Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
Nektar::NekMeshUtils::TetMesh Class Reference

class for taking surface mesh and octree spec and making a 3d tet mesh More...

#include <TetMesh.h>

Collaboration diagram for Nektar::NekMeshUtils::TetMesh:
Collaboration graph
[legend]

Public Member Functions

 TetMesh (MeshSharedPtr m, OctreeSharedPtr oct)
 default constructor More...
 
 TetMesh (MeshSharedPtr m, OctreeSharedPtr oct, BLMeshSharedPtr b)
 constructor for pseudo surface More...
 
void Mesh ()
 execute tet meshing More...
 

Private Attributes

MeshSharedPtr m_mesh
 
OctreeSharedPtr m_octree
 octree object More...
 
BLMeshSharedPtr m_blmesh
 bl mesh More...
 
bool m_pseudosurface
 
int m_numtet
 number of tetrahedra More...
 
std::vector< Array< OneD, int > > m_tetconnect
 conncetivity of the tets from the interface More...
 
std::map< int, FaceSharedPtrm_surftopriface
 

Friends

class MemoryManager< TetMesh >
 

Detailed Description

class for taking surface mesh and octree spec and making a 3d tet mesh

Definition at line 58 of file TetMesh.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::TetMesh::TetMesh ( MeshSharedPtr  m,
OctreeSharedPtr  oct 
)
inline

default constructor

Definition at line 66 of file TetMesh.h.

References m_pseudosurface.

67  : m_mesh(m), m_octree(oct)
68  {
69  m_pseudosurface = false;
70  };
OctreeSharedPtr m_octree
octree object
Definition: TetMesh.h:90
Nektar::NekMeshUtils::TetMesh::TetMesh ( MeshSharedPtr  m,
OctreeSharedPtr  oct,
BLMeshSharedPtr  b 
)
inline

constructor for pseudo surface

Definition at line 75 of file TetMesh.h.

References m_pseudosurface.

76  : m_mesh(m), m_octree(oct), m_blmesh(b)
77  {
78  m_pseudosurface = true;
79  };
OctreeSharedPtr m_octree
octree object
Definition: TetMesh.h:90
BLMeshSharedPtr m_blmesh
bl mesh
Definition: TetMesh.h:92

Member Function Documentation

void Nektar::NekMeshUtils::TetMesh::Mesh ( )

execute tet meshing

Definition at line 45 of file TetMesh.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, Nektar::NekMeshUtils::GetElementFactory(), and Nektar::iterator.

