16 const wedgePolyPatch& wpp
19 const polyBoundaryMesh&
patches = mesh.boundaryMesh();
21 scalar wppCosAngle = wpp.centreNormal()&wpp.patchNormal();
28 && patches[patchI].size()
29 && isA<wedgePolyPatch>(patches[patchI])
32 const wedgePolyPatch& pp = refCast<const wedgePolyPatch>
38 scalar ppCosAngle = wpp.centreNormal()&pp.patchNormal();
42 pp.size() == wpp.size()
43 &&
mag(pp.axis() & wpp.axis()) >= (1-1
E-3)
44 &&
mag(ppCosAngle - wppCosAngle) >= 1
E-3
59 const Vector<label>& directions,
64 EdgeMap<label> edgesInError;
70 const polyBoundaryMesh& patches = mesh.boundaryMesh();
73 if (patches[patchI].size() && isA<wedgePolyPatch>(patches[patchI]))
75 const wedgePolyPatch& pp = refCast<const wedgePolyPatch>
80 scalar wedgeAngle =
acos(pp.centreNormal()&pp.patchNormal());
84 Info<<
" Wedge " << pp.name() <<
" with angle "
92 if (oppositePatchI == -1)
96 Info<<
" ***Cannot find opposite wedge for wedge "
102 const wedgePolyPatch& opp = refCast<const wedgePolyPatch>
104 patches[oppositePatchI]
108 if (
mag(opp.axis() & pp.axis()) < (1-1
E-3))
112 Info<<
" ***Wedges do not have the same axis."
113 <<
" Encountered " << pp.axis()
114 <<
" on patch " << pp.name()
115 <<
" which differs from " << opp.axis()
116 <<
" on opposite wedge patch" << opp.axis()
127 const face&
f = pp[i];
131 label p1 = f.nextLabel(fp);
132 edgesInError.insert(edge(p0, p1), -1);
138 const point& p0 = p[pp.meshPoints()[0]];
139 forAll(pp.meshPoints(), i)
141 const point& pt = p[pp.meshPoints()[i]];
142 scalar
d =
mag((pt-p0) & pp.patchNormal());
148 Info<<
" ***Wedge patch " << pp.name() <<
" not planar."
149 <<
" Point " << pt <<
" is not in patch plane by "
162 label nEdgesInError = 0;
166 const face& f = fcs[faceI];
171 label p1 = f.nextLabel(fp);
175 scalar magD =
mag(d);
177 if (magD > ROOTVSMALL)
182 label nEmptyDirs = 0;
183 label nNonEmptyDirs = 0;
184 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
186 if (
mag(d[cmpt]) > 1
e-6)
188 if (directions[cmpt] == 0)
203 else if (nEmptyDirs == 1)
206 if (nNonEmptyDirs > 0)
208 if (edgesInError.insert(edge(p0, p1), faceI))
214 else if (nEmptyDirs > 1)
217 if (edgesInError.insert(edge(p0, p1), faceI))
227 label nErrorEdges =
returnReduce(nEdgesInError, sumOp<label>());
233 Info<<
" ***Number of edges not aligned with or perpendicular to "
234 <<
"non-empty directions: " << nErrorEdges <<
endl;
239 setPtr->resize(2*nEdgesInError);
244 setPtr->insert(iter.key()[0]);
245 setPtr->insert(iter.key()[1]);
256 Info<<
" All edges aligned with or perpendicular to "
257 <<
"non-empty directions." <<
endl;
266 label noFailedChecks = 0;
268 Info<<
"\nChecking geometry..." <<
endl;
271 const boundBox& globalBb = mesh.bounds();
273 Info<<
" Overall domain bounding box "
274 << globalBb.min() <<
" " << globalBb.max() <<
endl;
278 scalar minDistSqr =
magSqr(1
e-6 * globalBb.span());
281 const Vector<label> validDirs = (mesh.geometricD() + Vector<label>::one)/2;
282 Info<<
" Mesh (non-empty, non-wedge) directions " << validDirs <<
endl;
284 const Vector<label> solDirs = (mesh.solutionD() + Vector<label>::one)/2;
285 Info<<
" Mesh (non-empty) directions " << solDirs <<
endl;
287 if (mesh.nGeometricD() < 3)
289 pointSet nonAlignedPoints(mesh,
"nonAlignedEdges", mesh.nPoints()/100);
295 &&
checkWedges(mesh,
true, validDirs, &nonAlignedPoints)
299 && mesh.checkEdgeAlignment(
true, validDirs, &nonAlignedPoints)
306 nonAlignedPoints.size(),
312 Info<<
" <<Writing " << nNonAligned
313 <<
" points on non-aligned edges to set "
314 << nonAlignedPoints.name() <<
endl;
315 nonAlignedPoints.
write();
320 if (mesh.checkClosedBoundary(
true)) noFailedChecks++;
323 cellSet
cells(mesh,
"nonClosedCells", mesh.nCells()/100+1);
324 cellSet aspectCells(mesh,
"highAspectRatioCells", mesh.nCells()/100+1);
327 mesh.checkClosedCells
342 Info<<
" <<Writing " << nNonClosed
343 <<
" non closed cells to set " <<
cells.name() <<
endl;
348 label nHighAspect =
returnReduce(aspectCells.size(), sumOp<label>());
352 Info<<
" <<Writing " << nHighAspect
353 <<
" cells with high aspect ratio to set "
354 << aspectCells.name() <<
endl;
360 faceSet faces(mesh,
"zeroAreaFaces", mesh.nFaces()/100 + 1);
361 if (mesh.checkFaceAreas(
true, &faces))
365 label nFaces =
returnReduce(faces.size(), sumOp<label>());
369 Info<<
" <<Writing " << nFaces
370 <<
" zero area faces to set " << faces.name() <<
endl;
377 cellSet
cells(mesh,
"zeroVolumeCells", mesh.nCells()/100 + 1);
378 if (mesh.checkCellVolumes(
true, &
cells))
386 Info<<
" <<Writing " << nCells
387 <<
" zero volume cells to set " <<
cells.name() <<
endl;
394 faceSet faces(mesh,
"nonOrthoFaces", mesh.nFaces()/100 + 1);
395 if (mesh.checkFaceOrthogonality(
true, &faces))
400 label nFaces =
returnReduce(faces.size(), sumOp<label>());
404 Info<<
" <<Writing " << nFaces
405 <<
" non-orthogonal faces to set " << faces.name() <<
endl;
412 faceSet faces(mesh,
"wrongOrientedFaces", mesh.nFaces()/100 + 1);
413 if (mesh.checkFacePyramids(
true, -SMALL, &faces))
417 label nFaces =
returnReduce(faces.size(), sumOp<label>());
421 Info<<
" <<Writing " << nFaces
422 <<
" faces with incorrect orientation to set "
423 << faces.name() <<
endl;
430 faceSet faces(mesh,
"skewFaces", mesh.nFaces()/100 + 1);
431 if (mesh.checkFaceSkewness(
true, &faces))
435 label nFaces =
returnReduce(faces.size(), sumOp<label>());
439 Info<<
" <<Writing " << nFaces
440 <<
" skew faces to set " << faces.name() <<
endl;
449 pointSet
points(mesh,
"shortEdges", mesh.nPoints()/1000 + 1);
450 if (mesh.checkEdgeLength(
true, minDistSqr, &
points))
458 Info<<
" <<Writing " << nPoints
459 <<
" points on short edges to set " <<
points.name()
467 if (mesh.checkPointNearness(
false, minDistSqr, &
points))
473 if (nPoints > nEdgeClose)
475 pointSet nearPoints(mesh,
"nearPoints",
points);
476 Info<<
" <<Writing " << nPoints
477 <<
" near (closer than " <<
Foam::sqrt(minDistSqr)
478 <<
" apart) points to set " << nearPoints.
name() <<
endl;
486 faceSet faces(mesh,
"concaveFaces", mesh.nFaces()/100 + 1);
487 if (mesh.checkFaceAngles(
true, 10, &faces))
491 label nFaces =
returnReduce(faces.size(), sumOp<label>());
495 Info<<
" <<Writing " << nFaces
496 <<
" faces with concave angles to set " << faces.name()
505 faceSet faces(mesh,
"warpedFaces", mesh.nFaces()/100 + 1);
506 if (mesh.checkFaceFlatness(
true, 0.8, &faces))
510 label nFaces =
returnReduce(faces.size(), sumOp<label>());
514 Info<<
" <<Writing " << nFaces
515 <<
" warped faces to set " << faces.name() <<
endl;
523 cellSet
cells(mesh,
"underdeterminedCells", mesh.nCells()/100);
524 if (mesh.checkCellDeterminant(
true, &
cells, mesh.geometricD()))
530 Info<<
" <<Writing " << nCells
531 <<
" under-determined cells to set " <<
cells.name() <<
endl;
537 return noFailedChecks;