Nektar++
Public Member Functions | Public Attributes | List of all members
Nektar::NekMeshUtils::Mesh Class Reference

#include <Mesh.h>

Public Member Functions

NEKMESHUTILS_EXPORT Mesh ()
 
NEKMESHUTILS_EXPORT unsigned int GetNumElements ()
 Returns the total number of elements in the mesh with dimension expDim. More...
 
NEKMESHUTILS_EXPORT unsigned int GetNumBndryElements ()
 Returns the total number of elements in the mesh with dimension < expDim. More...
 
NEKMESHUTILS_EXPORT unsigned int GetNumEntities ()
 Returns the total number of entities in the mesh. More...
 
NEKMESHUTILS_EXPORT void MakeOrder (int order, LibUtilities::PointsType distType)
 Convert this mesh into a mesh of uniform polynomial order order with a curve point distribution distType. More...
 
NEKMESHUTILS_EXPORT void PrintStats (std::ostream &out)
 Print out basic statistics of this mesh. More...
 

Public Attributes

bool m_verbose
 Verbose flag. More...
 
unsigned int m_expDim
 Dimension of the expansion. More...
 
unsigned int m_spaceDim
 Dimension of the space in which the mesh is defined. More...
 
unsigned int m_nummode
 a order tag to aid output, a bit of a hack More...
 
std::vector< NodeSharedPtrm_node
 List of mesh nodes. More...
 
NodeSet m_vertexSet
 Set of element vertices. More...
 
int m_numNodes
 used for meshing purposes to keep trac of ids More...
 
EdgeSet m_edgeSet
 Set of element edges. More...
 
FaceSet m_faceSet
 Set of element faces. More...
 
ElementMap m_element
 Map for elements. More...
 
CompositeMap m_composite
 Map for composites. More...
 
ConditionMap m_condition
 Boundary conditions maps tag to condition. More...
 
std::vector< std::string > m_fields
 List of fields names. More...
 
std::unordered_map< int, Nodem_vertexNormals
 Map of vertex normals. More...
 
std::set< std::pair< int, int > > m_spherigonSurfs
 Set of all pairs of element ID and edge/face number on which to apply spherigon surface smoothing. More...
 
std::map< int, std::string > m_faceLabels
 List of face labels for composite annotation. More...
 
CADSystemSharedPtr m_cad
 CAD system pointer, if there is no cad its empty. More...
 
OctreeSharedPtr m_octree
 Octree system pointer, if there is no octree its empty. More...
 
LibUtilities::FieldMetaDataMap m_metadata
 Metadata map for storing any mesh generation parameters. More...
 
LibUtilities::CommSharedPtr m_comm
 MPI communicator in case we end up using MPI multiple times from Nektar++ SessionReader object. More...
 

Detailed Description

Definition at line 91 of file Mesh.h.

Constructor & Destructor Documentation

◆ Mesh()

NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Mesh::Mesh ( )
inline

Definition at line 94 of file Mesh.h.

94  : m_verbose(false), m_nummode(0)
95  {
96  }
unsigned int m_nummode
a order tag to aid output, a bit of a hack
Definition: Mesh.h:105
bool m_verbose
Verbose flag.
Definition: Mesh.h:99

Member Function Documentation

◆ GetNumBndryElements()

unsigned int Nektar::NekMeshUtils::Mesh::GetNumBndryElements ( )

Returns the total number of elements in the mesh with dimension < expDim.

Return the number of boundary elements (i.e. one below the expansion dimension).

Definition at line 61 of file Mesh.cpp.

62 {
63  unsigned int i, nElmt = 0;
64 
65  for (i = 0; i < m_expDim; ++i)
66  nElmt += m_element[i].size();
67 
68  return nElmt;
69 }
unsigned int m_expDim
Dimension of the expansion.
Definition: Mesh.h:101
ElementMap m_element
Map for elements.
Definition: Mesh.h:117

◆ GetNumElements()

unsigned int Nektar::NekMeshUtils::Mesh::GetNumElements ( )

Returns the total number of elements in the mesh with dimension expDim.

Return the number of elements of the expansion dimension.

Definition at line 52 of file Mesh.cpp.

53 {
54  return m_element[m_expDim].size();
55 }
unsigned int m_expDim
Dimension of the expansion.
Definition: Mesh.h:101
ElementMap m_element
Map for elements.
Definition: Mesh.h:117

◆ GetNumEntities()

