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);
167const Foam::vector& Foam::edgeInterpolation::skewCorr(
const label edgeI)
const
169 #ifdef FA_SKEW_CORRECTION
173 skewCorrectionVectorsPtr_
174 ? (*skewCorrectionVectorsPtr_)[edgeI]
180 return (*skewCorrectionVectorsPtr_)[edgeI];
186void Foam::edgeInterpolation::makeLPN()
const
189 <<
"Constructing geodesic distance between points P and N"
193 lPNptr_ = std::make_unique<edgeScalarField>
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"
265void 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"
343void 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]];
394 unitDelta.removeCollinear(edgeNormal);
395 unitDelta.normalise();
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]
441void 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]];
489 unitDelta.removeCollinear(edgeNormal);
490 unitDelta.normalise();
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"
523void 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())
597 vectorField ngbC(
C.boundaryField()[patchI].patchNeighbourField());
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"
Info<< " "<< writer.output().name()<< nl;}{ const Field< vector > edgeCentres(faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true))
Graphite solid properties.
GeometricBoundaryField< vector, faePatchField, edgeMesh > Boundary
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Face to edge interpolation scheme. Included in faMesh.
bool movePoints() const
Do what is necessary if the mesh has moved.
edgeInterpolation(const edgeInterpolation &)=delete
No copy construct.
const edgeScalarField & deltaCoeffs() const
Return reference to difference factors array.
const edgeVectorField & correctionVectors() const
Return reference to non-orthogonality correction vectors array.
bool orthogonal() const
Return whether mesh is orthogonal or not.
const edgeScalarField & lPN() const
Return reference to PN geodesic distance.
const edgeScalarField & weights() const
Return reference to weighting factors array.
bool skew() const
Return whether mesh is skew or not.
const edgeVectorField & skewCorrectionVectors() const
Return reference to skew vectors array.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
const labelUList & neighbour() const
Internal face neighbour.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
A traits class, which is primarily used for primitives and vector-space.
constant condensation/saturation model.
virtual const pointField & points() const
Return raw points.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define DebugInFunction
Report an information message using Foam::Info.
Different types of constants.
List< edge > edgeList
List of edge.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
const dimensionSet dimless
Dimensionless.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
faePatchField< vector > faePatchVectorField
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
UList< label > labelUList
A UList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionedTensor skew(const dimensionedTensor &dt)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Calculate the matrix for the second temporal derivative.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
const Vector< label > N(dict.get< Vector< label > >("N"))