50{
53
54 if (argc != 2)
55 {
56 fprintf(stderr, "Usage: CheckXmlFile meshfile.xml\n");
57 exit(1);
58 }
59
61 LibUtilities::SessionReader::CreateInstance(argc, argv);
62
63
64
65 string meshfile(argv[argc - 1]);
67 SpatialDomains::MeshGraphIO::Read(vSession);
68
69
70
71
72 int expdim = mesh->GetMeshDimension();
73
74 switch (expdim)
75 {
76 case 1:
78 break;
79 case 2:
80 {
82 string outname(strtok(argv[argc - 1], "."));
83 outname += ".dat";
84 FILE *fp = fopen(outname.c_str(), "w");
85
88
89 int nverts = mesh->GetNvertices();
90
92
93 for (int i = 0; i < nverts; ++i)
94 {
95 mesh->GetVertex(i)->GetCoords(x, y,
z);
96 xc[i] = x;
97 yc[i] = y;
99 }
100
101 std::map<int, SpatialDomains::TriGeomSharedPtr>::iterator triIter;
102 for (triIter = trigeom.begin(); triIter != trigeom.end(); ++triIter)
103 {
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);
108 }
109
110 std::map<int, SpatialDomains::QuadGeomSharedPtr>::iterator quadIter;
111 for (quadIter = quadgeom.begin(); quadIter != quadgeom.end();
112 ++quadIter)
113 {
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);
118 }
119 }
120 break;
121 case 3:
122 {
124 string outname(strtok(argv[argc - 1], "."));
125 outname += ".dat";
126
131
132 int nverts = mesh->GetNvertices();
133
135
136 for (int i = 0; i < nverts; ++i)
137 {
138
139 mesh->GetVertex(i)->GetCoords(x, y,
z);
140 xc[i] = x;
141 yc[i] = y;
143 }
144
145 for (int i = 0; i < nverts; ++i)
146 {
147 for (int j = i + 1; j < nverts; ++j)
148 {
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]) <
152 1e-10)
153 {
154 cout << "Duplicate vertices: " << i << " " << j << endl;
155 }
156 }
157 }
158
159 std::map<int, SpatialDomains::TetGeomSharedPtr>::iterator tetIter;
160 int cnt = 0;
161 bool NoRotateIssues = true;
162 bool NoOrientationIssues = true;
163 for (tetIter = tetgeom.begin(); tetIter != tetgeom.end(); ++tetIter)
164 {
165
166 NoOrientationIssues =
168
169
170 if ((tetIter->second)->GetFace(0)->GetVid(2) !=
171 (tetIter->second)->GetVid(2))
172 {
173 cout << "ERROR: Face " << tetIter->second->GetFid(0)
174 << " (vert "
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;
180 }
181
182 for (int i = 1; i < 4; ++i)
183
184 {
185 if ((tetIter->second)->GetFace(i)->GetVid(2) !=
186 (tetIter->second)->GetVid(3))
187 {
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;
192 }
193 }
194 }
195 if (NoOrientationIssues)
196 {
197 cout << "All Tet have correct ordering for anticlockwise "
198 "rotation"
199 << endl;
200 }
201
202 if (NoRotateIssues)
203 {
204 cout << "All Tet faces are correctly aligned" << endl;
205 }
206
207 std::map<int, SpatialDomains::PyrGeomSharedPtr>::iterator pyrIter;
208 for (pyrIter = pyrgeom.begin(); pyrIter != pyrgeom.end(); ++pyrIter)
209 {
210
211 }
212
213
214 std::map<int, SpatialDomains::PrismGeomSharedPtr>::iterator Iter;
215 NoRotateIssues = true;
216 NoOrientationIssues = true;
217 for (Iter = prismgeom.begin(); Iter != prismgeom.end(); ++Iter)
218 {
219
220
221 if ((Iter->second)->GetFace(1)->GetVid(2) !=
222 (Iter->second)->GetVid(4))
223 {
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;
230 }
231
232
233 if ((Iter->second)->GetFace(3)->GetVid(2) !=
234 (Iter->second)->GetVid(5))
235 {
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;
242 }
243 }
244
245 if (NoRotateIssues)
246 {
247 cout << "All Prism Tri faces are correctly aligned" << endl;
248 }
249
250 std::map<int, SpatialDomains::HexGeomSharedPtr>::iterator hexIter;
251 for (hexIter = hexgeom.begin(); hexIter != hexgeom.end(); ++hexIter)
252 {
253
254 }
255 }
256
257 break;
258 default:
259 ASSERTL0(
false,
"Expansion dimension not recognised");
260 break;
261 }
262
263
264
265 return 0;
266}
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