unsigned int Nektar::NekMeshUtils::Mesh::GetNumEntities ( )

Returns the total number of entities in the mesh.

Return the total number of entities in the mesh (i.e. all elements, regardless of dimension).

Definition at line 75 of file Mesh.cpp.

76 {
77  unsigned int nEnt = 0;
78 
79  for (unsigned int d = 0; d <= m_expDim; ++d)
80  {
81  nEnt += m_element[d].size();
82  }
83 
84  return nEnt;
85 }
unsigned int m_expDim
Dimension of the expansion.
Definition: Mesh.h:101
ElementMap m_element
Map for elements.
Definition: Mesh.h:117

◆ MakeOrder()

void Nektar::NekMeshUtils::Mesh::MakeOrder ( int  order,
LibUtilities::PointsType  distType 
)

Convert this mesh into a mesh of uniform polynomial order order with a curve point distribution distType.

This routine adds curvature points into a mesh so that the resulting elements are all of a uniform order order and all high-order vertices are consistently ordered. It proceeds in a bottom-up fashion:

  • First construct all edge, face and elemental geometry mappings.
  • Then call the local MakeOrder functions on each edge, face and element of dimension Mesh::m_expDim.
  • Finally, any boundary elements are updated so that they have the same interior degrees of freedom as their corresponding edge or face links.

Definition at line 101 of file Mesh.cpp.

References ASSERTL1, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::eNodalPrismElec, Nektar::LibUtilities::eNodalPrismEvenlySpaced, Nektar::LibUtilities::eNodalTetElec, Nektar::LibUtilities::eNodalTetEvenlySpaced, Nektar::LibUtilities::eNodalTriElec, Nektar::LibUtilities::eNodalTriEvenlySpaced, Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eSegment, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, and Nektar::LibUtilities::PrintProgressbar().

