36 bool Foam::polyMesh::checkFaceOrthogonality
41 const bool detailedReport,
61 const scalar severeNonorthogonalityThreshold =
65 scalar minDDotS = GREAT;
66 scalar sumDDotS = 0.0;
68 label severeNonOrth = 0;
69 label errorNonOrth = 0;
77 if (ortho[facei] < severeNonorthogonalityThreshold)
79 if (ortho[facei] > SMALL)
83 setPtr->insert(facei);
93 setPtr->insert(facei);
95 if (detailedReport && errorNonOrth == 0)
99 <<
"Severe non-orthogonality for face " 101 <<
" between cells " << own[facei]
102 <<
" and " << nei[facei]
112 if (isMasterFace.test(facei))
114 minDDotS =
min(minDDotS, ortho[facei]);
115 sumDDotS += ortho[facei];
120 reduce(minDDotS, minOp<scalar>());
121 reduce(sumDDotS, sumOp<scalar>());
122 reduce(nSummed, sumOp<label>());
123 reduce(severeNonOrth, sumOp<label>());
124 reduce(errorNonOrth, sumOp<label>());
133 meshDict.set(
"maxNonOrth", maxNonOrth);
134 meshDict.set(
"aveNonOrth", aveNonOrth);
138 Info<<
" Mesh non-orthogonality Max: " << maxNonOrth
139 <<
" average: " << aveNonOrth
144 if (severeNonOrth > 0)
147 meshDict.set(
"severeNonOrth", severeNonOrth);
151 Info<<
" *Number of severely non-orthogonal (> " 153 << severeNonOrth <<
"." <<
endl;
157 if (errorNonOrth > 0)
159 meshDict.set(
"errorNonOrth", errorNonOrth);
163 Info<<
" ***Number of non-orthogonality errors: " 164 << errorNonOrth <<
"." <<
endl;
172 Info<<
" Non-orthogonality check OK." <<
endl;
179 bool Foam::polyMesh::checkFaceSkewness
186 const bool detailedReport,
218 if (
skew[facei] > skewThreshold_)
222 setPtr->insert(facei);
224 if (detailedReport && nWarnSkew == 0)
227 if (isInternalFace(facei))
230 <<
"Severe skewness " <<
skew[facei]
231 <<
" for face " << facei
232 <<
" between cells " << own[facei]
233 <<
" and " << nei[facei];
238 <<
"Severe skewness " <<
skew[facei]
239 <<
" for boundary face " << facei
240 <<
" on cell " << own[facei];
244 if (isMasterFace.test(facei))
251 reduce(maxSkew, maxOp<scalar>());
252 reduce(nWarnSkew, sumOp<label>());
263 Info<<
" ***Max skewness = " << maxSkew
264 <<
", " << nWarnSkew <<
" highly skew faces detected" 265 " which may impair the quality of the results" 274 Info<<
" Max skewness = " << maxSkew <<
" OK." <<
endl;
281 bool Foam::polyMesh::checkEdgeAlignment
285 const Vector<label>& directions,
301 if (directions[cmpt] == 1)
305 else if (directions[cmpt] != 0)
308 <<
"directions should contain 0 or 1 but is now " << directions
321 EdgeMap<label> edgesInError;
325 const face&
f = fcs[facei];
330 label p1 =
f.nextLabel(fp);
334 scalar magD =
mag(d);
336 if (magD > ROOTVSMALL)
341 label nEmptyDirs = 0;
342 label nNonEmptyDirs = 0;
345 if (
mag(d[cmpt]) > 1
e-6)
347 if (directions[cmpt] == 0)
362 else if (nEmptyDirs == 1)
365 if (nNonEmptyDirs > 0)
367 edgesInError.insert(edge(
p0, p1), facei);
370 else if (nEmptyDirs > 1)
373 edgesInError.insert(edge(
p0, p1), facei);
380 label nErrorEdges =
returnReduce(edgesInError.size(), sumOp<label>());
389 Info<<
" ***Number of edges not aligned with or perpendicular to " 390 <<
"non-empty directions: " << nErrorEdges <<
endl;
395 setPtr->reserve(2*edgesInError.size());
398 setPtr->insert(iter.key().first());
399 setPtr->insert(iter.key().second());
408 Info<<
" All edges aligned with or perpendicular to " 409 <<
"non-empty directions." <<
endl;
416 bool Foam::polyMesh::checkCellDeterminant
421 const Vector<label>& meshD
424 const scalar warnDet = 1
e-3;
435 scalarField& cellDeterminant = tcellDeterminant.ref();
438 label nErrorCells = 0;
439 scalar minDet =
min(cellDeterminant);
440 scalar sumDet =
sum(cellDeterminant);
442 forAll(cellDeterminant, celli)
444 if (cellDeterminant[celli] < warnDet)
448 setPtr->insert(celli);
455 reduce(nErrorCells, sumOp<label>());
456 reduce(minDet, minOp<scalar>());
457 reduce(sumDet, sumOp<scalar>());
458 label nSummed =
returnReduce(cellDeterminant.size(), sumOp<label>());
469 Info<<
" Cell determinant (wellposedness) : minimum: " << minDet
470 <<
" average: " << sumDet/nSummed
482 Info<<
" ***Cells with small determinant (< " 483 << warnDet <<
") found, number of cells: " 484 << nErrorCells <<
endl;
492 Info<<
" Cell determinant check OK." <<
endl;
499 bool Foam::polyMesh::checkFaceWeight
505 const scalar minWeight,
521 label nErrorFaces = 0;
522 scalar minDet = GREAT;
531 if (faceWght[facei] < minWeight)
536 setPtr->insert(facei);
543 if (isMasterFace.test(facei))
545 minDet =
min(minDet, faceWght[facei]);
546 sumDet += faceWght[facei];
551 reduce(nErrorFaces, sumOp<label>());
552 reduce(minDet, minOp<scalar>());
553 reduce(sumDet, sumOp<scalar>());
554 reduce(nSummed, sumOp<label>());
565 Info<<
" Face interpolation weight : minimum: " << minDet
566 <<
" average: " << sumDet/nSummed
578 Info<<
" ***Faces with small interpolation weight (< " << minWeight
579 <<
") found, number of faces: " 580 << nErrorFaces <<
endl;
588 Info<<
" Face interpolation weight check OK." <<
endl;
595 bool Foam::polyMesh::checkVolRatio
599 const scalar minRatio,
609 label nErrorFaces = 0;
610 scalar minDet = GREAT;
619 if (volRatio[facei] < minRatio)
624 setPtr->insert(facei);
631 if (isMasterFace.test(facei))
633 minDet =
min(minDet, volRatio[facei]);
634 sumDet += volRatio[facei];
639 reduce(nErrorFaces, sumOp<label>());
640 reduce(minDet, minOp<scalar>());
641 reduce(sumDet, sumOp<scalar>());
642 reduce(nSummed, sumOp<label>());
649 meshDict.
set(
"aveFaceVolumeRatio", sumDet/nSummed);
653 Info<<
" Face volume ratio : minimum: " << minDet
654 <<
" average: " << sumDet/nSummed
661 meshDict.
set(
"thresholdFaceVolumeRatio", minRatio);
662 meshDict.
set(
"nErrorFaceVolumeRatio", nErrorFaces);
666 Info<<
" ***Faces with small volume ratio (< " << minRatio
667 <<
") found, number of faces: " 668 << nErrorFaces <<
endl;
676 Info<<
" Face volume ratio check OK." <<
endl;
683 bool Foam::polyMesh::checkFaceOrthogonality
689 return checkFaceOrthogonality
700 bool Foam::polyMesh::checkFaceSkewness
706 return checkFaceSkewness
719 bool Foam::polyMesh::checkEdgeAlignment
726 return checkEdgeAlignment
736 bool Foam::polyMesh::checkCellDeterminant
742 return checkCellDeterminant
752 bool Foam::polyMesh::checkFaceWeight
755 const scalar minWeight,
759 return checkFaceWeight
771 bool Foam::polyMesh::checkVolRatio
774 const scalar minRatio,
778 return checkVolRatio(cellVolumes(), report, minRatio, setPtr);
786 const bool detailedReport
791 Pout<<
"bool polyMesh::checkMeshMotion(" 792 <<
"const pointField&, const bool, const bool) const: " 793 <<
"checking mesh motion" <<
endl;
821 bool error = checkCellVolumes
831 bool areaError = checkFaceAreas
838 error = error || areaError;
842 bool pyrVolError = checkFacePyramids
851 error = error || pyrVolError;
855 bool nonOrthoError = checkFaceOrthogonality
863 error = error || nonOrthoError;
866 if (!error && (
debug || report))
868 Pout<<
"Mesh motion check OK." <<
endl;
const IOdictionary & meshDict
dimensionedScalar acos(const dimensionedScalar &ds)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
dimensionedTensor skew(const dimensionedTensor &dt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Unit conversion functions.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const meshState & data() const noexcept
Const reference to the mesh and solver state data.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< face > faceList
List of faces.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
dimensionedScalar cos(const dimensionedScalar &ds)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
#define DebugInFunction
Report an information message using Foam::Info.
virtual const labelList & faceOwner() const
Return face owner.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
int debug
Static debugging option.
const scalarField & cellVols
#define WarningInFunction
Report a warning using Foam::Warning.
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
List< label > labelList
A List of labels.
static scalar nonOrthThreshold_
Non-orthogonality warning threshold in deg.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dictionary & meshDict()
Return the dictionary of mesh data, typically populated by the polyMesh::checkXXX functions...
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
const volScalarField & p0
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
forAllConstIters(mixture.phases(), phase)
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)