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]);
36 int expdim = mesh->GetMeshDimension();
46 string outname(strtok(argv[argc-1],
"."));
48 FILE *fp = fopen(outname.c_str(),
"w");
53 int nverts = mesh->GetNvertices();
57 for(
int i = 0; i < nverts; ++i)
59 mesh->GetVertex(i)->GetCoords(x,y,z);
66 for(triIter = trigeom.begin(); triIter != trigeom.end(); ++triIter)
68 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);
72 for(quadIter = quadgeom.begin(); quadIter != quadgeom.end(); ++quadIter)
74 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);
81 string outname(strtok(argv[argc-1],
"."));
89 int nverts = mesh->GetNvertices();
93 for(
int i = 0; i < nverts; ++i)
96 mesh->GetVertex(i)->GetCoords(x,y,z);
103 for (
int i = 0; i < nverts; ++i)
105 for (
int j = i+1; j < nverts; ++j)
107 if ((xc[i]-xc[j])*(xc[i]-xc[j]) +
108 (yc[i]-yc[j])*(yc[i]-yc[j]) +
109 (zc[i]-zc[j])*(zc[i]-zc[j]) < 1e-10)
111 cout <<
"Duplicate vertices: " << i <<
" " << j << endl;
118 bool NoRotateIssues =
true;
119 bool NoOrientationIssues =
true;
120 for(tetIter = tetgeom.begin(); tetIter != tetgeom.end(); ++tetIter)
126 if((tetIter->second)->GetFace(0)->GetVid(2) != (tetIter->second)->GetVid(2))
128 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;
129 NoRotateIssues =
false;
132 for(
int i = 1; i < 4; ++i)
135 if((tetIter->second)->GetFace(i)->GetVid(2) != (tetIter->second)->GetVid(3))
137 cout <<
"ERROR: Face " << tetIter->second->GetFid(i) <<
" is not aligned with top Vertex of Tet " << (tetIter->second)->GetGlobalID() << endl;
138 NoRotateIssues =
false;
143 if(NoOrientationIssues)
145 cout <<
"All Tet have correct ordering for anticlockwise rotation" << endl;
150 cout <<
"All Tet faces are correctly aligned" << endl;
155 for(pyrIter = pyrgeom.begin(); pyrIter != pyrgeom.end(); ++pyrIter)
163 NoRotateIssues =
true;
164 NoOrientationIssues =
true;
165 for(Iter = prismgeom.begin(); Iter != prismgeom.end(); ++Iter)
169 if((Iter->second)->GetFace(1)->GetVid(2) != (Iter->second)->GetVid(4))
171 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;
172 NoRotateIssues =
false;
177 if((Iter->second)->GetFace(3)->GetVid(2) != (Iter->second)->GetVid(5))
179 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;
180 NoRotateIssues =
false;
187 cout <<
"All Prism Tri faces are correctly aligned" << endl;
191 for(hexIter = hexgeom.begin(); hexIter != hexgeom.end(); ++hexIter)
200 ASSERTL0(
false,
"Expansion dimension not recognised");
219 bool RotationOK =
true;
223 v[0].
x = xc[(tetIter->second)->GetVid(0)];
224 v[0].
y = yc[(tetIter->second)->GetVid(0)];
225 v[0].
z = zc[(tetIter->second)->GetVid(0)];
227 v[1].
x = xc[(tetIter->second)->GetVid(1)];
228 v[1].
y = yc[(tetIter->second)->GetVid(1)];
229 v[1].
z = zc[(tetIter->second)->GetVid(1)];
231 v[2].
x = xc[(tetIter->second)->GetVid(2)];
232 v[2].
y = yc[(tetIter->second)->GetVid(2)];
233 v[2].
z = zc[(tetIter->second)->GetVid(2)];
235 v[3].
x = xc[(tetIter->second)->GetVid(3)];
236 v[3].
y = yc[(tetIter->second)->GetVid(3)];
237 v[3].
z = zc[(tetIter->second)->GetVid(3)];
240 abx = (v[1].
y-v[0].
y)*(v[2].z-v[0].z) -
241 (v[1].
z-v[0].
z)*(v[2].y-v[0].y);
242 aby = (v[1].
z-v[0].
z)*(v[2].x-v[0].x) -
243 (v[1].
x-v[0].
x)*(v[2].z-v[0].z);
244 abz = (v[1].
x-v[0].
x)*(v[2].y-v[0].y) -
245 (v[1].
y-v[0].
y)*(v[2].x-v[0].x);
248 if(((v[3].x-v[0].x)*abx + (v[3].
y-v[0].
y)*aby +
249 (v[3].z-v[0].z)*abz)<0.0)
251 cerr <<
"ERROR: Element " <<
id + 1 <<
"is NOT counter-clockwise\n" << endl;
#define ASSERTL0(condition, msg)
std::map< int, PrismGeomSharedPtr > PrismGeomMap
std::map< int, PyrGeomSharedPtr > PyrGeomMap
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
bool CheckTetRotation(Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, Array< OneD, NekDouble > &xz, std::map< int, SpatialDomains::TetGeomSharedPtr >::iterator &tetIter, int id)
std::map< int, TetGeomSharedPtr > TetGeomMap
std::map< int, TriGeomSharedPtr > TriGeomMap
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::map< int, QuadGeomSharedPtr > QuadGeomMap
int main(int argc, char *argv[])
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::map< int, HexGeomSharedPtr > HexGeomMap