12 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator &tetIter,
int id);
14 int main(
int argc,
char *argv[])
21 fprintf(stderr,
"Usage: CheckXmlFile meshfile.xml\n");
26 LibUtilities::SessionReader::CreateInstance(argc, argv);
30 string meshfile(argv[argc - 1]);
32 SpatialDomains::MeshGraph::Read(vSession);
37 int expdim = mesh->GetMeshDimension();
47 string outname(strtok(argv[argc - 1],
"."));
49 FILE *fp = fopen(outname.c_str(),
"w");
54 int nverts = mesh->GetNvertices();
58 for (
int i = 0; i < nverts; ++i)
60 mesh->GetVertex(i)->GetCoords(x, y, z);
66 std::map<int, SpatialDomains::TriGeomSharedPtr>::iterator triIter;
67 for (triIter = trigeom.begin(); triIter != trigeom.end(); ++triIter)
69 fprintf(fp,
"%d %d %d %d\n", (triIter->second)->GetVid(0) + 1,
70 (triIter->second)->GetVid(1) + 1,
71 (triIter->second)->GetVid(2) + 1,
72 (triIter->second)->GetVid(2) + 1);
75 std::map<int, SpatialDomains::QuadGeomSharedPtr>::iterator quadIter;
76 for (quadIter = quadgeom.begin(); quadIter != quadgeom.end();
79 fprintf(fp,
"%d %d %d %d\n", (quadIter->second)->GetVid(0) + 1,
80 (quadIter->second)->GetVid(1) + 1,
81 (quadIter->second)->GetVid(2) + 1,
82 (quadIter->second)->GetVid(3) + 1);
89 string outname(strtok(argv[argc - 1],
"."));
97 int nverts = mesh->GetNvertices();
101 for (
int i = 0; i < nverts; ++i)
104 mesh->GetVertex(i)->GetCoords(x, y, z);
110 for (
int i = 0; i < nverts; ++i)
112 for (
int j = i + 1; j < nverts; ++j)
114 if ((xc[i] - xc[j]) * (xc[i] - xc[j]) +
115 (yc[i] - yc[j]) * (yc[i] - yc[j]) +
116 (zc[i] - zc[j]) * (zc[i] - zc[j]) <
119 cout <<
"Duplicate vertices: " << i <<
" " << j << endl;
124 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator tetIter;
126 bool NoRotateIssues =
true;
127 bool NoOrientationIssues =
true;
128 for (tetIter = tetgeom.begin(); tetIter != tetgeom.end(); ++tetIter)
131 NoOrientationIssues =
135 if ((tetIter->second)->GetFace(0)->GetVid(2) !=
136 (tetIter->second)->GetVid(2))
138 cout <<
"ERROR: Face " << tetIter->second->GetFid(0)
140 << (tetIter->second)->GetFace(0)->GetVid(2)
141 <<
") is not aligned with base vertex of Tet "
142 << (tetIter->second)->GetGlobalID() <<
" (vert "
143 << (tetIter->second)->GetVid(2) <<
")" << endl;
144 NoRotateIssues =
false;
147 for (
int i = 1; i < 4; ++i)
150 if ((tetIter->second)->GetFace(i)->GetVid(2) !=
151 (tetIter->second)->GetVid(3))
153 cout <<
"ERROR: Face " << tetIter->second->GetFid(i)
154 <<
" is not aligned with top Vertex of Tet "
155 << (tetIter->second)->GetGlobalID() << endl;
156 NoRotateIssues =
false;
160 if (NoOrientationIssues)
162 cout <<
"All Tet have correct ordering for anticlockwise "
169 cout <<
"All Tet faces are correctly aligned" << endl;
172 std::map<int, SpatialDomains::PyrGeomSharedPtr>::iterator pyrIter;
173 for (pyrIter = pyrgeom.begin(); pyrIter != pyrgeom.end(); ++pyrIter)
179 std::map<int, SpatialDomains::PrismGeomSharedPtr>::iterator Iter;
180 NoRotateIssues =
true;
181 NoOrientationIssues =
true;
182 for (Iter = prismgeom.begin(); Iter != prismgeom.end(); ++Iter)
186 if ((Iter->second)->GetFace(1)->GetVid(2) !=
187 (Iter->second)->GetVid(4))
189 cout <<
"ERROR: Face " << Iter->second->GetFid(1)
190 <<
" (vert " << (Iter->second)->GetFace(1)->GetVid(2)
191 <<
") not aligned to face 1 singular vert of Prism "
192 << (Iter->second)->GetGlobalID() <<
" (vert "
193 << (Iter->second)->GetVid(4) <<
")" << endl;
194 NoRotateIssues =
false;
198 if ((Iter->second)->GetFace(3)->GetVid(2) !=
199 (Iter->second)->GetVid(5))
201 cout <<
"ERROR: Face " << Iter->second->GetFid(3)
202 <<
" (vert " << (Iter->second)->GetFace(3)->GetVid(2)
203 <<
") not aligned to face 3 singular vert of Prism "
204 << (Iter->second)->GetGlobalID() <<
" (vert "
205 << (Iter->second)->GetVid(5) <<
")" << endl;
206 NoRotateIssues =
false;
212 cout <<
"All Prism Tri faces are correctly aligned" << endl;
215 std::map<int, SpatialDomains::HexGeomSharedPtr>::iterator hexIter;
216 for (hexIter = hexgeom.begin(); hexIter != hexgeom.end(); ++hexIter)
224 ASSERTL0(
false,
"Expansion dimension not recognised");
244 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator &tetIter,
int id)
246 bool RotationOK =
true;
250 v[0].
x = xc[(tetIter->second)->GetVid(0)];
251 v[0].
y = yc[(tetIter->second)->GetVid(0)];
252 v[0].
z = zc[(tetIter->second)->GetVid(0)];
254 v[1].
x = xc[(tetIter->second)->GetVid(1)];
255 v[1].
y = yc[(tetIter->second)->GetVid(1)];
256 v[1].
z = zc[(tetIter->second)->GetVid(1)];
258 v[2].
x = xc[(tetIter->second)->GetVid(2)];
259 v[2].
y = yc[(tetIter->second)->GetVid(2)];
260 v[2].
z = zc[(tetIter->second)->GetVid(2)];
262 v[3].
x = xc[(tetIter->second)->GetVid(3)];
263 v[3].
y = yc[(tetIter->second)->GetVid(3)];
264 v[3].
z = zc[(tetIter->second)->GetVid(3)];
267 abx = (v[1].
y - v[0].
y) * (v[2].z - v[0].z) -
268 (v[1].
z - v[0].
z) * (v[2].y - v[0].y);
269 aby = (v[1].
z - v[0].
z) * (v[2].x - v[0].x) -
270 (v[1].
x - v[0].
x) * (v[2].z - v[0].z);
271 abz = (v[1].
x - v[0].
x) * (v[2].y - v[0].y) -
272 (v[1].
y - v[0].
y) * (v[2].x - v[0].x);
275 if (((v[3].x - v[0].x) * abx + (v[3].
y - v[0].
y) * aby +
276 (v[3].z - v[0].z) * abz) < 0.0)
278 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
The above copyright notice and this permission notice shall be included.