Nektar++
SurfaceMesh.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: SurfaceMeshing.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: surfacemeshing object methods.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 #include <algorithm>
35 
37 
39 
40 using namespace std;
41 namespace Nektar
42 {
43 namespace NekMeshUtils
44 {
45 
46 ModuleKey SurfaceMesh::className = GetModuleFactory().RegisterCreatorFunction(
47  ModuleKey(eProcessModule, "surfacemesh"),
48  SurfaceMesh::create,
49  "Generates a surface mesh");
50 
51 SurfaceMesh::SurfaceMesh(MeshSharedPtr m) : ProcessModule(m)
52 {
53 
54 }
55 
57 {
58 }
59 
61 {
62  m_mesh->m_expDim--; //just to make it easier to surface mesh for now
63 
64  if (m_mesh->m_verbose)
65  cout << endl << "Surface meshing" << endl;
66 
67  if (m_mesh->m_verbose)
68  cout << endl << "\tCurve meshing:" << endl << endl;
69 
70  m_mesh->m_numNodes = m_mesh->m_cad->GetNumVerts();
71 
72  // linear mesh all curves
73  for (int i = 1; i <= m_mesh->m_cad->GetNumCurve(); i++)
74  {
75  if (m_mesh->m_verbose)
76  {
78  i, m_mesh->m_cad->GetNumCurve(), "Curve progress");
79  }
80 
82 
83  m_curvemeshes[i]->Mesh();
84  }
85 
86  if (m_mesh->m_verbose)
87  cout << endl << "\tFace meshing:" << endl << endl;
88 
89  bool validError = false;
90  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
91  {
92  if (m_mesh->m_verbose)
93  {
95  i, m_mesh->m_cad->GetNumSurf(), "Validating curve meshes");
96  }
97  FaceMeshSharedPtr face =
99  m_curvemeshes, i);
100 
101  validError = validError ? true : face->ValidateCurves();
102 
103  face->ValidateLoops();
104  }
105 
106  ASSERTL0(!validError,"valdity error in curve meshes");
107 
108  // linear mesh all surfaces
109  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
110  {
111  if (m_mesh->m_verbose)
112  {
114  i, m_mesh->m_cad->GetNumSurf(), "Face progress");
115  }
116  m_facemeshes[i] =
118  m_curvemeshes, i);
119 
120  m_facemeshes[i]->Mesh();
121  }
122 
123  ProcessVertices();
124  ProcessEdges();
125  ProcessFaces();
126  ProcessElements();
128 
129  Report();
130 
131  EdgeSet::iterator it;
132  for(it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
133  {
134  if((*it)->m_elLink.size() != 2)
135  {
136  ASSERTL0(false,"surface mesh connectivity error");
137  }
138  }
139 
140  m_mesh->m_expDim++; //revert dim
141 }
143 {
144  if (m_mesh->m_verbose)
145  {
146  int ns = m_mesh->m_vertexSet.size();
147  int es = m_mesh->m_edgeSet.size();
148  int ts = m_mesh->m_element[2].size();
149  int ep = ns - es + ts;
150  cout << endl << "\tSurface mesh statistics" << endl;
151  cout << "\t\tNodes: " << ns << endl;
152  cout << "\t\tEdges: " << es << endl;
153  cout << "\t\tTriangles " << ts << endl;
154  cout << "\t\tEuler-PoincarĂ© characteristic: " << ep << endl;
155  }
156 }
157 
158 }
159 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:67
STL namespace.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:156
std::pair< ModuleType, std::string > ModuleKey
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
std::map< int, CurveMeshSharedPtr > m_curvemeshes
map of individual curve meshes of the curves in the domain
Definition: SurfaceMesh.h:71
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Abstract base class for processing modules.
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
std::shared_ptr< FaceMesh > FaceMeshSharedPtr
Definition: FaceMesh.h:165
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
std::map< int, FaceMeshSharedPtr > m_facemeshes
map of individual surface meshes from parametric surfaces
Definition: SurfaceMesh.h:69
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.
ModuleFactory & GetModuleFactory()