Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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, int id, std::vector< ElementSharedPtr > e=std::vector< ElementSharedPtr >())
 default constructor More...
 
void Mesh ()
 execute tet meshing More...
 

Private Attributes

MeshSharedPtr m_mesh
 
std::vector< ElementSharedPtrm_surface
 
int m_numtet
 number of tetrahedra More...
 
int m_id
 
std::vector< Array< OneD, int > > m_tetconnect
 conncetivity of the tets from the interface More...
 
TetGenInterfaceSharedPtr tetgen
 

Friends

class MemoryManager< TetMesh >
 

Detailed Description

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

Definition at line 56 of file TetMesh.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::TetMesh::TetMesh ( MeshSharedPtr  m,
int  id,
std::vector< ElementSharedPtr e = std::vector<ElementSharedPtr>() 
)
inline

default constructor

Definition at line 64 of file TetMesh.h.

66  : m_mesh(m), m_surface(e), m_id(id)
67  {
68  };
std::vector< ElementSharedPtr > m_surface
Definition: TetMesh.h:78

Member Function Documentation

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

execute tet meshing

Definition at line 45 of file TetMesh.cpp.

References Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::eTetrahedron, Nektar::NekMeshUtils::GetElementFactory(), and class_topology::Node.

46 {
47  if (m_mesh->m_verbose)
48  cout << endl << endl << "Tetrahdral mesh generation" << endl;
49 
51 
52  map<int, NodeSharedPtr> IdToNode;
53  map<NodeSharedPtr, int> IdToNodeRev;
54 
55  // build sequentially ordered maps of nodes that exist and there delta value
56  // in the octree
57  map<int, NekDouble> IdToDelta;
58  vector<Array<OneD, int> > surfacetris;
59  NodeSet alreadyInSurface;
60 
61  if(m_surface.size() == 0)
62  {
63  m_surface = m_mesh->m_element[2];
64  }
65 
66  int cnt = 0;
67  for(int i = 0; i < m_surface.size(); i++)
68  {
69  vector<NodeSharedPtr> n = m_surface[i]->GetVertexList();
70  Array<OneD, int> tri(3);
71  for(int j = 0; j < n.size(); j++)
72  {
73  pair<NodeSet::iterator,bool> testIns =
74  alreadyInSurface.insert(n[j]);
75 
76  if (testIns.second)
77  {
78  if(cnt == 2114)
79  {
80  //cout << n[j]->m_x << " " << n[j]->m_y << " " << n[j]->m_z << endl;
81  }
82  tri[j] = cnt;
83  IdToNode[cnt] = n[j];
84  IdToNodeRev[n[j]] = cnt;
85  IdToDelta[cnt] = m_mesh->m_octree->Query(n[j]->GetLoc());
86  cnt++;
87  }
88  else
89  {
90  tri[j] = IdToNodeRev[(*testIns.first)];
91  }
92  }
93  surfacetris.push_back(tri);
94  }
95 
96  //m_mesh->m_expDim--;
97  //m_mesh->m_element[3].clear();
98  //m_mesh->m_element[2] = m_surface;
99  //return;
100 
101  if (m_mesh->m_verbose)
102  {
103  cout << "\tInital Node Count: " << IdToNode.size() << endl;
104  }
105 
106  tetgen->InitialMesh(IdToNode, surfacetris);
107 
108  vector<Array<OneD, NekDouble> > newp;
109  int ctbefore = IdToNode.size();
110  int newpb;
111  do
112  {
113  newpb = newp.size();
114  newp.clear();
115  tetgen->GetNewPoints(ctbefore, newp);
116  for (int i = 0; i < newp.size(); i++)
117  {
118  NekDouble d = m_mesh->m_octree->Query(newp[i]);
119  IdToDelta[ctbefore + i] = d;
120  }
121  tetgen->RefineMesh(IdToDelta);
122  } while (newpb != newp.size());
123 
124  // make new map of all nodes to build tets.
125  newp.clear();
126  tetgen->GetNewPoints(ctbefore, newp);
127  for (int i = 0; i < newp.size(); i++)
128  {
129  NodeSharedPtr n = boost::shared_ptr<Node>(
130  new Node(ctbefore + i, newp[i][0], newp[i][1], newp[i][2]));
131  IdToNode[ctbefore + i] = n;
132  }
133 
134  m_tetconnect = tetgen->Extract();
135 
136  // tetgen->freetet();
137 
138  // create tets
139  for (int i = 0; i < m_tetconnect.size(); i++)
140  {
141  vector<NodeSharedPtr> n;
142  n.push_back(IdToNode[m_tetconnect[i][0]]);
143  n.push_back(IdToNode[m_tetconnect[i][1]]);
144  n.push_back(IdToNode[m_tetconnect[i][2]]);
145  n.push_back(IdToNode[m_tetconnect[i][3]]);
146  ElmtConfig conf(LibUtilities::eTetrahedron, 1, false, false);
147  vector<int> tags;
148  tags.push_back(m_id);
150  LibUtilities::eTetrahedron, conf, n, tags);
151 
152  m_mesh->m_element[3].push_back(E);
153  }
154 
155  if (m_mesh->m_verbose)
156  cout << "\tTets :" << m_tetconnect.size() << endl;
157 }
std::vector< Array< OneD, int > > m_tetconnect
conncetivity of the tets from the interface
Definition: TetMesh.h:83
TetGenInterfaceSharedPtr tetgen
Definition: TetMesh.h:85
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.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
boost::unordered_set< NodeSharedPtr, NodeHash > NodeSet
Definition: Node.h:441
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
double NekDouble
std::vector< ElementSharedPtr > m_surface
Definition: TetMesh.h:78
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49

Friends And Related Function Documentation

friend class MemoryManager< TetMesh >
friend

Definition at line 59 of file TetMesh.h.

Member Data Documentation

int Nektar::NekMeshUtils::TetMesh::m_id
private

Definition at line 81 of file TetMesh.h.

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

Definition at line 77 of file TetMesh.h.

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

number of tetrahedra

Definition at line 80 of file TetMesh.h.

std::vector<ElementSharedPtr> Nektar::NekMeshUtils::TetMesh::m_surface
private

Definition at line 78 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 83 of file TetMesh.h.

TetGenInterfaceSharedPtr Nektar::NekMeshUtils::TetMesh::tetgen
private

Definition at line 85 of file TetMesh.h.