Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: surfacemeshing object methods.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 #include <algorithm>
36 
38 
40 
41 using namespace std;
42 namespace Nektar
43 {
44 namespace NekMeshUtils
45 {
46 
47 ModuleKey SurfaceMesh::className = GetModuleFactory().RegisterCreatorFunction(
48  ModuleKey(eProcessModule, "surfacemesh"),
49  SurfaceMesh::create,
50  "Generates a surface mesh");
51 
52 SurfaceMesh::SurfaceMesh(MeshSharedPtr m) : ProcessModule(m)
53 {
54 
55 }
56 
58 {
59 }
60 
62 {
63  m_mesh->m_expDim--; //just to make it easier to surface mesh for now
64 
65  if (m_mesh->m_verbose)
66  cout << endl << "Surface meshing" << endl;
67 
68  if (m_mesh->m_verbose)
69  cout << endl << "\tCurve meshing:" << endl << endl;
70 
71  m_mesh->m_numNodes = m_mesh->m_cad->GetNumVerts();
72 
73  // linear mesh all curves
74  for (int i = 1; i <= m_mesh->m_cad->GetNumCurve(); i++)
75  {
76  if (m_mesh->m_verbose)
77  {
79  i, m_mesh->m_cad->GetNumCurve(), "Curve progress");
80  }
81 
83 
84  m_curvemeshes[i]->Mesh();
85  }
86 
87  if (m_mesh->m_verbose)
88  cout << endl << "\tFace meshing:" << endl << endl;
89 
90  bool validError = false;
91  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
92  {
93  if (m_mesh->m_verbose)
94  {
96  i, m_mesh->m_cad->GetNumSurf(), "Validating curve meshes");
97  }
98  m_facemeshes[i] =
100  m_curvemeshes, i);
101 
102  validError = validError ? true : m_facemeshes[i]->ValidateCurves();
103  }
104 
105  ASSERTL0(!validError,"valdity error in curve meshes");
106 
107  // linear mesh all surfaces
109  int i = 1;
110  for(fit = m_facemeshes.begin(); fit != m_facemeshes.end(); fit++)
111  {
112  if (m_mesh->m_verbose)
113  {
115  i, m_mesh->m_cad->GetNumSurf(), "Face progress");
116  }
117  fit->second->Mesh();
118  i++;
119  }
120 
121  ProcessVertices();
122  ProcessEdges();
123  ProcessFaces();
124  ProcessElements();
126 
127  Report();
128 
130  for(it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
131  {
132  if((*it)->m_elLink.size() != 2)
133  {
134  ASSERTL0(false,"surface mesh connectivity error");
135  }
136  }
137 
138  m_mesh->m_expDim++; //revert dim
139 }
140 
142 {
143  if (m_mesh->m_verbose)
144  {
145  int ns = m_mesh->m_vertexSet.size();
146  int es = m_mesh->m_edgeSet.size();
147  int ts = m_mesh->m_element[2].size();
148  int ep = ns - es + ts;
149  cout << endl << "\tSurface mesh statistics" << endl;
150  cout << "\t\tNodes: " << ns << endl;
151  cout << "\t\tEdges: " << es << endl;
152  cout << "\t\tTriangles " << ts << endl;
153  cout << "\t\tEuler-PoincarĂ© characteristic: " << ep << endl;
154  }
155 }
156 
157 }
158 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
int PrintProgressbar(const int position, const int goal, const string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:69
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
STL namespace.
pair< ModuleType, 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:72
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:147
Abstract base class for processing modules.
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
std::map< int, FaceMeshSharedPtr > m_facemeshes
map of individual surface meshes from parametric surfaces
Definition: SurfaceMesh.h:70
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215