6 using namespace Nektar;
9 Array<OneD, NekDouble> &xz,
13 int main(
int argc,
char *argv[])
15 Array<OneD,NekDouble> fce;
16 Array<OneD,NekDouble> xc0,xc1,xc2;
20 fprintf(stderr,
"Usage: CheckXmlFile meshfile.xml\n");
29 string meshfile(argv[argc-1]);
35 int expdim = mesh->GetMeshDimension();
45 string outname(strtok(argv[argc-1],
"."));
47 FILE *fp = fopen(outname.c_str(),
"w");
52 int nverts = mesh->GetNvertices();
54 Array<OneD, NekDouble> xc(nverts),yc(nverts),zc(nverts);
56 for(
int i = 0; i < nverts; ++i)
58 mesh->GetVertex(i)->GetCoords(x,y,z);
65 for(triIter = trigeom.begin(); triIter != trigeom.end(); ++triIter)
67 fprintf(fp,
"%d %d %d %d\n",(triIter->second)->GetVid(0)+1,(triIter->second)->GetVid(1)+1,(triIter->second)->GetVid(2)+1,(triIter->second)->GetVid(2)+1);
71 for(quadIter = quadgeom.begin(); quadIter != quadgeom.end(); ++quadIter)
73 fprintf(fp,
"%d %d %d %d\n",(quadIter->second)->GetVid(0)+1,(quadIter->second)->GetVid(1)+1,(quadIter->second)->GetVid(2)+1,(quadIter->second)->GetVid(3)+1);
80 string outname(strtok(argv[argc-1],
"."));
88 int nverts = mesh->GetNvertices();
90 Array<OneD, NekDouble> xc(nverts),yc(nverts),zc(nverts);
92 for(
int i = 0; i < nverts; ++i)
95 mesh->GetVertex(i)->GetCoords(x,y,z);
102 for (
int i = 0; i < nverts; ++i)
104 for (
int j = i+1; j < nverts; ++j)
106 if ((xc[i]-xc[j])*(xc[i]-xc[j]) +
107 (yc[i]-yc[j])*(yc[i]-yc[j]) +
108 (zc[i]-zc[j])*(zc[i]-zc[j]) < 1e-10)
110 cout <<
"Duplicate vertices: " << i <<
" " << j << endl;
117 bool NoRotateIssues =
true;
118 bool NoOrientationIssues =
true;
119 for(tetIter = tetgeom.begin(); tetIter != tetgeom.end(); ++tetIter)
125 if((tetIter->second)->GetFace(0)->GetVid(2) != (tetIter->second)->GetVid(2))
127 cout <<
"ERROR: Face " << tetIter->second->GetFid(0) <<
" (vert "<< (tetIter->second)->GetFace(0)->GetVid(2) <<
") is not aligned with base vertex of Tet " << (tetIter->second)->GetGlobalID() <<
" (vert "<< (tetIter->second)->GetVid(2) <<
")" << endl;
128 NoRotateIssues =
false;
131 for(
int i = 1; i < 4; ++i)
134 if((tetIter->second)->GetFace(i)->GetVid(2) != (tetIter->second)->GetVid(3))
136 cout <<
"ERROR: Face " << tetIter->second->GetFid(i) <<
" is not aligned with top Vertex of Tet " << (tetIter->second)->GetGlobalID() << endl;
137 NoRotateIssues =
false;
142 if(NoOrientationIssues)
144 cout <<
"All Tet have correct ordering for anticlockwise rotation" << endl;
149 cout <<
"All Tet faces are correctly aligned" << endl;
154 for(pyrIter = pyrgeom.begin(); pyrIter != pyrgeom.end(); ++pyrIter)
162 NoRotateIssues =
true;
163 NoOrientationIssues =
true;
164 for(Iter = prismgeom.begin(); Iter != prismgeom.end(); ++Iter)
168 if((Iter->second)->GetFace(1)->GetVid(2) != (Iter->second)->GetVid(4))
170 cout <<
"ERROR: Face " << Iter->second->GetFid(1) <<
" (vert "<< (Iter->second)->GetFace(1)->GetVid(2) <<
") not aligned to face 1 singular vert of Prism " << (Iter->second)->GetGlobalID() <<
" (vert "<< (Iter->second)->GetVid(4) <<
")" << endl;
171 NoRotateIssues =
false;
176 if((Iter->second)->GetFace(3)->GetVid(2) != (Iter->second)->GetVid(5))
178 cout <<
"ERROR: Face " << Iter->second->GetFid(3) <<
" (vert "<< (Iter->second)->GetFace(3)->GetVid(2) <<
") not aligned to face 3 singular vert of Prism " << (Iter->second)->GetGlobalID() <<
" (vert "<< (Iter->second)->GetVid(5) <<
")" << endl;
179 NoRotateIssues =
false;
186 cout <<
"All Prism Tri faces are correctly aligned" << endl;
190 for(hexIter = hexgeom.begin(); hexIter != hexgeom.end(); ++hexIter)
199 ASSERTL0(
false,
"Expansion dimension not recognised");
218 bool RotationOK =
true;
222 v[0].
x = xc[(tetIter->second)->GetVid(0)];
223 v[0].
y = yc[(tetIter->second)->GetVid(0)];
224 v[0].
z = zc[(tetIter->second)->GetVid(0)];
226 v[1].
x = xc[(tetIter->second)->GetVid(1)];
227 v[1].
y = yc[(tetIter->second)->GetVid(1)];
228 v[1].
z = zc[(tetIter->second)->GetVid(1)];
230 v[2].
x = xc[(tetIter->second)->GetVid(2)];
231 v[2].
y = yc[(tetIter->second)->GetVid(2)];
232 v[2].
z = zc[(tetIter->second)->GetVid(2)];
234 v[3].
x = xc[(tetIter->second)->GetVid(3)];
235 v[3].
y = yc[(tetIter->second)->GetVid(3)];
236 v[3].
z = zc[(tetIter->second)->GetVid(3)];
239 abx = (v[1].
y-v[0].
y)*(v[2].z-v[0].z) -
240 (v[1].
z-v[0].
z)*(v[2].y-v[0].y);
241 aby = (v[1].
z-v[0].
z)*(v[2].x-v[0].x) -
242 (v[1].
x-v[0].
x)*(v[2].z-v[0].z);
243 abz = (v[1].
x-v[0].
x)*(v[2].y-v[0].y) -
244 (v[1].
y-v[0].
y)*(v[2].x-v[0].x);
247 if(((v[3].x-v[0].x)*abx + (v[3].
y-v[0].
y)*aby +
248 (v[3].z-v[0].z)*abz)<0.0)
250 cerr <<
"ERROR: Element " <<
id + 1 <<
"is NOT counter-clockwise\n" << endl;