60 weightingFactors_(nullptr),
61 differenceFactors_(nullptr),
62 correctionVectors_(nullptr),
63 skewCorrectionVectors_(nullptr),
92 if (!weightingFactors_)
97 return (*weightingFactors_);
103 if (!differenceFactors_)
108 return (*differenceFactors_);
114 if (orthogonal_ ==
false && !correctionVectors_)
116 makeCorrectionVectors();
128 <<
"cannot return correctionVectors; mesh is orthogonal" 132 return (*correctionVectors_);
138 if (skew_ ==
true && !skewCorrectionVectors_)
140 makeSkewCorrectionVectors();
153 <<
"cannot return skewCorrectionVectors; mesh is now skewed" 157 return (*skewCorrectionVectors_);
177 const Foam::vector& Foam::edgeInterpolation::skewCorr(
const label edgeI)
const 179 #ifdef FA_SKEW_CORRECTION 183 skewCorrectionVectors_
184 ? (*skewCorrectionVectors_)[edgeI]
185 : pTraits<vector>::zero
190 return (*skewCorrectionVectors_)[edgeI];
196 void Foam::edgeInterpolation::makeLPN()
const 199 <<
"Constructing geodesic distance between points P and N" 208 mesh().time().constant(),
232 const vector& skewCorrEdge = skewCorr(edgeI);
239 - faceCentres[owner[edgeI]]
245 faceCentres[neighbour[edgeI]]
250 lPNIn[edgeI] = (lPE + lEN);
253 if (
mag(lPNIn[edgeI]) < SMALL)
255 lPNIn[edgeI] = SMALL;
260 forAll(lPN.boundaryField(), patchI)
264 lPN.boundaryFieldRef()[patchI]
267 lPN.boundaryFieldRef()[patchI] = 1.0/lPN.boundaryField()[patchI];
272 <<
"Finished constructing geodesic distance PN" 277 void Foam::edgeInterpolation::makeWeights()
const 280 <<
"Constructing weighting factors for edge interpolation" 289 mesh().pointsInstance(),
307 scalarField& weightingFactorsIn = weightingFactors.primitiveFieldRef();
314 const vector& skewCorrEdge = skewCorr(edgeI);
321 - faceCentres[owner[edgeI]]
327 faceCentres[neighbour[edgeI]]
333 const scalar lPN = lPE + lEN;
334 if (
mag(lPN) > SMALL)
336 weightingFactorsIn[edgeI] = lEN/lPN;
344 weightingFactors.boundaryFieldRef()[patchI]
349 <<
"Finished constructing weighting factors for face interpolation" 354 void Foam::edgeInterpolation::makeDeltaCoeffs()
const 357 <<
"Constructing differencing factors array for edge gradient" 368 "differenceFactors_",
369 mesh().pointsInstance(),
402 faceCentres[neighbour[edgeI]]
403 - faceCentres[owner[edgeI]];
409 const vector& skewCorrEdge = skewCorr(edgeI);
416 - faceCentres[owner[edgeI]]
422 faceCentres[neighbour[edgeI]]
427 scalar lPN = lPE + lEN;
434 const scalar
alpha = lPN*(unitDelta & edgeNormal);
437 dc[edgeI] = scalar(1)/
max(
alpha, 0.05*lPN);
442 forAll(DeltaCoeffs.boundaryField(), patchI)
446 DeltaCoeffs.boundaryFieldRef()[patchI]
452 void Foam::edgeInterpolation::makeCorrectionVectors()
const 455 <<
"Constructing non-orthogonal correction vectors" 463 mesh().pointsInstance(),
487 vectorField& CorrVecsIn = CorrVecs.primitiveFieldRef();
497 faceCentres[neighbour[edgeI]]
498 - faceCentres[owner[edgeI]];
507 const scalar
alpha = unitDelta & edgeNormal;
510 deltaCoeffs[edgeI] = scalar(1)/
alpha;
516 - deltaCoeffs[edgeI]*unitDelta;
522 forAll(CorrVecs.boundaryField(), patchI)
524 mesh().
boundary()[patchI].makeCorrectionVectors(CorrVecsbf[patchI]);
527 scalar NonOrthogCoeff = 0.0;
529 if (owner.size() > 0)
532 sinAlpha.clamp_range(-1, 1);
537 reduce(NonOrthogCoeff, maxOp<scalar>());
540 <<
"non-orthogonality coefficient = " << NonOrthogCoeff <<
" deg." 543 if (NonOrthogCoeff < 0.1)
554 <<
"Finished constructing non-orthogonal correction vectors" 559 void Foam::edgeInterpolation::makeSkewCorrectionVectors()
const 562 <<
"Constructing skew correction vectors" 569 "skewCorrectionVectors",
570 mesh().pointsInstance(),
594 const vector& P =
C[owner[edgeI]];
595 const vector&
N =
C[neighbour[edgeI]];
609 const scalar
beta = -((d^(S - P)) & de)/
alpha;
614 SkewCorrVecs[edgeI] = Ce[edgeI] - E;
619 SkewCorrVecs.boundaryFieldRef();
621 forAll(SkewCorrVecs.boundaryField(), patchI)
625 if (patchSkewCorrVecs.coupled())
635 forAll(patchSkewCorrVecs, edgeI)
637 const vector& P =
C[edgeFaces[edgeI]];
652 const scalar
beta = -((d^(S - P)) & de)/
alpha;
656 patchSkewCorrVecs[edgeI] =
657 Ce.boundaryField()[patchI][edgeI] - E;
662 #ifdef FA_SKEW_CORRECTION 664 constexpr scalar maxSkewRatio = 0.1;
665 scalar skewCoeff = 0;
669 const scalar magSkew =
mag(skewCorrVecs[edgeI]);
675 - skewCorrVecs[edgeI]
682 + skewCorrVecs[edgeI]
685 const scalar ratio = magSkew/lPN;
687 if (skewCoeff < ratio)
691 if (skewCoeff > maxSkewRatio)
699 <<
"skew coefficient = " << skewCoeff <<
endl;
701 if (skewCoeff < maxSkewRatio)
708 skew_ = bool(skewCorrectionVectors_);
712 <<
"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)
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.
List< edge > edgeList
List of edge.
dimensionedTensor skew(const dimensionedTensor &dt)
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.
dimensionedScalar asin(const dimensionedScalar &ds)
UList< label > labelUList
A UList of labels.
Declarations for faPatchField types.
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))
void clearOut()
Clear all geometry and addressing.
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.
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
errorManip< error > abort(error &err)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
defineTypeNameAndDebug(combustionModel, 0)
~edgeInterpolation()
Destructor.
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.
Template functions to aid in the implementation of demand driven data.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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.
edgeInterpolation(const faMesh &)
Construct given an faMesh.
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.
void deleteDemandDrivenData(DataPtr &dataPtr)
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)