70 const primitiveMesh&
mesh,
71 const UList<label>& faceIDs,
79 for (
const label facei : faceIDs)
81 const auto&
f = fs[facei];
89 fCtrs[facei] = tri.centre();
90 fAreas[facei] = tri.areaNormal();
108 solveVector n = (nextPoint - thisPoint)^(fCentre - thisPoint);
109 solveScalar a =
mag(
n);
117 if (sumA < ROOTVSMALL)
119 fCtrs[facei] = fCentre;
120 fAreas[facei] =
Zero;
124 fCtrs[facei] = (1.0/3.0)*sumAc/sumA;
125 fAreas[facei] = 0.5*sumN;
145 auto& cellCtrs = tcellCtrs.ref();
164 const label celli = cellIDs[i];
166 for (
const auto facei :
c)
168 Cc0[i] += fCtrs[facei];
175 Cc0[i] /= nCellFaces[i];
180 for (
const label celli : cellIDs)
182 cellCtrs[celli] =
Zero;
190 const label celli = cellIDs[i];
191 const auto&
c =
cells[celli];
194 for (
const label facei : c)
199 const solveScalar pyr3Vol = own[facei] == celli
204 const solveVector pc = (3.0/4.0)*fc + (1.0/4.0)*cc;
207 cellCtrs[celli] += pyr3Vol*pc;
220 cellCtrs[celli] = Cc0[i];
235 fCtrs.resize_nocopy(fcs.size());
236 fAreas.resize_nocopy(fcs.size());
240 const face&
f = fcs[facei];
248 fCtrs[facei] = tri.centre();
249 fAreas[facei] = tri.areaNormal();
266 solveVector n = (nextPoint - thisPoint)^(fCentre - thisPoint);
267 solveScalar a =
mag(
n);
276 if (sumA < ROOTVSMALL)
278 fCtrs[facei] = fCentre;
279 fAreas[facei] =
Zero;
283 fCtrs[facei] = (1.0/3.0)*sumAc/sumA;
284 fAreas[facei] = 0.5*sumN;
314 auto& cellCtrs = tcellCtrs.ref();
332 cEst[own[facei]] += fCtrs[facei];
333 ++nCellFaces[own[facei]];
338 cEst[nei[facei]] += fCtrs[facei];
339 ++nCellFaces[nei[facei]];
344 cEst[celli] /= nCellFaces[celli];
353 solveScalar pyr3Vol = fA & (fc - cEst[own[facei]]);
356 solveVector pc = (3.0/4.0)*fc + (1.0/4.0)*cEst[own[facei]];
359 cellCtrs[own[facei]] += pyr3Vol*pc;
371 solveScalar pyr3Vol = fA & (cEst[nei[facei]] - fc);
374 solveVector pc = (3.0/4.0)*fc + (1.0/4.0)*cEst[nei[facei]];
377 cellCtrs[nei[facei]] += pyr3Vol*pc;
391 cellCtrs[celli] = cEst[celli];
411 const face&
f = fcs[facei];
413 vector Cpf = fCtrs[facei] - ownCc;
419 - ((fAreas[facei] & Cpf)/((fAreas[facei] & d) + ROOTVSMALL))*d;
420 vector svHat = sv/(
mag(sv) + ROOTVSMALL);
425 scalar fd = 0.2*
mag(d) + ROOTVSMALL;
428 fd =
max(fd,
mag(svHat & (
p[
f[
pi]] - fCtrs[facei])));
438 const UList<face>& fcs,
447 const face&
f = fcs[facei];
449 vector Cpf = fCtrs[facei] - ownCc;
452 vector d = normal*(normal & Cpf);
457 - ((fAreas[facei] & Cpf)/((fAreas[facei] & d) + ROOTVSMALL))*d;
458 vector svHat = sv/(
mag(sv) + ROOTVSMALL);
463 scalar fd = 0.4*
mag(d) + ROOTVSMALL;
466 fd =
max(fd,
mag(svHat & (
p[
f[
pi]] - fCtrs[facei])));
476 const primitiveMesh&
mesh,
514 return (d &
s)/(
mag(d)*
mag(
s) + ROOTVSMALL);
531 auto& ortho = tortho.ref();
536 ortho[facei] = faceOrthogonality
550 const primitiveMesh&
mesh,
562 auto&
skew = tskew.ref();
565 for (label facei = 0; facei <
mesh.nInternalFaces(); ++facei)
567 skew[facei] = faceSkewness
575 cellCtrs[own[facei]],
586 skew[facei] = boundaryFaceSkewness
603 const primitiveMesh&
mesh,
615 ownPyrVol.setSize(
mesh.nFaces());
616 neiPyrVol.setSize(
mesh.nInternalFaces());
627 if (
mesh.isInternalFace(facei))
663 sumClosed[own[facei]] += areas[facei];
664 sumMagClosed[own[facei]] +=
cmptMag(areas[facei]);
670 sumClosed[nei[facei]] -= areas[facei];
671 sumMagClosed[nei[facei]] +=
cmptMag(areas[facei]);
691 scalar maxOpenness = 0;
698 mag(sumClosed[celli][cmpt])
699 /(sumMagClosed[celli][cmpt] + ROOTVSMALL)
702 openness[celli] = maxOpenness;
706 scalar minCmpt = VGREAT;
707 scalar maxCmpt = -VGREAT;
712 minCmpt =
min(minCmpt, sumMagClosed[celli][dir]);
713 maxCmpt =
max(maxCmpt, sumMagClosed[celli][dir]);
717 scalar aspectRatio = maxCmpt/(minCmpt + ROOTVSMALL);
720 scalar v =
max(ROOTVSMALL, vols[celli]);
725 1.0/6.0*
cmptSum(sumMagClosed[celli])/
pow(v, 2.0/3.0)
729 aratio[celli] = aspectRatio;
745 faceNormals /=
mag(faceNormals) + ROOTVSMALL;
748 auto&& faceAngles = tfaceAngles.ref();
752 const face&
f = fcs[facei];
756 scalar magEPrev =
mag(ePrev);
757 ePrev /= magEPrev + ROOTVSMALL;
759 scalar maxEdgeSin = 0.0;
764 vector e10(
p[
f.nextLabel(fp0)] -
p[
f.thisLabel(fp0)]);
765 scalar magE10 =
mag(e10);
766 e10 /= magE10 + ROOTVSMALL;
768 if (magEPrev > SMALL && magE10 > SMALL)
770 vector edgeNormal = ePrev ^ e10;
771 scalar magEdgeNormal =
mag(edgeNormal);
773 if (magEdgeNormal < maxSin)
780 edgeNormal /= magEdgeNormal;
782 if ((edgeNormal & faceNormals[facei]) < SMALL)
784 maxEdgeSin =
max(maxEdgeSin, magEdgeNormal);
793 faceAngles[facei] = maxEdgeSin;
802 const primitiveMesh&
mesh,
815 auto& faceFlatness = tfaceFlatness.ref();
819 const face&
f = fcs[facei];
821 if (
f.size() > 3 && magAreas[facei] > ROOTVSMALL)
828 solveScalar sumA = 0.0;
836 solveVector n = 0.5*((nextPoint - thisPoint)^(fc - thisPoint));
840 faceFlatness[facei] = magAreas[facei]/(sumA + ROOTVSMALL);
844 return tfaceFlatness;
853 const bitSet& internalOrCoupledFace
872 auto& cellDeterminant = tcellDeterminant.ref();
878 cellDeterminant = 1.0;
889 label nInternalFaces = 0;
893 if (internalOrCoupledFace.test(curFaces[i]))
895 avgArea +=
mag(faceAreas[curFaces[i]]);
901 if (nInternalFaces == 0 || avgArea < ROOTVSMALL)
903 cellDeterminant[celli] = 0;
907 avgArea /= nInternalFaces;
913 if (internalOrCoupledFace.test(curFaces[i]))
915 areaTensor +=
sqr(faceAreas[curFaces[i]]/avgArea);
945 cellDeterminant[celli] =
mag(
det(areaTensor))/8.0;
950 return tcellDeterminant;
constexpr scalar pi(M_PI)
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void setSize(label n)
Alias for resize().
A non-const Field/List wrapper with possible data conversion.
const Cmpt & yy() const noexcept
const Cmpt & xx() const noexcept
const Cmpt & zz() const noexcept
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
static constexpr direction nComponents
Number of components in this vector space.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
A cell is defined as a list of faces with extra functionality.
A face is a list of labels corresponding to mesh vertices.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Cell-face mesh analysis engine.
label nInternalFaces() const noexcept
Number of internal faces.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
const cellList & cells() const
scalar mag(const UList< point > &points) const
Return scalar magnitude - returns volume of pyramid.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
static vector areaNormal(const Point &p0, const Point &p1, const Point &p2)
The area normal for a triangle defined by three points (right-hand rule). Magnitude equal to area of ...
static Point centre(const Point &p0, const Point &p1, const Point &p2)
The centre (centroid) of three points.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar c
Speed of light in a vacuum.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
static Foam::doubleVector pointsAverage(const UList< point > &points, const labelUList &pointLabels)
List< face > faceList
List of faces.
Cmpt cmptSum(const SphericalTensor< Cmpt > &st)
Return the sum of components of a SphericalTensor.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
List< cell > cellList
List of cell.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Vector< double > doubleVector
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
pyramid< point, const point &, const face & > pyramidPointFaceRef
A pyramid using referred point and face.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Field< label > labelField
Specialisation of Field<T> for label.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
triangle< point, const point & > triPointRef
A triangle using referred points.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Vector< solveScalar > solveVector
dimensionedTensor skew(const dimensionedTensor &dt)
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
labelList pointLabels(nPoints, -1)
#define forAll(list, i)
Loop across all elements in list.
const scalarField & cellVols