102 {
103  // Going to make a copy of the curavture information, since this is cheaper
104  // than using Nektar's Geometry objects. Currently, the geometry objects
105  // which make up a 3D element dont use the volume nodes, they are just
106  // stored, so we can get away without copying them.
107 
108  int id = m_vertexSet.size();
109 
110  EdgeSet::iterator eit;
111  FaceSet::iterator fit;
112 
113  std::unordered_map<int, EdgeSharedPtr> edgeCopies;
114  std::unordered_map<int, FaceSharedPtr> faceCopies;
115 
116  // Decide on distribution of points to use for each shape type based on the
117  // input we've been supplied.
118  std::map<LibUtilities::ShapeType, LibUtilities::PointsType> pTypes;
119  if (distType == LibUtilities::ePolyEvenlySpaced)
120  {
128  }
129  else if (distType == LibUtilities::eGaussLobattoLegendre)
130  {
138  }
139  else
140  {
141  ASSERTL1(false, "Mesh::MakeOrder does not support this points type.");
142  }
143 
144  // Begin by copying mesh objects for edges and faces so that we don't affect
145  // any neighbouring elements in the mesh as we process each element. At the
146  // same time we delete the curvature from the original edge and face, which
147  // will be re-added with the MakeOrder routine.
148 
149  // First, we fill in the volume-interior nodes. This preserves the original
150  // curvature of the mesh.
151  const int nElmt = m_element[m_expDim].size();
152  int tmpId = 0;
153  for (int i = 0; i < nElmt; ++i)
154  {
155  if (m_verbose)
156  {
157  LibUtilities::PrintProgressbar(i, nElmt, "MakeOrder: Elements: ");
158  }
160  SpatialDomains::GeometrySharedPtr geom = el->GetGeom(m_spaceDim);
161  geom->FillGeom();
162  el->MakeOrder(order, geom, pTypes[el->GetConf().m_e], m_spaceDim,
163  tmpId);
164  }
165 
166  // Now make copies of each of the edges.
167  for (eit = m_edgeSet.begin(); eit != m_edgeSet.end(); eit++)
168  {
169  edgeCopies[(*eit)->m_id] = EdgeSharedPtr(new Edge(*(*eit)));
170  (*eit)->m_edgeNodes.clear();
171  }
172 
173  // Now copy faces. Make sure that this is a "deep copy", so that the face's
174  // edge list corresponds to the copied edges, otherwise we end up in a
175  // non-consistent state.
176  for (fit = m_faceSet.begin(); fit != m_faceSet.end(); fit++)
177  {
178  FaceSharedPtr tmpFace = FaceSharedPtr(new Face(*(*fit)));
179 
180  for (int i = 0; i < tmpFace->m_edgeList.size(); ++i)
181  {
182  tmpFace->m_edgeList[i] = edgeCopies[tmpFace->m_edgeList[i]->m_id];
183  }
184 
185  faceCopies[(*fit)->m_id] = tmpFace;
186  (*fit)->m_faceNodes.clear();
187  }
188 
189  std::unordered_set<int> processedEdges, processedFaces, processedVolumes;
190 
191  // note if CAD previously existed on the face or edge, the new points need
192  // to be projected onto the CAD entity.
193 
194  // Call MakeOrder with our generated geometries on each edge to fill in edge
195  // interior nodes.
196  int ct = 0;
197  for (eit = m_edgeSet.begin(); eit != m_edgeSet.end(); eit++, ct++)
198  {
199  if (m_verbose)
200  {
202  "MakeOrder: Edges: ");
203  }
204  int edgeId = (*eit)->m_id;
205 
206  if (processedEdges.find(edgeId) != processedEdges.end())
207  {
208  continue;
209  }
210 
211  EdgeSharedPtr cpEdge = edgeCopies[edgeId];
212  SpatialDomains::GeometrySharedPtr geom = cpEdge->GetGeom(m_spaceDim);
213  geom->FillGeom();
214 
215  (*eit)->MakeOrder(order, geom, pTypes[LibUtilities::eSegment],
216  m_spaceDim, id);
217  processedEdges.insert(edgeId);
218  }
219 
220  // Call MakeOrder with our generated geometries on each face to fill in face
221  // interior nodes.
222  ct = 0;
223  for (fit = m_faceSet.begin(); fit != m_faceSet.end(); fit++, ct++)
224  {
225  if (m_verbose)
226  {
228  "MakeOrder: Faces: ");
229  }
230  int faceId = (*fit)->m_id;
231 
232  if (processedFaces.find(faceId) != processedFaces.end())
233  {
234  continue;
235  }
236 
237  FaceSharedPtr cpFace = faceCopies[faceId];
238  SpatialDomains::GeometrySharedPtr geom = cpFace->GetGeom(m_spaceDim);
239  geom->FillGeom();
240 
241  LibUtilities::ShapeType type = (*fit)->m_vertexList.size() == 3
244  (*fit)->MakeOrder(order, geom, pTypes[type], m_spaceDim, id);
245  processedFaces.insert(faceId);
246  }
247 
248  // Copy curvature into boundary conditions
249  for (int i = 0; i < m_element[1].size(); ++i)
250  {
251  ElementSharedPtr el = m_element[1][i];
252  EdgeSharedPtr edge = el->GetEdgeLink();
253 
254  if (!edge)
255  {
256  continue;
257  }
258 
259  // Copy face curvature
260  el->MakeOrder(order, SpatialDomains::GeometrySharedPtr(),
261  pTypes[el->GetConf().m_e], m_spaceDim, id, true);
262  el->SetVolumeNodes(edge->m_edgeNodes);
263  }
264 
265  for (int i = 0; i < m_element[2].size(); ++i)
266  {
267  ElementSharedPtr el = m_element[2][i];
268  FaceSharedPtr face = el->GetFaceLink();
269 
270  if (!face)
271  {
272  continue;
273  }
274 
275  // Copy face curvature
276  el->MakeOrder(order, SpatialDomains::GeometrySharedPtr(),
277  pTypes[el->GetConf().m_e], m_spaceDim, id, true);
278  el->SetVolumeNodes(face->m_faceNodes);
279  }
280 
281  for (int i = 0; i < nElmt; ++i)
282  {
283  vector<NodeSharedPtr> tmp = m_element[m_expDim][i]->GetVolumeNodes();
284  for (int j = 0; j < tmp.size(); ++j)
285  {
286  tmp[j]->m_id = id++;
287  }
288  }
289 
290  if (m_verbose)
291  {
292  cout << endl;
293  }
294 }
FaceSet m_faceSet
Set of element faces.
Definition: Mesh.h:115
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:67
unsigned int m_spaceDim
Dimension of the space in which the mesh is defined.
Definition: Mesh.h:103
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
unsigned int m_expDim
Dimension of the expansion.
Definition: Mesh.h:101
std::shared_ptr< Face > FaceSharedPtr
Definition: Face.h:155
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:64
ElementMap m_element
Map for elements.
Definition: Mesh.h:117
NodeSet m_vertexSet
Set of element vertices.
Definition: Mesh.h:109
std::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
3D Nodal Electrostatic Points on a Tetrahedron
Definition: PointsType.h:73
std::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
EdgeSet m_edgeSet
Set of element edges.
Definition: Mesh.h:113
bool m_verbose
Verbose flag.
Definition: Mesh.h:99
3D Evenly-spaced points on a Tetrahedron
Definition: PointsType.h:72
3D Evenly-spaced points on a Prism
Definition: PointsType.h:74
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:71
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:69
3D electrostatically spaced points on a Prism
Definition: PointsType.h:75

