45{
48
49 if (argc != 2)
50 {
51 std::cerr << "Usage: CheckXmlFile meshfile.xml" << std::endl;
52 return 1;
53 }
54
57
58
59
60 std::string meshfile(argv[argc - 1]);
63
64
65
66
67 int expdim = mesh->GetMeshDimension();
68
69 switch (expdim)
70 {
71 case 1:
73 break;
74 case 2:
76 break;
77 case 3:
78 {
79 int cnt = 0, nverts = mesh->GetNvertices();
81 std::map<int, int> vid2cnt;
82
83 for (auto [id, vert] :
84 mesh->GetGeomMap<SpatialDomains::PointGeom>())
85 {
86
87 vert->GetCoords(xc[cnt], yc[cnt], zc[cnt]);
88 vid2cnt[vert->GetGlobalID()] = cnt++;
89 }
90
91
92 for (int i = 0; i < nverts; ++i)
93 {
94 for (int j = i + 1; j < nverts; ++j)
95 {
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]) <
99 1e-10)
100 {
101 std::cerr << "ERROR: Duplicate vertices: " << i << " "
102 << j << std::endl;
103 }
104 }
105 }
106
107 bool NoRotateIssues = true;
108 bool NoOrientationIssues = true;
109 for (auto [id, tet] : mesh->GetGeomMap<SpatialDomains::TetGeom>())
110 {
111
112 NoOrientationIssues =
114
115
116 if (tet->GetFace(0)->GetVid(2) != tet->GetVid(2))
117 {
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;
124 }
125
126 for (int i = 1; i < 4; ++i)
127 {
128 if (tet->GetFace(i)->GetVid(2) != tet->GetVid(3))
129 {
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;
134 }
135 }
136 }
137 if (NoOrientationIssues)
138 {
139 std::cout << "All Tet have correct ordering for anticlockwise "
140 "rotation"
141 << std::endl;
142 }
143
144 if (NoRotateIssues)
145 {
146 std::cout << "All Tet faces are correctly aligned" << std::endl;
147 }
148
149 for ([[maybe_unused]] auto [id, pyr] :
150 mesh->GetGeomMap<SpatialDomains::PyrGeom>())
151 {
152
153 }
154
155 NoRotateIssues = true;
156 NoOrientationIssues = true;
157 for (auto [id, pri] : mesh->GetGeomMap<SpatialDomains::PrismGeom>())
158 {
159
160 if (pri->GetFace(1)->GetVid(2) != pri->GetVid(4))
161 {
162 std::cerr
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)
167 << ")" << std::endl;
168 NoRotateIssues = false;
169 }
170
171
172 if (pri->GetFace(3)->GetVid(2) != pri->GetVid(5))
173 {
174 std::cerr
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)
179 << ")" << std::endl;
180 NoRotateIssues = false;
181 }
182 }
183
184 if (NoRotateIssues)
185 {
186 std::cout << "All Prism Tri faces are correctly aligned"
187 << std::endl;
188 }
189
190 for ([[maybe_unused]] auto [id, hex] :
191 mesh->GetGeomMap<SpatialDomains::HexGeom>())
192 {
193
194 }
195 }
196
197 break;
198 default:
199 ASSERTL0(
false,
"Expansion dimension not recognised");
200 break;
201 }
202
203
204
205 return 0;
206}
bool CheckTetRotation(Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, Array< OneD, NekDouble > &xz, SpatialDomains::TetGeom *tet, std::map< int, int > &vid2cnt)
#define ASSERTL0(condition, msg)
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr