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::TetGenInterface Class Reference

Class for interacting with the external library TetGen. More...

#include <TetGenInterface.h>

Public Member Functions

 TetGenInterface ()
 Default constructor. More...
 
void InitialMesh (std::map< int, NodeSharedPtr > tgidton, std::vector< Array< OneD, int > > tri)
 Assign parameters for meshing. More...
 
void GetNewPoints (int num, std::vector< Array< OneD, NekDouble > > &newp)
 Gets the locations of the Stiener points added by TetGen. More...
 
void RefineMesh (std::map< int, NekDouble > delta)
 Refines a previously made tetmesh with node delta information from the Octree. More...
 
std::vector< Array< OneD, int > > Extract ()
 Get the list of connectivites of the nodes. More...
 
void freetet ()
 Clear previous mesh. More...
 

Private Attributes

tetgenio surface
 TetGen objects. More...
 
tetgenio output
 
tetgenio input
 
tetgenio additional
 

Friends

class MemoryManager< TetGenInterface >
 

Detailed Description

Class for interacting with the external library TetGen.

Definition at line 57 of file TetGenInterface.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::TetGenInterface::TetGenInterface ( )
inline

Default constructor.

Definition at line 65 of file TetGenInterface.h.

65 {};

Member Function Documentation

vector< Array< OneD, int > > Nektar::NekMeshUtils::TetGenInterface::Extract ( )

Get the list of connectivites of the nodes.

Definition at line 124 of file TetGenInterface.cpp.

125 {
126  vector<Array<OneD, int> > tets;
127  for (int i = 0; i < output.numberoftetrahedra; i++)
128  {
129  Array<OneD, int> tet(4);
130  tet[0] = output.tetrahedronlist[i * 4 + 0];
131  tet[1] = output.tetrahedronlist[i * 4 + 1];
132  tet[2] = output.tetrahedronlist[i * 4 + 2];
133  tet[3] = output.tetrahedronlist[i * 4 + 3];
134  tets.push_back(tet);
135  }
136  return tets;
137 }
void Nektar::NekMeshUtils::TetGenInterface::freetet ( )

Clear previous mesh.

Definition at line 139 of file TetGenInterface.cpp.

140 {
141  surface.deinitialize();
142  input.deinitialize();
143  output.deinitialize();
144 }
tetgenio surface
TetGen objects.
void Nektar::NekMeshUtils::TetGenInterface::GetNewPoints ( int  num,
std::vector< Array< OneD, NekDouble > > &  newp 
)

Gets the locations of the Stiener points added by TetGen.

Definition at line 95 of file TetGenInterface.cpp.

97 {
98  for (int i = num; i < output.numberofpoints; i++)
99  {
100  Array<OneD, NekDouble> loc(3);
101  loc[0] = output.pointlist[i * 3 + 0];
102  loc[1] = output.pointlist[i * 3 + 1];
103  loc[2] = output.pointlist[i * 3 + 2];
104  newp.push_back(loc);
105  }
106 }
void Nektar::NekMeshUtils::TetGenInterface::InitialMesh ( std::map< int, NodeSharedPtr tgidton,
std::vector< Array< OneD, int > >  tri 
)

Assign parameters for meshing.

Definition at line 48 of file TetGenInterface.cpp.

References Nektar::iterator, and REAL.

50 {
51  surface.initialize();
52  output.initialize();
53 
54  // build surface input
55  tetgenio::facet *f;
56  tetgenio::polygon *p;
57 
58  surface.firstnumber = 0;
59  surface.numberofpoints = tgidton.size();
60  surface.pointlist = new REAL[surface.numberofpoints * 3];
61 
63  for (it = tgidton.begin(); it != tgidton.end(); it++)
64  {
65  Array<OneD, NekDouble> loc = it->second->GetLoc();
66 
67  surface.pointlist[it->first * 3 + 0] = loc[0];
68  surface.pointlist[it->first * 3 + 1] = loc[1];
69  surface.pointlist[it->first * 3 + 2] = loc[2];
70  }
71 
72  surface.numberoffacets = tri.size();
73  surface.facetlist = new tetgenio::facet[surface.numberoffacets];
74  surface.facetmarkerlist = new int[surface.numberoffacets];
75 
76  for (int i = 0; i < tri.size(); i++)
77  {
78  f = &surface.facetlist[i];
79  f->numberofpolygons = 1;
80  f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
81  f->numberofholes = 0;
82  f->holelist = NULL;
83  p = &f->polygonlist[0];
84  p->numberofvertices = 3;
85  p->vertexlist = new int[p->numberofvertices];
86  p->vertexlist[0] = tri[i][0];
87  p->vertexlist[1] = tri[i][1];
88  p->vertexlist[2] = tri[i][2];
89  surface.facetmarkerlist[i] = 0;
90  }
91 
92  tetrahedralize("pYzqQ", &surface, &output);
93 }
tetgenio surface
TetGen objects.
#define REAL
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void Nektar::NekMeshUtils::TetGenInterface::RefineMesh ( std::map< int, NekDouble delta)

Refines a previously made tetmesh with node delta information from the Octree.

Definition at line 108 of file TetGenInterface.cpp.

References REAL.

109 {
110  input = output;
111 
112  input.numberofpointmtrs = 1;
113 
114  input.pointmtrlist = new REAL[input.numberofpoints];
115 
116  for (int i = 0; i < input.numberofpoints; i++)
117  {
118  input.pointmtrlist[i] = delta[i];
119  }
120 
121  tetrahedralize("pYrmzqQO2/7o/120", &input, &output);
122 }
#define REAL

Friends And Related Function Documentation

friend class MemoryManager< TetGenInterface >
friend

Definition at line 60 of file TetGenInterface.h.

Member Data Documentation

tetgenio Nektar::NekMeshUtils::TetGenInterface::additional
private

Definition at line 96 of file TetGenInterface.h.

tetgenio Nektar::NekMeshUtils::TetGenInterface::input
private

Definition at line 96 of file TetGenInterface.h.

tetgenio Nektar::NekMeshUtils::TetGenInterface::output
private

Definition at line 96 of file TetGenInterface.h.

tetgenio Nektar::NekMeshUtils::TetGenInterface::surface
private

TetGen objects.

Definition at line 96 of file TetGenInterface.h.