75 &&
mag(ppCosAngle - wppCosAngle) >= 1
e-3
113 Info<<
" Wedge " << pp.
name() <<
" with angle "
114 <<
radToDeg(wedgeAngle) <<
" degrees"
121 if (oppositePatchi == -1)
125 Info<<
" ***Cannot find opposite wedge for wedge "
132 refCast<const wedgePolyPatch>(
patches[oppositePatchi]);
139 Info<<
" ***Wedges do not have the same axis."
140 <<
" Encountered " << pp.
axis()
141 <<
" on patch " << pp.
name()
142 <<
" which differs from " << opp.
axis()
143 <<
" on opposite wedge patch" << opp.
axis()
154 const face&
f = pp[i];
158 label p1 =
f.nextLabel(fp);
169 scalar d =
mag((pt - p0) & pp.
n());
175 Info<<
" ***Wedge patch " << pp.
name() <<
" not planar."
176 <<
" Point " << pt <<
" is not in patch plane by "
189 label nEdgesInError = 0;
193 const face&
f = fcs[facei];
198 label p1 =
f.nextLabel(fp);
202 scalar magD =
mag(d);
204 if (magD > rootVSmall)
209 label nEmptyDirs = 0;
210 label nNonEmptyDirs = 0;
211 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
213 if (
mag(d[cmpt]) > 1
e-6)
230 else if (nEmptyDirs == 1)
233 if (nNonEmptyDirs > 0)
241 else if (nEmptyDirs > 1)
260 Info<<
" ***Number of edges not aligned with or perpendicular to "
261 <<
"non-empty directions: " << nErrorEdges <<
endl;
266 setPtr->
resize(2*nEdgesInError);
271 setPtr->
insert(iter.key()[0]);
272 setPtr->
insert(iter.key()[1]);
283 Info<<
" All edges aligned with or perpendicular to "
284 <<
"non-empty directions." <<
endl;
311 newPts[facei].
setSize(pts[facei].size());
324 if (facePts.
size() > index)
326 ptsAtIndex[facei] = facePts[index];
338 cpp.transform().transformPosition(ptsAtIndex, ptsAtIndex);
344 if (facePts.
size() > index)
346 facePts[index] = ptsAtIndex[facei];
387 const face&
f = cpp[i];
388 nbrPoints[bFacei].
setSize(
f.size());
392 nbrPoints[bFacei][fp] = p0;
397 syncTools::syncBoundaryFaceList
406 label nErrorFaces = 0;
407 scalar avgMismatch = 0;
408 label nCoupledPoints = 0;
433 const face&
f = cpp[i];
435 if (
f.size() != nbrPoints[bFacei].
size())
438 <<
"Local face size : " <<
f.size()
439 <<
" does not equal neighbour face size : "
440 << nbrPoints[bFacei].
size()
448 scalar d =
mag(p0 - nbrPoints[bFacei][j]);
450 if (d > smallDist[i])
475 if (nCoupledPoints > 0)
477 avgMismatch /= nCoupledPoints;
484 Info<<
" **Error in coupled point location: "
486 <<
" faces have their 0th or consecutive vertex not opposite"
487 <<
" their coupled equivalent. Average mismatch "
488 << avgMismatch <<
"."
498 Info<<
" Coupled point location match (average "
499 << avgMismatch <<
") OK." <<
endl;
510 const bool allGeometry,
511 const scalar nonOrthThreshold,
512 const scalar skewThreshold,
517 const scalar closedThreshold = 1.0e-6;
518 const scalar aspectThreshold = 1000;
519 const scalar planarCosAngle = 1.0e-6;
521 label noFailedChecks = 0;
523 Info<<
"\nChecking geometry..." <<
endl;
528 Info<<
" Overall domain bounding box "
529 << globalBb.
min() <<
" " << globalBb.
max() <<
endl;
533 Info<<
" Patch bounding boxes" <<
endl;
541 if (!isA<processorPolyPatch>(pp))
566 scalar minDistSqr =
magSqr(1
e-6 * globalBb.
span());
571 <<
" geometric (non-empty/wedge) directions " << validDirs <<
endl;
576 <<
" solution (non-empty) directions " << solDirs <<
endl;
603 nonAlignedPoints.
size(),
611 Info<<
" <<Writing " << nNonAligned
612 <<
" points on non-aligned edges to set "
615 nonAlignedPoints.
write();
649 Info<<
" <<Writing " << nNonClosed
650 <<
" non closed cells to set " <<
cells.name() <<
endl;
655 if (surfWriter.
valid())
668 Info<<
" <<Writing " << nHighAspect
669 <<
" cells with high aspect ratio to set "
675 if (surfWriter.
valid())
694 Info<<
" <<Writing " << nFaces
695 <<
" zero area faces to set " << faces.
name() <<
endl;
700 if (surfWriter.
valid())
720 Info<<
" <<Writing " << nCells
721 <<
" zero volume cells to set " <<
cells.name() <<
endl;
726 if (surfWriter.
valid())
756 Info<<
" <<Writing " << nFaces
757 <<
" non-orthogonal faces to set " << faces.
name() <<
endl;
762 if (surfWriter.
valid())
781 Info<<
" <<Writing " << nFaces
782 <<
" faces with incorrect orientation to set "
788 if (surfWriter.
valid())
817 Info<<
" <<Writing " << nFaces
818 <<
" skew faces to set " << faces.
name() <<
endl;
823 if (surfWriter.
valid())
843 Info<<
" <<Writing " << nFaces
844 <<
" faces with incorrectly matched 0th "
845 "(or consecutive) vertex to set "
851 if (surfWriter.
valid())
867 polyMeshTetDecomposition::minTetQuality,
881 Info<<
" <<Writing " << nFaces
882 <<
" faces with low quality or negative volume "
883 <<
"decomposition tets to set " << faces.
name() <<
endl;
888 if (surfWriter.
valid())
911 <<
" points on short edges to set " <<
points.name()
934 <<
" near (closer than " <<
Foam::sqrt(minDistSqr)
935 <<
" apart) points to set " << nearPoints.
name()
958 Info<<
" <<Writing " << nFaces
959 <<
" faces with concave angles to set " << faces.
name()
965 if (surfWriter.
valid())
986 Info<<
" <<Writing " << nFaces
987 <<
" warped faces to set " << faces.
name() <<
endl;
992 if (surfWriter.
valid())
1011 Info<<
" <<Writing " << nCells
1012 <<
" under-determined cells to set " <<
cells.name()
1018 if (surfWriter.
valid())
1036 Info<<
" <<Writing " << nCells
1037 <<
" concave cells to set " <<
cells.name() <<
endl;
1042 if (surfWriter.
valid())
1060 Info<<
" <<Writing " << nFaces
1061 <<
" faces with low interpolation weights to set "
1067 if (surfWriter.
valid())
1085 Info<<
" <<Writing " << nFaces
1086 <<
" faces with low volume ratio cells to set "
1092 if (surfWriter.
valid())
1103 /functionObjects::writeFile::outputPrefix
1114 if (isA<nonConformalCyclicPolyPatch>(
patches[nccPatchi]))
1117 refCast<const nonConformalCyclicPolyPatch>
1128 if (!patchCoverage.
set(origPp.
index()))
1137 patchCoverage[origPp.
index()] +=
1140 if (!patchCoverage.
set(nbrOrigPp.
index()))
1149 patchCoverage[nbrOrigPp.
index()] +=
1176 uniqueMeshPointLabels,
1185 globalFaces().gather
1187 UPstream::worldComm,
1188 labelList(UPstream::procID(UPstream::worldComm)),
1194 if (Pstream::master())
1203 patch.
name() +
"_coverage",
1215 return noFailedChecks;
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
void resize(const label newSize)
Resize the hash table for efficiency.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const word & name() const
Return name.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const Field< PointType > & points() const
Return reference to global points.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
fileName globalPath() const
Return the global path.
IOstream::streamFormat writeFormat() const
Default write format.
IOstream::compressionType writeCompression() const
Default write compression.
label size() const
Return the number of elements in the UList.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
A bounding box defined in terms of the points at its extremities.
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
vector span() const
The bounding box span (from minimum to maximum)
A collection of cell labels.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual bool owner() const =0
Does this side own the patch ?
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
const word & name() const
Return const reference to name.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
const Time & time() const
Return the top-level database.
const word & name() const
Return reference to name.
Calculates points shared by more than two processor patches or cyclic patches.
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Class to generate patchToPatch coupling geometry. A full geometric intersection is done between a fac...
Mesh consisting of general polyhedral cells.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
virtual const faceList & faces() const
Return raw faces.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
const fileName & pointsInstance() const
Return the current instance directory for points.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
const boundBox & bounds() const
Return mesh bounding box.
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
const vectorField::subField faceCentres() const
Return face centres.
label nInternalFaces() const
virtual bool write(const bool write=true) const
Write using setting from DB.
Base class for writing coordinate sets with data.
A surfaceWriter for VTK legacy format with support for writing ASCII or binary.
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces, const wordList &fieldNames, const bool writePointValues #define FieldTypeValuesConstArg(Type, nullArg)) const
Write fields for a single surface to file.
Wedge front and back plane patch.
const vector & centreNormal() const
Return plane normal between the wedge boundaries.
scalar cosAngle() const
Return the cosine of the wedge angle.
const vector & n() const
Return the normal to the patch.
const vector & axis() const
Return axis of the wedge.
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
Tools for checking the mesh.
Functions for checking mesh topology and geometry.
const dimensionedScalar mp
Proton mass.
const dimensionedScalar e
Elementary charge.
bool checkFaceWeight(const polyMesh &mesh, const bool report, const scalar minWeight=0.05, labelHashSet *setPtr=nullptr)
Check for face weights.
bool checkFacePyramids(const bool report, const scalar minPyrVol, const polyMesh &, const vectorField &cellCentres, const pointField &p, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet *)
Check face pyramid volumes.
bool checkEdgeAlignment(const polyMesh &mesh, const bool report, const Vector< label > &directions, labelHashSet *setPtr)
Check edge alignment for 1D/2D cases.
bool checkEdgeLength(const primitiveMesh &mesh, const bool report, const scalar minLenSqr, labelHashSet *setPtr=nullptr)
Check edge length.
bool checkCoupledPoints(const polyMesh &, const bool report, labelHashSet *)
Check 0th vertex on coupled faces.
bool checkConcaveCells(const primitiveMesh &mesh, const scalar planarCosAngle, const bool report=false, labelHashSet *setPtr=nullptr)
Check for concave cells by the planes of faces.
bool checkWedges(const polyMesh &, const bool report, const Vector< label > &, labelHashSet *)
Check wedge orientation.
bool checkPointNearness(const primitiveMesh &mesh, const bool report, const scalar reportDistSqr, labelHashSet *setPtr=nullptr)
Check for point-point-nearness,.
bool checkCellDeterminant(const polyMesh &mesh, const bool report, labelHashSet *setPtr)
bool checkFaceAngles(const bool report, const scalar maxConcave, const polyMesh &mesh, const vectorField &faceAreas, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
Check convexity of angles in a face. See primitiveMesh for explanation.
bool checkVolRatio(const polyMesh &mesh, const bool report, const scalar minRatio=0.01, labelHashSet *setPtr=nullptr)
Check for neighbouring cell volumes.
label findOppositeWedge(const polyMesh &, const wedgePolyPatch &)
Find wedge with opposite orientation. Note: does not actually check.
bool checkClosedCells(const primitiveMesh &mesh, const scalar closedThreshold, const scalar aspectThreshold, const bool report=false, labelHashSet *setPtr=nullptr, labelHashSet *highAspectSetPtr=nullptr, const Vector< label > &solutionD=Vector< label >::one)
Check cells for closedness.
void mergeAndWrite(const polyMesh &mesh, const surfaceWriter &setWriter, const word &name, const indirectPrimitivePatch setPatch, const fileName &outputDir)
Generate merged surface on master and write. Needs input patch.
bool checkClosedBoundary(const primitiveMesh &mesh, const scalar closedThreshold, const bool report=false)
Check boundary for closedness.
bool checkFaceTets(const bool report, const scalar minPyrVol, const polyMesh &, const vectorField &cellCentres, const vectorField &faceCentres, const pointField &p, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet *)
Check face tetrahedra volumes.
bool checkFaceFlatness(const bool report, const scalar minFlatness, const polyMesh &, const vectorField &faceAreas, const vectorField &faceCentres, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
Check for face areas v.s. sum of face-triangle (from face-centre.
bool checkFaceOrthogonality(const polyMesh &mesh, const scalar nonOrthThreshold, const bool report=false, labelHashSet *setPtr=nullptr)
Check face orthogonality.
bool checkCellVolumes(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check for negative cell volumes.
label checkGeometry(const polyMesh &mesh, const bool allGeometry, const scalar nonOrthThreshold, const scalar skewThreshold, const autoPtr< surfaceWriter > &, const autoPtr< setWriter > &)
Check the geometry.
bool checkFaceAreas(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check for negative face areas.
bool checkFaceSkewness(const polyMesh &mesh, const scalar skewThreshold, const bool report=false, labelHashSet *setPtr=nullptr)
Check face skewness.
scalar radToDeg(const scalar rad)
Convert radians to degrees.
scalar degToRad(const scalar deg)
Convert degrees to radians.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Omanip< int > setw(const int i)
errorManip< error > abort(error &err)
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensionedScalar acos(const dimensionedScalar &ds)