OGS
MeshRevision.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <array>
18 #include <limits>
19 #include <string>
20 #include <vector>
21 
22 #include "MeshLib/Properties.h"
23 
24 // forward declaration
25 namespace MeshLib
26 {
27 class Mesh;
28 class Node;
29 class Element;
30 } // namespace MeshLib
31 
32 namespace MeshLib
33 {
39 {
40 public:
47  explicit MeshRevision(MeshLib::Mesh& mesh);
48 
49  virtual ~MeshRevision() = default;
50 
53  double eps = std::numeric_limits<double>::epsilon()) const;
54 
57  std::vector<std::size_t> collapseNodeIndices(double eps) const;
58 
70  MeshLib::Mesh* simplifyMesh(const std::string& new_mesh_name, double eps,
71  unsigned min_elem_dim = 1) const;
72 
73 private:
76  std::vector<MeshLib::Node*> constructNewNodesArray(
77  const std::vector<std::size_t>& id_map) const;
78 
81  static unsigned getNumberOfUniqueNodes(
82  MeshLib::Element const* const element);
83 
90  MeshLib::Properties const& props,
91  std::vector<std::size_t> const& node_ids,
92  std::vector<std::size_t> const& elem_ids) const;
93 
101  std::size_t subdivideElement(
102  MeshLib::Element const* const element,
103  std::vector<MeshLib::Node*> const& nodes,
104  std::vector<MeshLib::Element*>& elements) const;
105 
106  // Revises an element by removing collapsed nodes, using the nodes vector
107  // from the result mesh.
108  std::size_t reduceElement(MeshLib::Element const* const element,
109  unsigned n_unique_nodes,
110  const std::vector<MeshLib::Node*>& nodes,
111  std::vector<MeshLib::Element*>& elements,
112  unsigned min_elem_dim) const;
113 
115  void cleanUp(std::vector<MeshLib::Node*>& nodes,
116  std::vector<MeshLib::Element*>& new_elements) const;
117 
119  unsigned subdivideQuad(MeshLib::Element const* const quad,
120  const std::vector<MeshLib::Node*>& nodes,
121  std::vector<MeshLib::Element*>& new_elements) const;
122 
124  unsigned subdivideHex(MeshLib::Element const* const hex,
125  const std::vector<MeshLib::Node*>& nodes,
126  std::vector<MeshLib::Element*>& new_elements) const;
127 
129  unsigned subdividePyramid(
130  MeshLib::Element const* const pyramid,
131  const std::vector<MeshLib::Node*>& nodes,
132  std::vector<MeshLib::Element*>& new_elements) const;
133 
135  unsigned subdividePrism(MeshLib::Element const* const prism,
136  const std::vector<MeshLib::Node*>& nodes,
137  std::vector<MeshLib::Element*>& new_elements) const;
138 
142  MeshLib::Element const* const element,
143  const std::vector<MeshLib::Node*>& nodes) const;
147  MeshLib::Element const* const element,
148  const std::vector<MeshLib::Node*>& nodes) const;
152  MeshLib::Element const* const element,
153  const std::vector<MeshLib::Node*>& nodes,
154  unsigned min_elem_dim = 1) const;
155 
161  unsigned reduceHex(MeshLib::Element const* const org_elem,
162  unsigned n_unique_nodes,
163  const std::vector<MeshLib::Node*>& nodes,
164  std::vector<MeshLib::Element*>& new_elements,
165  unsigned min_elem_dim) const;
168  void reducePyramid(MeshLib::Element const* const org_elem,
169  unsigned n_unique_nodes,
170  const std::vector<MeshLib::Node*>& nodes,
171  std::vector<MeshLib::Element*>& new_elements,
172  unsigned min_elem_dim) const;
178  unsigned reducePrism(MeshLib::Element const* const org_elem,
179  unsigned n_unique_nodes,
180  std::vector<MeshLib::Node*> const& nodes,
181  std::vector<MeshLib::Element*>& new_elements,
182  unsigned min_elem_dim) const;
183 
184  // In an element with 5 unique nodes, return the node that will be the top
185  // of the resulting pyramid
186  static unsigned findPyramidTopNode(
187  MeshLib::Element const& element,
188  std::array<std::size_t, 4> const& base_node_ids);
189 
192  static unsigned lutHexDiametralNode(unsigned id);
193 
196  static std::array<unsigned, 4> lutHexCuttingQuadNodes(unsigned id1,
197  unsigned id2);
198 
201  static std::pair<unsigned, unsigned> lutHexBackNodes(unsigned i, unsigned j,
202  unsigned k,
203  unsigned l);
204 
207  static unsigned lutPrismThirdNode(unsigned id1, unsigned id2);
208 
211 
212  static const std::array<unsigned, 8> _hex_diametral_nodes;
213 };
214 
215 } // namespace MeshLib
Definition of the class Properties that implements a container of properties.
MeshLib::Element * constructTri(MeshLib::Element const *const element, const std::vector< MeshLib::Node * > &nodes) const
Mesh & _mesh
The original mesh used for constructing the class.
Definition: MeshRevision.h:210
MeshLib::Properties copyProperties(MeshLib::Properties const &props, std::vector< std::size_t > const &node_ids, std::vector< std::size_t > const &elem_ids) const
unsigned getNumberOfCollapsableNodes(double eps=std::numeric_limits< double >::epsilon()) const
Returns the number of potentially collapsible nodes.
static unsigned lutHexDiametralNode(unsigned id)
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.
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
static unsigned findPyramidTopNode(MeshLib::Element const &element, std::array< std::size_t, 4 > const &base_node_ids)
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.
static std::array< unsigned, 4 > lutHexCuttingQuadNodes(unsigned id1, unsigned id2)
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.
static unsigned lutPrismThirdNode(unsigned id1, unsigned id2)
static std::pair< unsigned, unsigned > lutHexBackNodes(unsigned i, unsigned j, unsigned k, unsigned l)
MeshLib::Element * constructFourNodeElement(MeshLib::Element const *const element, const std::vector< MeshLib::Node * > &nodes, unsigned min_elem_dim=1) const
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.
void cleanUp(std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > &new_elements) const
Cleans up all nodes and elements if something went wrong.
std::vector< MeshLib::Node * > constructNewNodesArray(const std::vector< std::size_t > &id_map) const
static unsigned getNumberOfUniqueNodes(MeshLib::Element const *const element)
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
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
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
virtual ~MeshRevision()=default
static const std::array< unsigned, 8 > _hex_diametral_nodes
Definition: MeshRevision.h:212
MeshRevision(MeshLib::Mesh &mesh)
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
MeshLib::Element * constructLine(MeshLib::Element const *const element, const std::vector< MeshLib::Node * > &nodes) const
std::size_t subdivideElement(MeshLib::Element const *const element, std::vector< MeshLib::Node * > const &nodes, std::vector< MeshLib::Element * > &elements) const
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition: Properties.h:36