◆ PrintStats()

void Nektar::NekMeshUtils::Mesh::PrintStats ( std::ostream &  out)

Print out basic statistics of this mesh.

Definition at line 299 of file Mesh.cpp.

References Nektar::LibUtilities::ShapeTypeMap, and Nektar::LibUtilities::SIZE_ShapeType.

300 {
301  out << "Mesh statistics" << std::endl
302  << "---------------" << std::endl
303  << std::endl;
304 
305  out << "Mesh dimension : " << m_spaceDim << std::endl
306  << "Element dimension : " << m_expDim << std::endl
307  << "Has CAD attached : " << (m_cad ? "yes" : "no") << std::endl
308  << "Node count : " << m_vertexSet.size() << std::endl;
309 
310  if (m_edgeSet.size() > 0)
311  {
312  out << "Edge count : " << m_edgeSet.size() << std::endl;
313  }
314 
315  if (m_faceSet.size() > 0)
316  {
317  out << "Face count : " << m_faceSet.size() << std::endl;
318  }
319 
320  out << "Elements : " << m_element[m_expDim].size() << std::endl
321  << "Bnd elements : " << m_element[m_expDim - 1].size()
322  << std::endl;
323 
324  // Print out number of composites
325 
326  out << "Number of composites : " << m_composite.size() << std::endl;
327 
328  // Calculate domain extent
329  auto extent = m_element[m_expDim][0]->GetBoundingBox();
330  for (int i = 1; i < m_element[m_expDim].size(); ++i)
331  {
332  auto el = m_element[m_expDim][i]->GetBoundingBox();
333  extent.first.m_x = std::min(extent.first.m_x, el.first.m_x);
334  extent.first.m_y = std::min(extent.first.m_y, el.first.m_y);
335  extent.first.m_z = std::min(extent.first.m_z, el.first.m_z);
336  extent.second.m_x = std::max(extent.second.m_x, el.second.m_x);
337  extent.second.m_y = std::max(extent.second.m_y, el.second.m_y);
338  extent.second.m_z = std::max(extent.second.m_z, el.second.m_z);
339  }
340 
341  out << "Lower mesh extent : " << extent.first.m_x << " "
342  << extent.first.m_y << " " << extent.first.m_z << std::endl
343  << "Upper mesh extent : " << extent.second.m_x << " "
344  << extent.second.m_y << " " << extent.second.m_z << std::endl;
345 
346  std::map<LibUtilities::ShapeType, std::pair<int, int>> elmtCounts;
347 
348  for (int i = 1; i < LibUtilities::SIZE_ShapeType; ++i)
349  {
350  elmtCounts[(LibUtilities::ShapeType)i] = std::make_pair(0, 0);
351  }
352 
353  for (int dim = 0; dim <= 3; ++dim)
354  {
355  for (auto &elmt : m_element[dim])
356  {
357  auto &counts = elmtCounts[elmt->GetShapeType()];
358 
359  if (elmt->IsDeformed())
360  {
361  counts.second++;
362  }
363  else
364  {
365  counts.first++;
366  }
367  }
368  }
369 
370  out << std::endl << "Element counts (regular/deformed/total):" << std::endl;
371  for (int i = 1; i < LibUtilities::SIZE_ShapeType; ++i)
372  {
373  auto shapeType = (LibUtilities::ShapeType)i;
374  auto counts = elmtCounts[shapeType];
375 
376  if (counts.first + counts.second == 0)
377  {
378  continue;
379  }
380 
381  out << " " << std::setw(14)
383  << setw(12) << counts.first << " " << setw(12) << counts.second
384  << " " << setw(12) << counts.first + counts.second << std::endl;
385  }
386 }
FaceSet m_faceSet
Set of element faces.
Definition: Mesh.h:115
CompositeMap m_composite
Map for composites.
Definition: Mesh.h:119
unsigned int m_spaceDim
Dimension of the space in which the mesh is defined.
Definition: Mesh.h:103
unsigned int m_expDim
Dimension of the expansion.
Definition: Mesh.h:101
const char *const ShapeTypeMap[]
Definition: ShapeType.hpp:67
ElementMap m_element
Map for elements.
Definition: Mesh.h:117
NodeSet m_vertexSet
Set of element vertices.
Definition: Mesh.h:109
CADSystemSharedPtr m_cad
CAD system pointer, if there is no cad its empty.
Definition: Mesh.h:132
EdgeSet m_edgeSet
Set of element edges.
Definition: Mesh.h:113

