47 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator &tetIter,
int id);
49int main(
int argc,
char *argv[])
56 fprintf(stderr,
"Usage: CheckXmlFile meshfile.xml\n");
61 LibUtilities::SessionReader::CreateInstance(argc, argv);
65 string meshfile(argv[argc - 1]);
67 SpatialDomains::MeshGraphIO::Read(vSession);
72 int expdim = mesh->GetMeshDimension();
82 string outname(strtok(argv[argc - 1],
"."));
84 FILE *fp = fopen(outname.c_str(),
"w");
89 int nverts = mesh->GetNvertices();
93 for (
int i = 0; i < nverts; ++i)
95 mesh->GetVertex(i)->GetCoords(x, y,
z);
101 std::map<int, SpatialDomains::TriGeomSharedPtr>::iterator triIter;
102 for (triIter = trigeom.begin(); triIter != trigeom.end(); ++triIter)
104 fprintf(fp,
"%d %d %d %d\n", (triIter->second)->GetVid(0) + 1,
105 (triIter->second)->GetVid(1) + 1,
106 (triIter->second)->GetVid(2) + 1,
107 (triIter->second)->GetVid(2) + 1);
110 std::map<int, SpatialDomains::QuadGeomSharedPtr>::iterator quadIter;
111 for (quadIter = quadgeom.begin(); quadIter != quadgeom.end();
114 fprintf(fp,
"%d %d %d %d\n", (quadIter->second)->GetVid(0) + 1,
115 (quadIter->second)->GetVid(1) + 1,
116 (quadIter->second)->GetVid(2) + 1,
117 (quadIter->second)->GetVid(3) + 1);
124 string outname(strtok(argv[argc - 1],
"."));
132 int nverts = mesh->GetNvertices();
136 for (
int i = 0; i < nverts; ++i)
139 mesh->GetVertex(i)->GetCoords(x, y,
z);
145 for (
int i = 0; i < nverts; ++i)
147 for (
int j = i + 1; j < nverts; ++j)
149 if ((xc[i] - xc[j]) * (xc[i] - xc[j]) +
150 (yc[i] - yc[j]) * (yc[i] - yc[j]) +
151 (zc[i] - zc[j]) * (zc[i] - zc[j]) <
154 cout <<
"Duplicate vertices: " << i <<
" " << j << endl;
159 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator tetIter;
161 bool NoRotateIssues =
true;
162 bool NoOrientationIssues =
true;
163 for (tetIter = tetgeom.begin(); tetIter != tetgeom.end(); ++tetIter)
166 NoOrientationIssues =
170 if ((tetIter->second)->GetFace(0)->GetVid(2) !=
171 (tetIter->second)->GetVid(2))
173 cout <<
"ERROR: Face " << tetIter->second->GetFid(0)
175 << (tetIter->second)->GetFace(0)->GetVid(2)
176 <<
") is not aligned with base vertex of Tet "
177 << (tetIter->second)->GetGlobalID() <<
" (vert "
178 << (tetIter->second)->GetVid(2) <<
")" << endl;
179 NoRotateIssues =
false;
182 for (
int i = 1; i < 4; ++i)
185 if ((tetIter->second)->GetFace(i)->GetVid(2) !=
186 (tetIter->second)->GetVid(3))
188 cout <<
"ERROR: Face " << tetIter->second->GetFid(i)
189 <<
" is not aligned with top Vertex of Tet "
190 << (tetIter->second)->GetGlobalID() << endl;
191 NoRotateIssues =
false;
195 if (NoOrientationIssues)
197 cout <<
"All Tet have correct ordering for anticlockwise "
204 cout <<
"All Tet faces are correctly aligned" << endl;
207 std::map<int, SpatialDomains::PyrGeomSharedPtr>::iterator pyrIter;
208 for (pyrIter = pyrgeom.begin(); pyrIter != pyrgeom.end(); ++pyrIter)
214 std::map<int, SpatialDomains::PrismGeomSharedPtr>::iterator Iter;
215 NoRotateIssues =
true;
216 NoOrientationIssues =
true;
217 for (Iter = prismgeom.begin(); Iter != prismgeom.end(); ++Iter)
221 if ((Iter->second)->GetFace(1)->GetVid(2) !=
222 (Iter->second)->GetVid(4))
224 cout <<
"ERROR: Face " << Iter->second->GetFid(1)
225 <<
" (vert " << (Iter->second)->GetFace(1)->GetVid(2)
226 <<
") not aligned to face 1 singular vert of Prism "
227 << (Iter->second)->GetGlobalID() <<
" (vert "
228 << (Iter->second)->GetVid(4) <<
")" << endl;
229 NoRotateIssues =
false;
233 if ((Iter->second)->GetFace(3)->GetVid(2) !=
234 (Iter->second)->GetVid(5))
236 cout <<
"ERROR: Face " << Iter->second->GetFid(3)
237 <<
" (vert " << (Iter->second)->GetFace(3)->GetVid(2)
238 <<
") not aligned to face 3 singular vert of Prism "
239 << (Iter->second)->GetGlobalID() <<
" (vert "
240 << (Iter->second)->GetVid(5) <<
")" << endl;
241 NoRotateIssues =
false;
247 cout <<
"All Prism Tri faces are correctly aligned" << endl;
250 std::map<int, SpatialDomains::HexGeomSharedPtr>::iterator hexIter;
251 for (hexIter = hexgeom.begin(); hexIter != hexgeom.end(); ++hexIter)
259 ASSERTL0(
false,
"Expansion dimension not recognised");
279 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator &tetIter,
int id)
281 bool RotationOK =
true;
285 v[0].
x = xc[(tetIter->second)->GetVid(0)];
286 v[0].
y = yc[(tetIter->second)->GetVid(0)];
287 v[0].
z = zc[(tetIter->second)->GetVid(0)];
289 v[1].
x = xc[(tetIter->second)->GetVid(1)];
290 v[1].
y = yc[(tetIter->second)->GetVid(1)];
291 v[1].
z = zc[(tetIter->second)->GetVid(1)];
293 v[2].
x = xc[(tetIter->second)->GetVid(2)];
294 v[2].
y = yc[(tetIter->second)->GetVid(2)];
295 v[2].
z = zc[(tetIter->second)->GetVid(2)];
297 v[3].
x = xc[(tetIter->second)->GetVid(3)];
298 v[3].
y = yc[(tetIter->second)->GetVid(3)];
299 v[3].
z = zc[(tetIter->second)->GetVid(3)];
302 abx = (v[1].
y - v[0].
y) * (v[2].
z - v[0].
z) -
303 (v[1].
z - v[0].
z) * (v[2].y - v[0].y);
304 aby = (v[1].
z - v[0].
z) * (v[2].x - v[0].x) -
305 (v[1].
x - v[0].
x) * (v[2].
z - v[0].
z);
306 abz = (v[1].
x - v[0].
x) * (v[2].y - v[0].y) -
307 (v[1].
y - v[0].
y) * (v[2].x - v[0].x);
310 if (((v[3].x - v[0].x) * abx + (v[3].
y - v[0].
y) * aby +
311 (v[3].
z - v[0].
z) * abz) < 0.0)
313 cerr <<
"ERROR: Element " <<
id + 1 <<
"is NOT counter-clockwise\n"
int main(int argc, char *argv[])
bool CheckTetRotation(Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, Array< OneD, NekDouble > &xz, std::map< int, SpatialDomains::TetGeomSharedPtr >::iterator &tetIter, int id)
#define ASSERTL0(condition, msg)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::map< int, TriGeomSharedPtr > TriGeomMap
std::map< int, PyrGeomSharedPtr > PyrGeomMap
std::map< int, QuadGeomSharedPtr > QuadGeomMap
std::map< int, TetGeomSharedPtr > TetGeomMap
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::map< int, PrismGeomSharedPtr > PrismGeomMap
std::map< int, HexGeomSharedPtr > HexGeomMap
std::vector< double > z(NPUPPER)