66 if (!weightingFactorsPtr_)
71 return (*weightingFactorsPtr_);
77 if (!differenceFactorsPtr_)
82 return (*differenceFactorsPtr_);
88 if (orthogonal_ ==
false && !correctionVectorsPtr_)
90 makeCorrectionVectors();
106 mesh().pointsInstance(),
114 return (*correctionVectorsPtr_);
120 if (skew_ ==
true && !skewCorrectionVectorsPtr_)
122 makeSkewCorrectionVectors();
138 "skewCorrectionVectors",
139 mesh().pointsInstance(),
147 return (*skewCorrectionVectorsPtr_);
153 lPNptr_.reset(
nullptr);
154 weightingFactorsPtr_.reset(
nullptr);
155 differenceFactorsPtr_.reset(
nullptr);
158 correctionVectorsPtr_.reset(
nullptr);
161 skewCorrectionVectorsPtr_.reset(
nullptr);
167 const Foam::vector& Foam::edgeInterpolation::skewCorr(
const label edgeI)
const 169 #ifdef FA_SKEW_CORRECTION 173 skewCorrectionVectorsPtr_
174 ? (*skewCorrectionVectorsPtr_)[edgeI]
175 : pTraits<vector>::zero
180 return (*skewCorrectionVectorsPtr_)[edgeI];
186 void Foam::edgeInterpolation::makeLPN()
const 189 <<
"Constructing geodesic distance between points P and N" 193 lPNptr_ = std::make_unique<edgeScalarField>
198 mesh().time().constant(),
222 const vector& skewCorrEdge = skewCorr(edgeI);
229 - faceCentres[owner[edgeI]]
235 faceCentres[neighbour[edgeI]]
240 lPNIn[edgeI] = (lPE + lEN);
243 if (
mag(lPNIn[edgeI]) < SMALL)
245 lPNIn[edgeI] = SMALL;
250 forAll(lPN.boundaryField(), patchI)
254 lPN.boundaryFieldRef()[patchI]
260 <<
"Finished constructing geodesic distance PN" 265 void Foam::edgeInterpolation::makeWeights()
const 268 <<
"Constructing weighting factors for edge interpolation" 272 weightingFactorsPtr_ = std::make_unique<edgeScalarField>
277 mesh().pointsInstance(),
295 scalarField& weightingFactorsIn = weightingFactors.primitiveFieldRef();
302 const vector& skewCorrEdge = skewCorr(edgeI);
309 - faceCentres[owner[edgeI]]
315 faceCentres[neighbour[edgeI]]
321 const scalar lPN = lPE + lEN;
323 if (
mag(lPN) > SMALL)
325 weightingFactorsIn[edgeI] = lEN/lPN;
333 weightingFactors.boundaryFieldRef()[patchI]
338 <<
"Finished constructing weighting factors for face interpolation" 343 void Foam::edgeInterpolation::makeDeltaCoeffs()
const 346 <<
"Constructing differencing factors array for edge gradient" 353 differenceFactorsPtr_ = std::make_unique<edgeScalarField>
358 mesh().pointsInstance(),
391 faceCentres[neighbour[edgeI]]
392 - faceCentres[owner[edgeI]];
398 const vector& skewCorrEdge = skewCorr(edgeI);
405 - faceCentres[owner[edgeI]]
411 faceCentres[neighbour[edgeI]]
416 scalar lPN = lPE + lEN;
423 const scalar
alpha = lPN*(unitDelta & edgeNormal);
426 dc[edgeI] = scalar(1)/
max(
alpha, 0.05*lPN);
431 forAll(DeltaCoeffs.boundaryField(), patchI)
435 DeltaCoeffs.boundaryFieldRef()[patchI]
441 void Foam::edgeInterpolation::makeCorrectionVectors()
const 444 <<
"Constructing non-orthogonal correction vectors" 447 correctionVectorsPtr_ = std::make_unique<edgeVectorField>
452 mesh().pointsInstance(),
476 vectorField& CorrVecsIn = CorrVecs.primitiveFieldRef();
486 faceCentres[neighbour[edgeI]]
487 - faceCentres[owner[edgeI]];
496 const scalar
alpha = unitDelta & edgeNormal;
499 deltaCoeffs[edgeI] = scalar(1)/
alpha;
505 - deltaCoeffs[edgeI]*unitDelta;
511 forAll(CorrVecs.boundaryField(), patchI)
513 mesh().
boundary()[patchI].makeCorrectionVectors(CorrVecsbf[patchI]);
518 <<
"Finished constructing non-orthogonal correction vectors" 523 void Foam::edgeInterpolation::makeSkewCorrectionVectors()
const 526 <<
"Constructing skew correction vectors" 529 skewCorrectionVectorsPtr_ = std::make_unique<edgeVectorField>
533 "skewCorrectionVectors",
534 mesh().pointsInstance(),
558 const vector& P =
C[owner[edgeI]];
559 const vector&
N =
C[neighbour[edgeI]];
573 const scalar
beta = -((d^(S - P)) & de)/
alpha;
578 SkewCorrVecs[edgeI] = Ce[edgeI] - E;
583 SkewCorrVecs.boundaryFieldRef();
585 forAll(SkewCorrVecs.boundaryField(), patchI)
589 if (patchSkewCorrVecs.coupled())
599 forAll(patchSkewCorrVecs, edgeI)
601 const vector& P =
C[edgeFaces[edgeI]];
616 const scalar
beta = -((d^(S - P)) & de)/
alpha;
620 patchSkewCorrVecs[edgeI] =
621 Ce.boundaryField()[patchI][edgeI] - E;
626 #ifdef FA_SKEW_CORRECTION 628 constexpr scalar maxSkewRatio = 0.1;
629 scalar skewCoeff = 0;
633 const scalar magSkew =
mag(skewCorrVecs[edgeI]);
639 - skewCorrVecs[edgeI]
646 + skewCorrVecs[edgeI]
649 const scalar ratio = magSkew/lPN;
651 if (skewCoeff < ratio)
655 if (skewCoeff > maxSkewRatio)
663 <<
"skew coefficient = " << skewCoeff <<
endl;
665 if (skewCoeff < maxSkewRatio)
667 skewCorrectionVectorsPtr_.reset(
nullptr);
672 skew_ = bool(skewCorrectionVectorsPtr_);
676 <<
"Finished constructing skew correction vectors"
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
const edgeVectorField & skewCorrectionVectors() const
Return reference to skew vectors array.
const edgeScalarField & weights() const
Return reference to weighting factors array.
const edgeScalarField & deltaCoeffs() const
Return reference to difference factors array.
const edgeVectorField & correctionVectors() const
Return reference to non-orthogonality correction vectors array.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< edge > edgeList
List of edge.
dimensionedTensor skew(const dimensionedTensor &dt)
edgeInterpolation(const edgeInterpolation &)=delete
No copy construct.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Face to edge interpolation scheme. Included in faMesh.
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
GeometricBoundaryField< Type, PatchField, GeoMesh > Boundary
Type of boundary fields.
SubList< edge > subList
Declare type of subList.
Ignore writing from objectRegistry::writeObject()
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
const dimensionSet dimless
Dimensionless.
bool movePoints() const
Do what is necessary if the mesh has moved.
const edgeScalarField & lPN() const
Return reference to PN geodesic distance.
UList< label > labelUList
A UList of labels.
const labelUList & neighbour() const
Internal face neighbour.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ const Field< vector > edgeCentres(faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true))
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
#define DebugInFunction
Report an information message using Foam::Info.
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
bool orthogonal() const
Return whether mesh is orthogonal or not.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
defineTypeNameAndDebug(combustionModel, 0)
bool skew() const
Return whether mesh is skew or not.
const Vector< label > N(dict.get< Vector< label >>("N"))
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
faePatchField< vector > faePatchVectorField
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Field< vector > vectorField
Specialisation of Field<T> for vector.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
Inplace removal of components that are collinear to the given unit vector.
Calculate the matrix for the second temporal derivative.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Do not request registration (bool: false)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)