Example demonstrating Lloyd relaxation for mesh smoothing. More...
#include "moab/Core.hpp"#include "moab/Skinner.hpp"#include "moab/CN.hpp"#include "moab/CartVect.hpp"#include <iostream>#include <sstream>
Include dependency graph for LloydRelaxation.cpp:Go to the source code of this file.
Functions | |
| ErrorCode | perform_lloyd_relaxation (Interface *mb, Range &verts, Range &cells, Tag fixed, int num_its, int report_its) |
| int | main (int argc, char **argv) |
Variables | |
| string | test_file_name = string( MESH_DIR ) + string( "/surfrandomtris-4part.h5m" ) |
Example demonstrating Lloyd relaxation for mesh smoothing.
This example shows how to:
Lloyd relaxation is a technique to smooth out a mesh by iteratively moving vertices to the centroids of their connected cells.
Perform Lloyd relaxation on a mesh and its dual
To run: mpiexec -np np LloydRelaxation [filename]
Briefly, Lloyd 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 'lloydfinal.h5m' in the current directory (H5M format must be used since the file is written in parallel).
| argc | Number of command line arguments |
| argv | Command line arguments array |
Definition in file LloydRelaxation.cpp.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 60 of file LloydRelaxation.cpp.
References moab::Skinner::find_skin(), moab::Core::get_entities_by_dimension(), moab::Core::get_entities_by_type(), moab::Core::load_file(), mb, MB_CHK_ERR, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_INTEGER, MBVERTEX, perform_lloyd_relaxation(), 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_lloyd_relaxation | ( | Interface * | mb, |
| Range & | verts, | ||
| Range & | cells, | ||
| Tag | fixed, | ||
| int | num_its, | ||
| int | report_its | ||
| ) |
Definition at line 141 of file LloydRelaxation.cpp.
References moab::Range::begin(), moab::ParallelComm::comm(), moab::Range::empty(), moab::Range::end(), ErrorCode, moab::ParallelComm::exchange_tags(), moab::ParallelComm::filter_pstatus(), moab::Core::get_adjacencies(), moab::Core::get_connectivity(), moab::Core::get_coords(), moab::ParallelComm::get_pcomm(), moab::ParallelComm::get_shared_entities(), moab::Range::insert(), length(), moab::CN::MAX_NODES_PER_ELEMENT, mb, MB_CHK_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_DOUBLE, PSTATUS_NOT, PSTATUS_NOT_OWNED, moab::ParallelComm::rank(), moab::Core::set_coords(), moab::Range::size(), moab::ParallelComm::size(), moab::Core::tag_delete(), moab::Core::tag_get_data(), moab::Core::tag_get_handle(), and moab::Core::tag_set_data().
Referenced by main().
| string test_file_name = string( MESH_DIR ) + string( "/surfrandomtris-4part.h5m" ) |
Definition at line 56 of file LloydRelaxation.cpp.
Referenced by main().