40 const coupledPolyPatch& cpp,
41 List<pointField>& pts)
const
46 List<pointField> newPts(pts.size());
49 newPts[facei].setSize(pts[facei].size());
58 pointField ptsAtIndex(pts.size(), Zero);
61 const pointField& facePts = pts[facei];
62 if (facePts.size() > index)
64 ptsAtIndex[facei] = facePts[index];
76 cpp.transformPosition(ptsAtIndex);
81 pointField& facePts = newPts[facei];
82 if (facePts.size() > index)
84 facePts[index] = ptsAtIndex[facei];
101 const pointField&
p =
mesh.points();
102 const faceList& fcs =
mesh.faces();
103 const polyBoundaryMesh& patches =
mesh.boundaryMesh();
107 List<pointField> nbrPoints(fcs.size() -
mesh.nInternalFaces());
112 if (patches[patchi].coupled())
114 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(
119 label bFacei = cpp.start() + i -
mesh.nInternalFaces();
120 const face& f = cpp[i];
121 nbrPoints[bFacei].setSize(f.size());
124 const point&
p0 =
p[f[fp]];
125 nbrPoints[bFacei][fp] =
p0;
130 syncTools::syncBoundaryFaceList(
137 label nErrorFaces = 0;
138 scalar avgMismatch = 0;
139 label nCoupledPoints = 0;
143 if (patches[patchi].coupled())
145 const coupledPolyPatch& cpp =
146 refCast<const coupledPolyPatch>(patches[patchi]);
150 scalarField smallDist(
159 label bFacei = cpp.start() + i -
mesh.nInternalFaces();
160 const face& f = cpp[i];
162 if (f.size() != nbrPoints[bFacei].size())
165 <<
"Local face size : " << f.size()
166 <<
" does not equal neighbour face size : "
167 << nbrPoints[bFacei].size()
168 << abort(FatalError);
174 const point&
p0 =
p[f[fp]];
175 scalar d = mag(
p0 - nbrPoints[bFacei][j]);
177 if (d > smallDist[i])
181 setPtr->insert(cpp.start() + i);
198 reduce(nErrorFaces, sumOp<label>());
199 reduce(avgMismatch, maxOp<scalar>());
200 reduce(nCoupledPoints, sumOp<label>());
202 if (nCoupledPoints > 0)
204 avgMismatch /= nCoupledPoints;
211 Info <<
" **Error in coupled point location: "
213 <<
" faces have their 0th or consecutive vertex not opposite"
214 <<
" their coupled equivalent. Average mismatch "
215 << avgMismatch <<
"."
225 Info <<
" Coupled point location match (average "
226 << avgMismatch <<
") OK." << endl;
234 const polyMesh&
mesh,
235 const autoPtr<surfaceWriter>& surfWriter,
236 const autoPtr<writer<scalar>>& setWriter,
237 const label maxIncorrectlyOrientedFaces)
239 label noFailedChecks = 0;
244 const boundBox& globalBb =
mesh.bounds();
246 Info <<
" Overall domain bounding box "
247 << globalBb.min() <<
" " << globalBb.max() << endl;
250 const Vector<label> validDirs = (
mesh.geometricD() + Vector<label>::one);
251 labelList tmpList(3);
252 forAll(tmpList, idxI) tmpList[idxI] = validDirs[idxI] / 2;
253 Info <<
" Mesh has " <<
mesh.nGeometricD()
254 <<
" geometric (non-empty/wedge) directions " << tmpList << endl;
257 const Vector<label> solDirs = (
mesh.solutionD() + Vector<label>::one);
258 forAll(tmpList, idxI) tmpList[idxI] = solDirs[idxI] / 2;
259 Info <<
" Mesh has " <<
mesh.nSolutionD()
260 <<
" solution (non-empty) directions " << tmpList << endl;
262 if (
mesh.nGeometricD() < 3)
265 <<
"Mesh geometric directions is less than 3 and not supported!"
266 << abort(FatalError);
269 if (
mesh.checkClosedBoundary(
true))
275 cellSet cells(
mesh,
"nonClosedCells",
mesh.nCells() / 100 + 1);
276 cellSet aspectCells(
mesh,
"highAspectRatioCells",
mesh.nCells() / 100 + 1);
278 mesh.checkClosedCells(
286 label nNonClosed = returnReduce(cells.size(), sumOp<label>());
290 Info <<
" <<Writing " << nNonClosed
291 <<
" non closed cells to set " << cells.name() << endl;
292 cells.instance() =
mesh.pointsInstance();
294 if (surfWriter.valid())
301 label nHighAspect = returnReduce(aspectCells.size(), sumOp<label>());
305 Info <<
" <<Writing " << nHighAspect
306 <<
" cells with high aspect ratio to set "
307 << aspectCells.name() << endl;
308 aspectCells.instance() =
mesh.pointsInstance();
310 if (surfWriter.valid())
318 faceSet faces(
mesh,
"zeroAreaFaces",
mesh.nFaces() / 100 + 1);
319 if (
mesh.checkFaceAreas(
true, &faces))
323 label nFaces = returnReduce(faces.size(), sumOp<label>());
327 Info <<
" <<Writing " << nFaces
328 <<
" zero area faces to set " << faces.name() << endl;
329 faces.instance() =
mesh.pointsInstance();
331 if (surfWriter.valid())
340 cellSet cells(
mesh,
"zeroVolumeCells",
mesh.nCells() / 100 + 1);
341 if (
mesh.checkCellVolumes(
true, &cells))
345 label nCells = returnReduce(cells.size(), sumOp<label>());
349 Info <<
" <<Writing " << nCells
350 <<
" zero volume cells to set " << cells.name() << endl;
351 cells.instance() =
mesh.pointsInstance();
353 if (surfWriter.valid())
362 faceSet faces(
mesh,
"nonOrthoFaces",
mesh.nFaces() / 100 + 1);
363 if (
mesh.checkFaceOrthogonality(
true, &faces))
368 label nFaces = returnReduce(faces.size(), sumOp<label>());
372 Info <<
" <<Writing " << nFaces
373 <<
" non-orthogonal faces to set " << faces.name() << endl;
374 faces.instance() =
mesh.pointsInstance();
376 if (surfWriter.valid())
384 faceSet faces(
mesh,
"wrongOrientedFaces",
mesh.nFaces() / 100 + 1);
385 if (
mesh.checkFacePyramids(
true, -SMALL, &faces))
387 if (maxIncorrectlyOrientedFaces > 0)
389 Info <<
"maxIncorrectlyOrientedFaces threshold is set to " << maxIncorrectlyOrientedFaces << endl;
392 label nFaces = returnReduce(faces.size(), sumOp<label>());
398 if (nFaces > maxIncorrectlyOrientedFaces)
405 Info <<
" <<Writing " << nFaces
406 <<
" faces with incorrect orientation to set "
407 << faces.name() << endl;
408 faces.instance() =
mesh.pointsInstance();
410 if (surfWriter.valid())
419 faceSet faces(
mesh,
"skewFaces",
mesh.nFaces() / 100 + 1);
420 if (
mesh.checkFaceSkewness(
true, &faces))
424 label nFaces = returnReduce(faces.size(), sumOp<label>());
428 Info <<
" <<Writing " << nFaces
429 <<
" skew faces to set " << faces.name() << endl;
430 faces.instance() =
mesh.pointsInstance();
432 if (surfWriter.valid())
441 faceSet faces(
mesh,
"coupledFaces",
mesh.nFaces() / 100 + 1);
446 label nFaces = returnReduce(faces.size(), sumOp<label>());
450 Info <<
" <<Writing " << nFaces
451 <<
" faces with incorrectly matched 0th (or consecutive)"
453 << faces.name() << endl;
454 faces.instance() =
mesh.pointsInstance();
456 if (surfWriter.valid())
464 return noFailedChecks;