44int main(
int argc,
char *argv[])
51 std::cerr <<
"Usage: CheckXmlFile meshfile.xml" << std::endl;
60 std::string meshfile(argv[argc - 1]);
67 int expdim = mesh->GetMeshDimension();
79 int cnt = 0, nverts = mesh->GetNvertices();
81 std::map<int, int> vid2cnt;
83 for (
auto [
id, vert] :
87 vert->GetCoords(xc[cnt], yc[cnt], zc[cnt]);
88 vid2cnt[vert->GetGlobalID()] = cnt++;
92 for (
int i = 0; i < nverts; ++i)
94 for (
int j = i + 1; j < nverts; ++j)
96 if ((xc[i] - xc[j]) * (xc[i] - xc[j]) +
97 (yc[i] - yc[j]) * (yc[i] - yc[j]) +
98 (zc[i] - zc[j]) * (zc[i] - zc[j]) <
101 std::cerr <<
"ERROR: Duplicate vertices: " << i <<
" "
107 bool NoRotateIssues =
true;
108 bool NoOrientationIssues =
true;
112 NoOrientationIssues =
116 if (tet->GetFace(0)->GetVid(2) != tet->GetVid(2))
118 std::cerr <<
"ERROR: Face " << tet->GetFid(0) <<
" (vert "
119 << tet->GetFace(0)->GetVid(2)
120 <<
") is not aligned with base vertex of Tet "
121 << tet->GetGlobalID() <<
" (vert "
122 << tet->GetVid(2) <<
")" << std::endl;
123 NoRotateIssues =
false;
126 for (
int i = 1; i < 4; ++i)
128 if (tet->GetFace(i)->GetVid(2) != tet->GetVid(3))
130 std::cerr <<
"ERROR: Face " << tet->GetFid(i)
131 <<
" is not aligned with top Vertex of Tet "
132 << tet->GetGlobalID() << std::endl;
133 NoRotateIssues =
false;
137 if (NoOrientationIssues)
139 std::cout <<
"All Tet have correct ordering for anticlockwise "
146 std::cout <<
"All Tet faces are correctly aligned" << std::endl;
149 for ([[maybe_unused]]
auto [
id, pyr] :
155 NoRotateIssues =
true;
156 NoOrientationIssues =
true;
160 if (pri->GetFace(1)->GetVid(2) != pri->GetVid(4))
163 <<
"ERROR: Face " << pri->GetFid(1) <<
" (vert "
164 << pri->GetFace(1)->GetVid(2)
165 <<
") not aligned to face 1 singular vert of Prism "
166 << pri->GetGlobalID() <<
" (vert " << pri->GetVid(4)
168 NoRotateIssues =
false;
172 if (pri->GetFace(3)->GetVid(2) != pri->GetVid(5))
175 <<
"ERROR: Face " << pri->GetFid(3) <<
" (vert "
176 << pri->GetFace(3)->GetVid(2)
177 <<
") not aligned to face 3 singular vert of Prism "
178 << pri->GetGlobalID() <<
" (vert " << pri->GetVid(5)
180 NoRotateIssues =
false;
186 std::cout <<
"All Prism Tri faces are correctly aligned"
190 for ([[maybe_unused]]
auto [
id, hex] :
199 ASSERTL0(
false,
"Expansion dimension not recognised");
218 std::map<int, int> &vid2cnt)
220 bool RotationOK =
true;
221 std::array<Ord, 4> v;
224 v[0].x = xc[vid2cnt[tet->
GetVid(0)]];
225 v[0].y = yc[vid2cnt[tet->
GetVid(0)]];
226 v[0].z = zc[vid2cnt[tet->
GetVid(0)]];
228 v[1].x = xc[vid2cnt[tet->
GetVid(1)]];
229 v[1].y = yc[vid2cnt[tet->
GetVid(1)]];
230 v[1].z = zc[vid2cnt[tet->
GetVid(1)]];
232 v[2].x = xc[vid2cnt[tet->
GetVid(2)]];
233 v[2].y = yc[vid2cnt[tet->
GetVid(2)]];
234 v[2].z = zc[vid2cnt[tet->
GetVid(2)]];
236 v[3].x = xc[vid2cnt[tet->
GetVid(3)]];
237 v[3].y = yc[vid2cnt[tet->
GetVid(3)]];
238 v[3].z = zc[vid2cnt[tet->
GetVid(3)]];
241 abx = (v[1].y - v[0].y) * (v[2].z - v[0].z) -
242 (v[1].z - v[0].z) * (v[2].y - v[0].y);
243 aby = (v[1].z - v[0].z) * (v[2].x - v[0].x) -
244 (v[1].x - v[0].x) * (v[2].z - v[0].z);
245 abz = (v[1].x - v[0].x) * (v[2].y - v[0].y) -
246 (v[1].y - v[0].y) * (v[2].x - v[0].x);
249 if (((v[3].x - v[0].x) * abx + (v[3].y - v[0].y) * aby +
250 (v[3].z - v[0].z) * abz) < 0.0)
252 std::cerr <<
"ERROR: Element " << tet->
GetGlobalID()
253 <<
"is NOT counter-clockwise\n"
bool CheckTetRotation(Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, Array< OneD, NekDouble > &xz, SpatialDomains::TetGeom *tet, std::map< int, int > &vid2cnt)
int GetVid(int i) const
Returns global id of vertex i of this object.
int GetGlobalID(void) const
Get the ID of this object.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr