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::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 58 of file TetGenInterface.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 66 of file TetGenInterface.h.

66 {};

Member Function Documentation

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

Get the list of connectivites of the nodes.

Definition at line 132 of file TetGenInterface.cpp.

133 {
134  vector<Array<OneD, int> > tets;
135  for (int i = 0; i < output.numberoftetrahedra; i++)
136  {
137  Array<OneD, int> tet(4);
138  tet[0] = output.tetrahedronlist[i * 4 + 0];
139  tet[1] = output.tetrahedronlist[i * 4 + 1];
140  tet[2] = output.tetrahedronlist[i * 4 + 2];
141  tet[3] = output.tetrahedronlist[i * 4 + 3];
142  tets.push_back(tet);
143  }
144 
145  return tets;
146 }
void Nektar::NekMeshUtils::TetGenInterface::freetet ( )

Clear previous mesh.

Definition at line 148 of file TetGenInterface.cpp.

149 {
150  surface.deinitialize();
151  input.deinitialize();
152  output.deinitialize();
153 }
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 99 of file TetGenInterface.cpp.

101 {
102  for (int i = num; i < output.numberofpoints; i++)
103  {
104  Array<OneD, NekDouble> loc(3);
105  loc[0] = output.pointlist[i * 3 + 0];
106  loc[1] = output.pointlist[i * 3 + 1];
107  loc[2] = output.pointlist[i * 3 + 2];
108  newp.push_back(loc);
109  }
110 }
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 CellMLToNektar.cellml_metadata::p.

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  string cmd = "pYzqQ";
93  char *cstr = new char[cmd.length() + 1];
94  strcpy(cstr, cmd.c_str());
95 
96  tetrahedralize(cstr, &surface, &output);
97 }
tetgenio surface
TetGen objects.
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 112 of file TetGenInterface.cpp.

113 {
114  input = output;
115 
116  input.numberofpointmtrs = 1;
117 
118  input.pointmtrlist = new REAL[input.numberofpoints];
119 
120  for (int i = 0; i < input.numberofpoints; i++)
121  {
122  input.pointmtrlist[i] = delta[i];
123  }
124 
125  string cmd = "pYrmzq1.1/0QO2/7";
126  char *cstr = new char[cmd.length() + 1];
127  strcpy(cstr, cmd.c_str());
128 
129  tetrahedralize(cstr, &input, &output);
130 }

Friends And Related Function Documentation

friend class MemoryManager< TetGenInterface >
friend

Definition at line 61 of file TetGenInterface.h.

Member Data Documentation

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

Definition at line 97 of file TetGenInterface.h.

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

Definition at line 97 of file TetGenInterface.h.

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

Definition at line 97 of file TetGenInterface.h.

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

TetGen objects.

Definition at line 97 of file TetGenInterface.h.