Member Data Documentation

◆ m_cad

CADSystemSharedPtr Nektar::NekMeshUtils::Mesh::m_cad

CAD system pointer, if there is no cad its empty.

Definition at line 132 of file Mesh.h.

◆ m_comm

LibUtilities::CommSharedPtr Nektar::NekMeshUtils::Mesh::m_comm

MPI communicator in case we end up using MPI multiple times from Nektar++ SessionReader object.

Definition at line 139 of file Mesh.h.

◆ m_composite

CompositeMap Nektar::NekMeshUtils::Mesh::m_composite

Map for composites.

Definition at line 119 of file Mesh.h.

◆ m_condition

ConditionMap Nektar::NekMeshUtils::Mesh::m_condition

Boundary conditions maps tag to condition.

Definition at line 121 of file Mesh.h.

◆ m_edgeSet

EdgeSet Nektar::NekMeshUtils::Mesh::m_edgeSet

Set of element edges.

Definition at line 113 of file Mesh.h.

◆ m_element

ElementMap Nektar::NekMeshUtils::Mesh::m_element

Map for elements.

Definition at line 117 of file Mesh.h.

◆ m_expDim

unsigned int Nektar::NekMeshUtils::Mesh::m_expDim

Dimension of the expansion.

Definition at line 101 of file Mesh.h.

◆ m_faceLabels

std::map<int, std::string> Nektar::NekMeshUtils::Mesh::m_faceLabels

List of face labels for composite annotation.

Definition at line 130 of file Mesh.h.

◆ m_faceSet

FaceSet Nektar::NekMeshUtils::Mesh::m_faceSet

Set of element faces.

Definition at line 115 of file Mesh.h.

◆ m_fields

std::vector<std::string> Nektar::NekMeshUtils::Mesh::m_fields

List of fields names.

Definition at line 123 of file Mesh.h.

◆ m_metadata

LibUtilities::FieldMetaDataMap Nektar::NekMeshUtils::Mesh::m_metadata

Metadata map for storing any mesh generation parameters.

Definition at line 136 of file Mesh.h.

◆ m_node

std::vector<NodeSharedPtr> Nektar::NekMeshUtils::Mesh::m_node

List of mesh nodes.

Definition at line 107 of file Mesh.h.

◆ m_nummode

unsigned int Nektar::NekMeshUtils::Mesh::m_nummode

a order tag to aid output, a bit of a hack

Definition at line 105 of file Mesh.h.

◆ m_numNodes

int Nektar::NekMeshUtils::Mesh::m_numNodes

used for meshing purposes to keep trac of ids

Definition at line 111 of file Mesh.h.

◆ m_octree

OctreeSharedPtr Nektar::NekMeshUtils::Mesh::m_octree

Octree system pointer, if there is no octree its empty.

Definition at line 134 of file Mesh.h.

◆ m_spaceDim

unsigned int Nektar::NekMeshUtils::Mesh::m_spaceDim

Dimension of the space in which the mesh is defined.

Definition at line 103 of file Mesh.h.

◆ m_spherigonSurfs

std::set<std::pair<int, int> > Nektar::NekMeshUtils::Mesh::m_spherigonSurfs

Set of all pairs of element ID and edge/face number on which to apply spherigon surface smoothing.

Definition at line 128 of file Mesh.h.

◆ m_verbose

bool Nektar::NekMeshUtils::Mesh::m_verbose

Verbose flag.

Definition at line 99 of file Mesh.h.

◆ m_vertexNormals

std::unordered_map<int, Node> Nektar::NekMeshUtils::Mesh::m_vertexNormals

Map of vertex normals.

Definition at line 125 of file Mesh.h.

◆ m_vertexSet

NodeSet Nektar::NekMeshUtils::Mesh::m_vertexSet

Set of element vertices.

Definition at line 109 of file Mesh.h.