OGS
|
Collapses nodes with a distance smaller min_distance and reduces elements accordingly.
Definition at line 38 of file MeshRevision.h.
#include <MeshRevision.h>
Public Member Functions | |
MeshRevision (MeshLib::Mesh &mesh) | |
virtual | ~MeshRevision ()=default |
unsigned | getNumberOfCollapsableNodes (double eps=std::numeric_limits< double >::epsilon()) const |
Returns the number of potentially collapsible nodes. More... | |
std::vector< std::size_t > | collapseNodeIndices (double eps) const |
MeshLib::Mesh * | simplifyMesh (const std::string &new_mesh_name, double eps, unsigned min_elem_dim=1) const |
Private Member Functions | |
std::vector< MeshLib::Node * > | constructNewNodesArray (const std::vector< std::size_t > &id_map) const |
MeshLib::Properties | copyProperties (MeshLib::Properties const &props, std::vector< std::size_t > const &node_ids, std::vector< std::size_t > const &elem_ids) const |
std::size_t | subdivideElement (MeshLib::Element const *const element, std::vector< MeshLib::Node * > const &nodes, std::vector< MeshLib::Element * > &elements) const |
std::size_t | reduceElement (MeshLib::Element const *const element, unsigned n_unique_nodes, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &elements, unsigned min_elem_dim) const |
void | cleanUp (std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements) const |
Cleans up all nodes and elements if something went wrong. More... | |
unsigned | subdivideQuad (MeshLib::Element const *const quad, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements) const |
Subdivides a nonplanar quad into two triangles. More... | |
unsigned | subdivideHex (MeshLib::Element const *const hex, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements) const |
Subdivides a Hex with nonplanar faces into tets. More... | |
unsigned | subdividePyramid (MeshLib::Element const *const pyramid, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements) const |
Subdivides a pyramid with a nonplanar base into two tets. More... | |
unsigned | subdividePrism (MeshLib::Element const *const prism, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements) const |
Subdivides a prism with nonplanar quad faces into two tets. More... | |
MeshLib::Element * | constructLine (MeshLib::Element const *const element, const std::vector< MeshLib::Node * > &nodes) const |
MeshLib::Element * | constructTri (MeshLib::Element const *const element, const std::vector< MeshLib::Node * > &nodes) const |
MeshLib::Element * | constructFourNodeElement (MeshLib::Element const *const element, const std::vector< MeshLib::Node * > &nodes, unsigned min_elem_dim=1) const |
unsigned | reduceHex (MeshLib::Element const *const org_elem, unsigned n_unique_nodes, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements, unsigned min_elem_dim) const |
void | reducePyramid (MeshLib::Element const *const org_elem, unsigned n_unique_nodes, const std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements, unsigned min_elem_dim) const |
unsigned | reducePrism (MeshLib::Element const *const org_elem, unsigned n_unique_nodes, std::vector< MeshLib::Node * > const &nodes, std::vector< MeshLib::Element * > &new_elements, unsigned min_elem_dim) const |
Static Private Member Functions | |
static unsigned | getNumberOfUniqueNodes (MeshLib::Element const *const element) |
static unsigned | findPyramidTopNode (MeshLib::Element const &element, std::array< std::size_t, 4 > const &base_node_ids) |
static unsigned | lutHexDiametralNode (unsigned id) |
static std::array< unsigned, 4 > | lutHexCuttingQuadNodes (unsigned id1, unsigned id2) |
static std::pair< unsigned, unsigned > | lutHexBackNodes (unsigned i, unsigned j, unsigned k, unsigned l) |
static unsigned | lutPrismThirdNode (unsigned id1, unsigned id2) |
Private Attributes | |
Mesh & | _mesh |
The original mesh used for constructing the class. More... | |
Static Private Attributes | |
static const std::array< unsigned, 8 > | _hex_diametral_nodes |
|
explicit |
Constructor
mesh | The mesh which is being revised. Note that node IDs in mesh are changed during computation but are reset after the algorithms implemented here are finished |
Definition at line 32 of file MeshRevision.cpp.
|
virtualdefault |
|
private |
Cleans up all nodes and elements if something went wrong.
std::vector< std::size_t > MeshLib::MeshRevision::collapseNodeIndices | ( | double | eps | ) | const |
Designates nodes to be collapsed by setting their ID to the index of the node they will get merged with.
Definition at line 120 of file MeshRevision.cpp.
References _mesh, MathLib::Point3dWithID::getID(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfNodes(), GeoLib::Grid< POINT >::getPntVecsOfGridCellsIntersectingCube(), and MathLib::sqrDist().
Referenced by getNumberOfCollapsableNodes(), MeshAnalysisDialog::on_startButton_pressed(), and simplifyMesh().
|
private |
Creates a quad or a tet, depending if the four nodes being coplanar or not (element should have exactly four unique nodes!)
Definition at line 926 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfBaseNodes(), MathLib::isCoplanar(), and MeshLib::Element::validate().
Referenced by reduceHex(), reducePrism(), and reducePyramid().
|
private |
Creates a line element from the first two unique nodes found in the element (element should have exactly two unique nodes!)
Definition at line 873 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfBaseNodes().
Referenced by reduceElement(), reduceHex(), reducePrism(), and reducePyramid().
|
private |
Constructs a new node vector for the resulting mesh by removing all nodes whose ID indicates they need to be merged/removed.
Definition at line 175 of file MeshRevision.cpp.
References _mesh, and MeshLib::Mesh::getNodes().
Referenced by simplifyMesh().
|
private |
Creates a triangle element from the first three unique nodes found in the element (element should have exactly three unique nodes!)
Definition at line 892 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfBaseNodes().
Referenced by reduceElement(), reduceHex(), reducePrism(), and reducePyramid().
|
private |
Copies all scalar arrays according to the restructured Node- and Element-vectors after the mesh revision process (i.e. collapsed nodes, split elements, etc.)
Definition at line 252 of file MeshRevision.cpp.
References MeshLib::Cell, MeshLib::Properties::createNewPropertyVector(), MeshLib::Properties::existsPropertyVector(), MeshLib::fillElemProperty(), MeshLib::fillNodeProperty(), MeshLib::Properties::getPropertyVector(), MeshLib::Properties::getPropertyVectorNames(), MaterialPropertyLib::name, MeshLib::Node, and WARN().
Referenced by simplifyMesh().
|
staticprivate |
Definition at line 984 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfBaseNodes().
Referenced by reduceHex().
unsigned MeshLib::MeshRevision::getNumberOfCollapsableNodes | ( | double | eps = std::numeric_limits<double>::epsilon() | ) | const |
Returns the number of potentially collapsible nodes.
Definition at line 34 of file MeshRevision.cpp.
References collapseNodeIndices().
Referenced by MeshLib::MeshValidation::MeshValidation().
|
staticprivate |
Calculates the number of unique nodes in an element (i.e. uncollapsed nodes)
Definition at line 204 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfBaseNodes().
Referenced by simplifyMesh().
|
staticprivate |
When a hex is subdivided into two prisms, this returns the nodes of the hex edge that will serve as the back of one of the prisms.
Definition at line 1189 of file MeshRevision.cpp.
References lutHexDiametralNode().
Referenced by reduceHex().
|
staticprivate |
Lookup-table for returning four nodes connected to the two nodes (id1, id2) forming an edge in a Hex
Definition at line 1013 of file MeshRevision.cpp.
Referenced by reduceHex().
|
staticprivate |
Lookup-table for returning the diametral node id of the given node id in a Hex
Definition at line 1008 of file MeshRevision.cpp.
References _hex_diametral_nodes.
Referenced by lutHexBackNodes(), and reduceHex().
|
staticprivate |
Lookup-table for returning the third node of bottom or top triangle given the other two
Definition at line 1241 of file MeshRevision.cpp.
Referenced by reducePrism().
|
private |
Definition at line 343 of file MeshRevision.cpp.
References constructLine(), constructTri(), ERR(), MeshLib::Element::getGeomType(), MeshLib::HEXAHEDRON, MeshLib::PRISM, MeshLib::PYRAMID, MeshLib::QUAD, reduceHex(), reducePrism(), reducePyramid(), MeshLib::TETRAHEDRON, and MeshLib::TRIANGLE.
Referenced by simplifyMesh().
|
private |
Reduces a hexahedron element by removing collapsed nodes and constructing one or more new elements from the remaining nodes.
Definition at line 490 of file MeshRevision.cpp.
References constructFourNodeElement(), constructLine(), constructTri(), ERR(), findPyramidTopNode(), MeshLib::Element::getFace(), MeshLib::Element::getGeomType(), MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), MeshLib::getNodeIDinElement(), MeshLib::Element::isEdge(), lutHexBackNodes(), lutHexCuttingQuadNodes(), lutHexDiametralNode(), MeshLib::QUAD, and reducePrism().
Referenced by reduceElement().
|
private |
Reduces a prism element by removing collapsed nodes and constructing one or two new elements from the remaining nodes.
Definition at line 783 of file MeshRevision.cpp.
References constructFourNodeElement(), constructLine(), constructTri(), ERR(), MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), MathLib::isCoplanar(), and lutPrismThirdNode().
Referenced by reduceElement(), and reduceHex().
|
private |
Reduces a pyramid element by removing collapsed nodes and constructing a new elements from the remaining nodes.
Definition at line 758 of file MeshRevision.cpp.
References constructFourNodeElement(), constructLine(), and constructTri().
Referenced by reduceElement().
MeshLib::Mesh * MeshLib::MeshRevision::simplifyMesh | ( | const std::string & | new_mesh_name, |
double | eps, | ||
unsigned | min_elem_dim = 1 |
||
) | const |
Create a new mesh where all nodes with a distance < eps from each other are collapsed. Elements are adjusted accordingly and elements with nonplanar faces are subdivided into geometrically correct elements.
new_mesh_name | New name. |
eps | Minimum distance for nodes not to be collapsed |
min_elem_dim | Minimum dimension of elements to be inserted into new mesh (i.e. min_elem_dim=3 will prevent the new mesh to contain 2D elements) |
Definition at line 49 of file MeshRevision.cpp.
References _mesh, BaseLib::cleanupVectorElements(), collapseNodeIndices(), constructNewNodesArray(), MeshLib::copyElement(), copyProperties(), ERR(), MeshLib::Element::getDimension(), MeshLib::Mesh::getElements(), MeshLib::Element::getNumberOfBaseNodes(), MeshLib::Mesh::getNumberOfElements(), getNumberOfUniqueNodes(), MeshLib::Mesh::getProperties(), NonCoplanar, reduceElement(), MeshLib::Mesh::resetNodeIDs(), subdivideElement(), and MeshLib::Element::validate().
Referenced by MeshLib::convertSurfaceToMesh(), and main().
|
private |
Subdivides an element if it has a face that is not coplanar
element | the element that will be subdivided |
nodes | vector containing the nodes the elements originated by the subdivision are based on |
elements | vector of MeshLib::Elements; the elements originated by the subdivision will be inserted into elements |
Definition at line 319 of file MeshRevision.cpp.
References MeshLib::Element::getGeomType(), MeshLib::HEXAHEDRON, MeshLib::PRISM, MeshLib::PYRAMID, MeshLib::QUAD, subdivideHex(), subdividePrism(), subdividePyramid(), and subdivideQuad().
Referenced by simplifyMesh().
|
private |
Subdivides a Hex with nonplanar faces into tets.
Definition at line 410 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and subdividePrism().
Referenced by subdivideElement().
|
private |
Subdivides a prism with nonplanar quad faces into two tets.
Definition at line 464 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), and MeshLib::Element::getNode().
Referenced by subdivideElement(), and subdivideHex().
|
private |
Subdivides a pyramid with a nonplanar base into two tets.
Definition at line 440 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), and MeshLib::Element::getNode().
Referenced by subdivideElement().
|
private |
Subdivides a nonplanar quad into two triangles.
Definition at line 392 of file MeshRevision.cpp.
References MathLib::Point3dWithID::getID(), and MeshLib::Element::getNode().
Referenced by subdivideElement().
|
staticprivate |
Definition at line 212 of file MeshRevision.h.
Referenced by lutHexDiametralNode().
|
private |
The original mesh used for constructing the class.
Definition at line 210 of file MeshRevision.h.
Referenced by collapseNodeIndices(), constructNewNodesArray(), and simplifyMesh().