Example demonstrating Laplacian smoothing for mesh optimization. More...
#include <iostream>#include <sstream>#include "moab/Core.hpp"#include "moab/Skinner.hpp"#include "moab/CN.hpp"#include "moab/ProgOptions.hpp"#include "moab/CartVect.hpp"#include "moab/NestedRefine.hpp"#include "moab/VerdictWrapper.hpp"#include "matrix.h"
Include dependency graph for LaplacianSmoother.cpp:Go to the source code of this file.
Macros | |
| #define | WRITE_DEBUG_FILES |
| #define | RC MB_CHK_ERR( rval ) |
| #define | dbgprint(MSG) |
Functions | |
| ErrorCode | perform_laplacian_smoothing (Core *mb, Range &cells, Range &verts, int dim, Tag fixed, bool use_hc=false, bool use_acc=false, int acc_method=1, int num_its=10, double rel_eps=1e-5, double alpha=0.0, double beta=0.5, int report_its=1) |
| ErrorCode | hcFilter (Core *mb, moab::ParallelComm *pcomm, moab::Range &verts, int dim, Tag fixed, std::vector< double > &verts_o, std::vector< double > &verts_n, double alpha, double beta) |
| ErrorCode | laplacianFilter (Core *mb, moab::ParallelComm *pcomm, moab::Range &verts, int dim, Tag fixed, std::vector< double > &verts_o, std::vector< double > &verts_n, bool use_updated=true) |
| int | main (int argc, char **argv) |
Variables | |
| string | test_file_name = string( "input/surfrandomtris-4part.h5m" ) |
Example demonstrating Laplacian smoothing for mesh optimization.
This example shows how to:
Laplacian smoothing moves vertices to the average position of their connected neighbors, improving mesh quality while preserving topology.
Perform Laplacian relaxation on a mesh and its dual
To run: mpiexec -np np LaplacianSmoother [filename]
Briefly, Laplacian relaxation is a technique to smooth out a mesh. The centroid of each cell is computed from its vertex positions, then vertices are placed at the average of their connected cells' centroids.
In the parallel algorithm, an extra ghost layer of cells is exchanged. This allows us to compute the centroids for boundary cells on each processor where they appear; this eliminates the need for one round of data exchange (for those centroids) between processors. New vertex positions must be sent from owning processors to processors sharing those vertices. Convergence is measured as the maximum distance moved by any vertex.
In this implementation, a fixed number of iterations is performed. The final mesh is output to 'laplacianfinal.h5m' in the current directory (H5M format must be used since the file is written in parallel).
Usage: mpiexec -n 2 valgrind ./LaplacianSmoother -f input/surfrandomtris-64part.h5m -r 2 -p 2 -n 25
| argc | Number of command line arguments |
| argv | Command line arguments array |
Definition in file LaplacianSmoother.cpp.
| #define dbgprint | ( | MSG | ) |
Definition at line 74 of file LaplacianSmoother.cpp.
| #define RC MB_CHK_ERR( rval ) |
Definition at line 73 of file LaplacianSmoother.cpp.
| #define WRITE_DEBUG_FILES |
Definition at line 65 of file LaplacianSmoother.cpp.
| ErrorCode hcFilter | ( | Core * | mb, |
| moab::ParallelComm * | pcomm, | ||
| moab::Range & | verts, | ||
| int | dim, | ||
| Tag | fixed, | ||
| std::vector< double > & | verts_o, | ||
| std::vector< double > & | verts_n, | ||
| double | alpha, | ||
| double | beta | ||
| ) |
Definition at line 741 of file LaplacianSmoother.cpp.
References moab::Range::begin(), moab::Range::end(), moab::Range::erase(), ErrorCode, moab::ParallelComm::filter_pstatus(), moab::Core::get_adjacencies(), moab::Core::get_connectivity(), moab::index, moab::Range::index(), laplacianFilter(), mb, MB_SUCCESS, PSTATUS_NOT, PSTATUS_NOT_OWNED, RC, moab::Range::size(), moab::ParallelComm::size(), and moab::Core::tag_get_data().
Referenced by perform_laplacian_smoothing().
| ErrorCode laplacianFilter | ( | Core * | mb, |
| moab::ParallelComm * | pcomm, | ||
| moab::Range & | verts, | ||
| int | dim, | ||
| Tag | fixed, | ||
| std::vector< double > & | verts_o, | ||
| std::vector< double > & | verts_n, | ||
| bool | use_updated = true |
||
| ) |
Definition at line 656 of file LaplacianSmoother.cpp.
References moab::Range::begin(), moab::Range::end(), moab::Range::erase(), ErrorCode, moab::ParallelComm::filter_pstatus(), moab::Core::get_adjacencies(), moab::Core::get_connectivity(), moab::index, moab::Range::index(), mb, MB_SUCCESS, PSTATUS_NOT, PSTATUS_NOT_OWNED, RC, moab::Range::size(), moab::ParallelComm::size(), and moab::Core::tag_get_data().
Referenced by hcFilter(), and perform_laplacian_smoothing().
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 113 of file LaplacianSmoother.cpp.
References ProgOptions::addOpt(), moab::Core::create_meshset(), dbgprint, ErrorCode, moab::NestedRefine::exchange_ghosts(), moab::ParallelComm::exchange_tags(), moab::Skinner::find_skin(), moab::NestedRefine::generate_mesh_hierarchy(), moab::Core::get_entities_by_dimension(), moab::Core::get_entities_by_type(), moab::Core::load_file(), mb, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_INTEGER, MBVERTEX, MESHSET_SET, ProgOptions::parseCommandLine(), perform_laplacian_smoothing(), RC, moab::Range::size(), moab::ParallelComm::size(), moab::Core::tag_delete(), moab::Core::tag_get_handle(), moab::Core::tag_set_data(), test_file_name, and moab::Core::write_file().
| ErrorCode perform_laplacian_smoothing | ( | Core * | mb, |
| Range & | cells, | ||
| Range & | verts, | ||
| int | dim, | ||
| Tag | fixed, | ||
| bool | use_hc = false, |
||
| bool | use_acc = false, |
||
| int | acc_method = 1, |
||
| int | num_its = 10, |
||
| double | rel_eps = 1e-5, |
||
| double | alpha = 0.0, |
||
| double | beta = 0.5, |
||
| int | report_its = 1 |
||
| ) |
Definition at line 283 of file LaplacianSmoother.cpp.
References moab::Range::begin(), moab::ParallelComm::comm(), dbgprint, moab::Range::empty(), moab::Range::end(), ErrorCode, moab::ParallelComm::exchange_tags(), moab::ParallelComm::filter_pstatus(), moab::Core::get_connectivity(), moab::Core::get_coords(), moab::ParallelComm::get_pcomm(), moab::ParallelComm::get_shared_entities(), hcFilter(), moab::Core::id_from_handle(), moab::Range::insert(), laplacianFilter(), length(), moab::CartVect::length_squared(), mb, MB_CHK_ERR, moab::MB_SHAPE, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_DOUBLE, PSTATUS_NOT, PSTATUS_NOT_OWNED, moab::VerdictWrapper::quality_measure(), moab::ParallelComm::rank(), RC, moab::CartVect::scale(), moab::Core::set_coords(), moab::VerdictWrapper::set_size(), moab::Range::size(), moab::ParallelComm::size(), moab::Core::tag_get_data(), moab::Core::tag_get_handle(), moab::Core::tag_set_data(), moab::Core::type_from_handle(), and moab::Core::write_file().
Referenced by main().
| string test_file_name = string( "input/surfrandomtris-4part.h5m" ) |
Definition at line 70 of file LaplacianSmoother.cpp.
Referenced by main().