Nektar++
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

◆ TetGenInterface()

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

Default constructor.

Definition at line 65 of file TetGenInterface.h.

References Extract(), freetet(), GetNewPoints(), InitialMesh(), and RefineMesh().

65 {};

Member Function Documentation

◆ Extract()

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

Get the list of connectivites of the nodes.

Definition at line 131 of file TetGenInterface.cpp.

Referenced by TetGenInterface().

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

◆ freetet()

void Nektar::NekMeshUtils::TetGenInterface::freetet ( )

Clear previous mesh.

Definition at line 147 of file TetGenInterface.cpp.

Referenced by TetGenInterface().

148 {
149  surface.deinitialize();
150  input.deinitialize();
151  output.deinitialize();
152 }
tetgenio surface
TetGen objects.

◆ GetNewPoints()

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 98 of file TetGenInterface.cpp.

References CG_Iterations::loc.

Referenced by TetGenInterface().

100 {
101  for (int i = num; i < output.numberofpoints; i++)
102  {
103  Array<OneD, NekDouble> loc(3);
104  loc[0] = output.pointlist[i * 3 + 0];
105  loc[1] = output.pointlist[i * 3 + 1];
106  loc[2] = output.pointlist[i * 3 + 2];
107  newp.push_back(loc);
108  }
109 }

◆ InitialMesh()

void Nektar::NekMeshUtils::TetGenInterface::InitialMesh ( std::map< int, NodeSharedPtr tgidton,
std::vector< Array< OneD, int > >  tri 
)

Assign parameters for meshing.

Definition at line 47 of file TetGenInterface.cpp.

References CG_Iterations::loc, CellMLToNektar.cellml_metadata::p, and REAL.

Referenced by TetGenInterface().

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

◆ RefineMesh()

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 111 of file TetGenInterface.cpp.

References REAL.

Referenced by TetGenInterface().

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

Friends And Related Function Documentation

◆ MemoryManager< TetGenInterface >

friend class MemoryManager< TetGenInterface >
friend

Definition at line 60 of file TetGenInterface.h.

Member Data Documentation

◆ additional

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

Definition at line 96 of file TetGenInterface.h.

◆ input

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

Definition at line 96 of file TetGenInterface.h.

◆ output

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

Definition at line 96 of file TetGenInterface.h.

◆ surface

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

TetGen objects.

Definition at line 96 of file TetGenInterface.h.