44 namespace NekMeshUtils
47 void TetGenInterface::InitialMesh(map<int, NodeSharedPtr> tgidton,
57 surface.firstnumber = 0;
58 surface.numberofpoints = tgidton.size();
59 surface.pointlist =
new REAL[surface.numberofpoints * 3];
61 map<int, NodeSharedPtr>::iterator it;
62 for (it = tgidton.begin(); it != tgidton.end(); it++)
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];
71 surface.numberoffacets = tri.size();
72 surface.facetlist =
new tetgenio::facet[surface.numberoffacets];
73 surface.facetmarkerlist =
new int[surface.numberoffacets];
75 for (
int i = 0; i < tri.size(); i++)
77 f = &surface.facetlist[i];
78 f->numberofpolygons = 1;
79 f->polygonlist =
new tetgenio::polygon[f->numberofpolygons];
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;
92 char *cstr =
new char[cmd.length() + 1];
93 strcpy(cstr, cmd.c_str());
95 tetrahedralize(cstr, &surface, &output);
98 void TetGenInterface::GetNewPoints(
int num,
101 for (
int i = num; i < output.numberofpoints; i++)
104 loc[0] = output.pointlist[i * 3 + 0];
105 loc[1] = output.pointlist[i * 3 + 1];
106 loc[2] = output.pointlist[i * 3 + 2];
111 void TetGenInterface::RefineMesh(std::map<int, NekDouble> delta)
115 input.numberofpointmtrs = 1;
117 input.pointmtrlist =
new REAL[input.numberofpoints];
119 for (
int i = 0; i < input.numberofpoints; i++)
121 input.pointmtrlist[i] = delta[i];
124 string cmd =
"pYrmzq1.1/0QO2/7";
125 char *cstr =
new char[cmd.length() + 1];
126 strcpy(cstr, cmd.c_str());
128 tetrahedralize(cstr, &input, &output);
131 vector<Array<OneD, int> > TetGenInterface::Extract()
133 vector<Array<OneD, int> > tets;
134 for (
int i = 0; i < output.numberoftetrahedra; i++)
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];
147 void TetGenInterface::freetet()
149 surface.deinitialize();
150 input.deinitialize();
151 output.deinitialize();