46 {
47  if (m_mesh->m_verbose)
48  cout << endl << endl << "Tetrahdral mesh generation" << endl;
49 
52 
53  map<int, NodeSharedPtr> TetgenIdToNode;
54  map<int, int> NodeIdToTetgenId;
55  // at this point all nodes are in m_mesh->m_vertexset, but if there is a
56  // boundary layer, we dont want all of them, also, tetgen ids must be
57  // sequential so there is a map from tetgen id to real nodes
58 
59  // build sequentially ordered maps of nodes that exist and there delta value
60  // in the octree
61  map<int, NekDouble> TetgenIdToDelta;
62  vector<Array<OneD, int> >
63  surfacetris; // surface mesh connectivity based on tetgenids
64 
65  int cnt = 0;
66  if (!m_pseudosurface)
67  {
68  // build surface mesh and node map from all surface elements
69  for (int i = 0; i < m_mesh->m_element[2].size(); i++)
70  {
71  ASSERTL0(m_mesh->m_element[2][i]->GetConf().m_e ==
73  "quad found in surface mesh with no prism mapping");
74 
75  vector<NodeSharedPtr> n = m_mesh->m_element[2][i]->GetVertexList();
76  Array<OneD, int> tri(3);
77  for (int j = 0; j < n.size(); j++)
78  {
80  it = NodeIdToTetgenId.find(n[j]->m_id);
81  if (it == NodeIdToTetgenId.end())
82  {
83  tri[j] = cnt;
84  NodeIdToTetgenId[n[j]->m_id] = cnt;
85  TetgenIdToNode[cnt] = n[j];
86  TetgenIdToDelta[cnt] = m_octree->Query(n[j]->GetLoc());
87  cnt++;
88  }
89  else
90  {
91  tri[j] = it->second;
92  }
93  }
94  surfacetris.push_back(tri);
95  }
96  }
97  else
98  {
99  m_surftopriface = m_blmesh->GetSurfToPri();
100  // surface triangles will need to be checked against surftopriface to
101  // get the right face
102  // all surface elements are sequentially numbered so this should be easy
103  // to find in map
104  for (int i = 0; i < m_mesh->m_element[2].size(); i++)
105  {
106  if (m_mesh->m_element[2][i]->GetConf().m_e !=
108  continue; // no quads for tetgen
109 
111  fit = m_surftopriface.find(m_mesh->m_element[2][i]->GetId());
112  if (fit == m_surftopriface.end())
113  {
114  // surface element does not have a correspoding prism, build
115  // tetgen surface
116  // tri from surface element
117  vector<NodeSharedPtr> n =
118  m_mesh->m_element[2][i]->GetVertexList();
119  Array<OneD, int> tri(3);
120  for (int j = 0; j < n.size(); j++)
121  {
123  it = NodeIdToTetgenId.find(n[j]->m_id);
124  if (it == NodeIdToTetgenId.end())
125  {
126  tri[j] = cnt;
127  NodeIdToTetgenId[n[j]->m_id] = cnt;
128  TetgenIdToNode[cnt] = n[j];
129  TetgenIdToDelta[cnt] = m_octree->Query(n[j]->GetLoc());
130  cnt++;
131  }
132  else
133  {
134  tri[j] = it->second;
135  }
136  }
137  surfacetris.push_back(tri);
138  }
139  else
140  {
141  // surface element has a prism on it, build tetgen surface
142  // element from the face
143  vector<NodeSharedPtr> n = fit->second->m_vertexList;
144  Array<OneD, int> tri(3);
145  for (int j = 0; j < n.size(); j++)
146  {
148  it = NodeIdToTetgenId.find(n[j]->m_id);
149  if (it == NodeIdToTetgenId.end())
150  {
151  tri[j] = cnt;
152  NodeIdToTetgenId[n[j]->m_id] = cnt;
153  TetgenIdToNode[cnt] = n[j];
154  TetgenIdToDelta[cnt] = m_octree->Query(n[j]->GetLoc());
155  cnt++;
156  }
157  else
158  {
159  tri[j] = it->second;
160  }
161  }
162  surfacetris.push_back(tri);
163  }
164  }
165  }
166 
167  if (m_mesh->m_verbose)
168  {
169  cout << "\tInital Node Count: " << TetgenIdToNode.size() << endl;
170  }
171 
172  tetgen->InitialMesh(TetgenIdToNode, surfacetris);
173 
174  vector<Array<OneD, NekDouble> > newp;
175  int ctbefore = TetgenIdToNode.size();
176  int newpb;
177 
178  do
179  {
180  newpb = newp.size();
181  newp.clear();
182  tetgen->GetNewPoints(ctbefore, newp);
183  for (int i = 0; i < newp.size(); i++)
184  {
185  NekDouble d = m_octree->Query(newp[i]);
186  TetgenIdToDelta[ctbefore + i] = d;
187  }
188  tetgen->RefineMesh(TetgenIdToDelta);
189  } while (newpb != newp.size());
190 
191  // make new map of all nodes to build tets.
192 
193  tetgen->GetNewPoints(ctbefore, newp);
194  for (int i = 0; i < newp.size(); i++)
195  {
196  NodeSharedPtr n = boost::shared_ptr<Node>(
197  new Node(m_mesh->m_numNodes++, newp[i][0], newp[i][1], newp[i][2]));
198  TetgenIdToNode[ctbefore + i] = n;
199  }
200 
201  m_tetconnect = tetgen->Extract();
202 
203  // tetgen->freetet();
204 
205  // create tets
206  for (int i = 0; i < m_tetconnect.size(); i++)
207  {
208  vector<NodeSharedPtr> n;
209  n.push_back(TetgenIdToNode[m_tetconnect[i][0]]);
210  n.push_back(TetgenIdToNode[m_tetconnect[i][1]]);
211  n.push_back(TetgenIdToNode[m_tetconnect[i][2]]);
212  n.push_back(TetgenIdToNode[m_tetconnect[i][3]]);
213  ElmtConfig conf(LibUtilities::eTetrahedron, 1, false, false);
214  vector<int> tags;
215  tags.push_back(0);
217  LibUtilities::eTetrahedron, conf, n, tags);
218 
219  m_mesh->m_element[3].push_back(E);
220  }
221 
222  if (m_mesh->m_verbose)
223  cout << "\tTets :" << m_tetconnect.size() << endl;
224 }
std::vector< Array< OneD, int > > m_tetconnect
conncetivity of the tets from the interface
Definition: TetMesh.h:98
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
OctreeSharedPtr m_octree
octree object
Definition: TetMesh.h:90
BLMeshSharedPtr m_blmesh
bl mesh
Definition: TetMesh.h:92
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
boost::shared_ptr< TetGenInterface > TetGenInterfaceSharedPtr
std::map< int, FaceSharedPtr > m_surftopriface
Definition: TetMesh.h:100
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
double NekDouble
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:52

Friends And Related Function Documentation

friend class MemoryManager< TetMesh >
friend

Definition at line 61 of file TetMesh.h.

Member Data Documentation

BLMeshSharedPtr Nektar::NekMeshUtils::TetMesh::m_blmesh
private

bl mesh

Definition at line 92 of file TetMesh.h.

MeshSharedPtr Nektar::NekMeshUtils::TetMesh::m_mesh
private

Definition at line 88 of file TetMesh.h.

int Nektar::NekMeshUtils::TetMesh::m_numtet
private

number of tetrahedra

Definition at line 96 of file TetMesh.h.

OctreeSharedPtr Nektar::NekMeshUtils::TetMesh::m_octree
private

octree object

Definition at line 90 of file TetMesh.h.

bool Nektar::NekMeshUtils::TetMesh::m_pseudosurface
private

Definition at line 94 of file TetMesh.h.

Referenced by TetMesh().

std::map<int, FaceSharedPtr> Nektar::NekMeshUtils::TetMesh::m_surftopriface
private

Definition at line 100 of file TetMesh.h.

std::vector<Array<OneD, int> > Nektar::NekMeshUtils::TetMesh::m_tetconnect
private

conncetivity of the tets from the interface

Definition at line 98 of file TetMesh.h.