45 setHoleCellValue_(false),
46 fluxCorrection_(false),
47 interpolateHoleCellValue_(false),
67 setHoleCellValue_(ptf.setHoleCellValue_),
68 fluxCorrection_(ptf.fluxCorrection_),
69 interpolateHoleCellValue_(ptf.interpolateHoleCellValue_),
70 holeCellValue_(ptf.holeCellValue_),
71 fringeUpperCoeffs_(ptf.fringeUpperCoeffs_),
72 fringeLowerCoeffs_(ptf.fringeLowerCoeffs_),
73 fringeFaces_(ptf.fringeFaces_),
88 setHoleCellValue_(
dict.getOrDefault(
"setHoleCellValue", false)),
91 dict.getOrDefaultCompat
94 {{
"massCorrection", 2206}},
98 interpolateHoleCellValue_
105 ?
dict.
get<Type>(
"holeCellValue")
108 fringeUpperCoeffs_(),
109 fringeLowerCoeffs_(),
130 const oversetFvPatchField<Type>& ptf
133 coupledFvPatchField<Type>(ptf),
134 oversetPatch_(ptf.oversetPatch_),
135 setHoleCellValue_(ptf.setHoleCellValue_),
136 fluxCorrection_(ptf.fluxCorrection_),
137 interpolateHoleCellValue_(ptf.interpolateHoleCellValue_),
138 holeCellValue_(ptf.holeCellValue_),
139 fringeUpperCoeffs_(ptf.fringeUpperCoeffs_),
140 fringeLowerCoeffs_(ptf.fringeLowerCoeffs_),
141 fringeFaces_(ptf.fringeFaces_),
154 oversetPatch_(ptf.oversetPatch_),
155 setHoleCellValue_(ptf.setHoleCellValue_),
156 fluxCorrection_(ptf.fluxCorrection_),
157 interpolateHoleCellValue_(ptf.interpolateHoleCellValue_),
158 holeCellValue_(ptf.holeCellValue_),
159 fringeUpperCoeffs_(ptf.fringeUpperCoeffs_),
160 fringeLowerCoeffs_(ptf.fringeLowerCoeffs_),
161 fringeFaces_(ptf.fringeFaces_),
174 const fvMesh&
mesh = this->internalField().mesh();
184 label fringesFaces = 0;
188 const label zonei = zoneID[own[facei]];
190 const label ownType =
cellTypes[own[facei]];
191 const label neiType =
cellTypes[nei[facei]];
201 const bool ownNei = (ownCalc || neiCalc);
205 (ownNei && (zonei == zoneId_)) || (ownNei && (zoneId_ == -1))
219 const fvPatch& curPatch =
patches[patchi];
223 const label start = curPatch.start();
227 const label facei = start + i;
228 const label celli = fc[i];
232 const label zonei = zoneID[celli];
239 if (ownCalc && (zonei == zoneId_))
247 fringeLowerCoeffs_.setSize(fringesFaces,
Zero);
248 fringeFaces_.setSize(fringesFaces, -1);
256 const label zonei = zoneID[own[facei]];
258 const label ownType =
cellTypes[own[facei]];
259 const label neiType =
cellTypes[nei[facei]];
269 const bool ownNei = (ownCalc || neiCalc);
273 (ownNei && (zonei == zoneId_)) || (ownNei && (zoneId_ == -1))
276 fringeUpperCoeffs_[fringesFaces] =
upper[facei];
277 fringeLowerCoeffs_[fringesFaces] =
lower[facei];
278 fringeFaces_[fringesFaces] = facei;
283 forAll(boundaryMesh, patchi)
285 const polyPatch&
p = boundaryMesh[patchi];
287 if (isA<coupledPolyPatch>(
p))
290 const label start =
p.start();
294 const label facei = start + i;
295 const label celli = fc[i];
299 const label zonei = zoneID[celli];
309 if ((ownCalc||neiCalc) && (zonei == zoneId_))
311 fringeLowerCoeffs_[fringesFaces] =
318 fringeUpperCoeffs_[fringesFaces] =
325 fringeFaces_[fringesFaces] = facei;
338 const fvMatrix<Type>& matrix,
345 const Field<Type>&
psi = matrix.psi();
350 if (this->oversetPatch_.master())
352 const fvMesh&
mesh = this->internalField().mesh();
361 label fringesFaces = 0;
364 const label zonei = zoneID[own[facei]];
366 const label ownType =
cellTypes[own[facei]];
367 const label neiType =
cellTypes[nei[facei]];
377 const bool ownNei = (ownCalc || neiCalc);
381 (ownNei && (zonei == zoneId_)) || (ownNei && (zoneId_ == -1))
384 const label fringei = fringeFaces_[fringesFaces];
390 const scalar& ufc =
upper[fringei];
391 const scalar& lfc =
lower[fringei];
394 ufc*
psi[nei[fringei]] - lfc*
psi[own[fringei]];
398 phiIn -=
phi[fringei];
403 phiIn +=
phi[fringei];
411 reduce(massIn, sumOp<scalar>());
412 reduce(phiIn, sumOp<scalar>());
415 Info <<
" gSum(p.flux) on fringes " << massIn <<
endl;
427 const fvMesh&
mesh = this->internalField().mesh();
439 scalar offDiagCoeffs = 0;
446 label fringesFaces = 0;
450 const label zonei = zoneID[own[facei]];
452 const label ownType =
cellTypes[own[facei]];
453 const label neiType =
cellTypes[nei[facei]];
463 const bool ownNei = (ownCalc || neiCalc);
467 (ownNei && (zonei == zoneId_)) || (ownNei && (zoneId_ == -1))
471 const scalar& ufc = fringeUpperCoeffs_[fringesFaces];
472 const scalar& lfc = fringeLowerCoeffs_[fringesFaces];
474 const scalar curFlux =
475 ufc*
psi[nei[facei]] - lfc*
psi[own[facei]];
480 offDiagCoeffs += lfc;
481 facePerCell[own[facei]]++;
486 offDiagCoeffs += ufc;
487 facePerCell[nei[facei]]++;
494 scalarField weights(facePerCell.size(), scalar(1));
497 if (facePerCell[celli] > 1)
499 weights[celli] = scalar(1)/facePerCell[celli];
509 forAll(boundaryMesh, patchi)
513 if (isA<coupledPolyPatch>(
p))
515 const auto& coupledPatch = refCast<const coupledPolyPatch>(
p);
518 const label start =
p.start();
522 const label facei = start + i;
523 const label celli = fc[i];
527 const label zonei = zoneID[celli];
537 if ((ownCalc||neiCalc) && (zonei == zoneId_))
539 const scalar psiOwn =
psi[celli];
540 const scalar& lfc = fringeLowerCoeffs_[fringesFaces];
541 const scalar curFlux = lfc*psiOwn;
547 if (coupledPatch.owner())
549 offDiagCoeffs -= lfc;
558 if (coupledPatch.owner())
560 offDiagCoeffs -= lfc;
570 reduce(massIn, sumOp<scalar>());
571 reduce(offDiagCoeffs, sumOp<scalar>());
573 scalar psiCorr = -massIn/offDiagCoeffs;
578 const label zonei = zoneID[celli];
581 (bInter && (zonei == zoneId_)) ||(bInter && (zoneId_ == -1))
584 psi[celli] += psiCorr;
594 return tmp<Field<Type>>
607 if (this->oversetPatch_.master())
610 const fvMesh&
mesh = this->internalField().mesh();
612 const word& fldName = this->internalField().name();
621 Info<<
"Skipping overset interpolation for solved-for field " 625 else if (!fvSchemes.
found(
"oversetInterpolation"))
628 <<
"Missing required dictionary entry" 629 <<
" 'oversetInterpolation'" 630 <<
". Skipping overset interpolation for field " 633 else if (fvSchemes.
found(
"oversetInterpolationRequired"))
638 if (fvSchemes.
found(
"oversetInterpolationSuppressed"))
641 <<
"Cannot have both dictionary entry" 642 <<
" 'oversetInterpolationSuppresed' and " 643 <<
" 'oversetInterpolationRequired' for field " 646 const dictionary& intDict = fvSchemes.
subDict 648 "oversetInterpolationRequired" 650 if (intDict.found(fldName))
654 Info<<
"Interpolating field " << fldName <<
endl;
664 const_cast<Field<Type>&
> 666 this->primitiveField()
672 Info<<
"Skipping overset interpolation for field " 678 const dictionary* dictPtr
680 fvSchemes.
findDict(
"oversetInterpolationSuppressed")
686 bool skipInterpolate = suppress.found(fldName);
692 || dictPtr->found(fldName);
699 Info<<
"Skipping suppressed overset interpolation" 700 <<
" for field " << fldName <<
endl;
707 Info<<
"Interpolating non-suppressed field " << fldName
720 const_cast<Field<Type>&
>(this->primitiveField());
731 if (this->setHoleCellValue_)
734 label nConstrained = 0;
737 const label cType = types[celli];
744 fld[celli] = this->holeCellValue_;
752 <<
" patch:" << this->oversetPatch_.name()
753 <<
" set:" << nConstrained <<
" cells to:" 754 << this->holeCellValue_ <<
endl;
771 if (this->manipulatedMatrix())
776 const oversetFvPatch& ovp = this->oversetPatch_;
780 if (fluxCorrection_ || (
debug & 2))
782 storeFringeCoefficients(matrix);
786 const fvMesh&
mesh = this->internalField().mesh();
787 const word& fldName = this->internalField().name();
799 <<
" patch:" << ovp.name() <<
endl;
806 dynamic_cast<const oversetFvMeshBase&>(
mesh).normalisation(matrix)
813 dynamic_cast<const oversetFvMeshBase&
>(
mesh).addInterpolation
817 this->setHoleCellValue_,
829 scalarField marker(this->primitiveField().size(), 0);
850 && marker[celli] > SMALL
854 <<
" field:" << fldName
855 <<
" patch:" << ovp.name()
856 <<
" found:" << celli
858 <<
" donorSlots:" << stencil[celli]
860 << UIndirectList<point>(allCs, stencil[celli])
861 <<
" amount-of-hole:" << marker[celli]
870 const labelUList& upperAddr = addr.upperAddr();
871 const labelUList& lowerAddr = addr.lowerAddr();
877 const label l = lowerAddr[facei];
879 const label u = upperAddr[facei];
884 (lHole &&
upper[facei] != 0.0)
885 || (uHole &&
lower[facei] != 0.0)
889 <<
"Hole-neighbouring face:" << facei
891 <<
" type:" << types[l]
892 <<
" coeff:" <<
lower[facei]
893 <<
" upper:" << upperAddr[facei]
894 <<
" type:" << types[u]
895 <<
" coeff:" <<
upper[facei]
905 && stencil[l].empty()
910 && stencil[u].empty()
915 (lEmpty &&
upper[facei] != 0.0)
916 || (uEmpty &&
lower[facei] != 0.0)
920 <<
"Still connected face:" << facei <<
" lower:" << l
921 <<
" type:" << types[l]
922 <<
" coeff:" <<
lower[facei]
924 <<
" type:" << types[u]
925 <<
" coeff:" <<
upper[facei]
932 const labelUList& fc = addr.patchAddr(patchi);
937 const label celli = fc[i];
940 if (lHole && bouCoeffs[i] != pTraits<Type>::zero)
943 <<
"Patch:" << patchi
944 <<
" patchFace:" << i
945 <<
" lower:" << celli
946 <<
" type:" << types[celli]
947 <<
" bouCoeff:" << bouCoeffs[i]
955 && stencil[celli].empty()
958 if (lEmpty && bouCoeffs[i] != pTraits<Type>::zero)
961 <<
"Patch:" << patchi
962 <<
" patchFace:" << i
963 <<
" lower:" << celli
964 <<
" type:" << types[celli]
965 <<
" bouCoeff:" << bouCoeffs[i]
974 const FieldField<Field, Type>& internalCoeffs =
977 for (
direction cmpt=0; cmpt<pTraits<Type>::nComponents; ++cmpt)
981 forAll(internalCoeffs, patchi)
983 const labelUList& fc = addr.patchAddr(patchi);
984 const Field<Type>& intCoeffs = internalCoeffs[patchi];
985 const scalarField cmptCoeffs(intCoeffs.component(cmpt));
988 diag[fc[i]] += cmptCoeffs[i];
997 <<
"Patch:" << ovp.name()
1000 <<
" diag:" <<
diag[celli]
1012 template<
class Type>
1018 const label interfacei,
1028 template<
class Type>
1043 if (fluxCorrection_ && this->oversetPatch_.master())
1045 adjustPsi(
psi, lduAddr, result);
1050 template<
class Type>
1055 if (this->setHoleCellValue_)
1061 "interpolateHoleCellValue",
1063 interpolateHoleCellValue_
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
List< labelList > labelListList
A List of labelList.
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
commsTypes
Types of communications.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void fringeFlux(const fvMatrix< Type > &m, const surfaceScalarField &phi) const
Calculate patch flux (helper function). Requires.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Type & refCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts, uses the virtual type() me...
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field. Dummy.
A traits class, which is primarily used for primitives.
Patch for indicating interpolated boundaries (in overset meshes).
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
static int & msgType() noexcept
Message tag of standard messages.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
virtual void interpolate(volScalarField &) const
Interpolate interpolationCells only.
static void interpolate(Field< T > &psi, const fvMesh &mesh, const cellCellStencil &overlap, const List< scalarList > &wghts)
Interpolation of acceptor cells from donor cells.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
UList< label > labelUList
A UList of labels.
virtual const labelUList & cellTypes() const
Return the cell type list.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
const labelUList & neighbour() const
Internal face neighbour.
#define forAll(list, i)
Loop across all elements in list.
virtual void write(Ostream &) const
Write.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
friend Ostream & operator(Ostream &, const Field< Type > &)
void storeFringeCoefficients(const fvMatrix< Type > &matrix)
Store fringe coefficients and faces.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
virtual const labelListList & cellStencil() const
Per interpolated cell the neighbour cells (in terms of slots as.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
A FieldMapper for finite-volume patch fields.
const cellCellStencilObject & overlap
virtual const List< scalarList > & cellInterpolationWeights() const
Weights for cellStencil.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
const dictionary & schemesDict() const
The current schemes dictionary, respects the "select" keyword.
virtual void initInterfaceMatrixUpdate(Field< Type > &, const bool add, const lduAddressing &, const label interfacei, const Field< Type > &, const scalarField &, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
label nInternalFaces() const noexcept
Number of internal faces.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Abstract base class for coupled patches.
const labelList & cellTypes
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
oversetFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
void adjustPsi(solveScalarField &psi, const lduAddressing &lduAddr, solveScalarField &result) const
Adjust psi for mass correction. Requires storeFringeCoefficients.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
void operator=(const Field< Type > &)
Copy assignment.
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Selector class for finite volume differencing schemes. fvMesh is derived from fvSchemes so that all f...
Mesh data needed to do the Finite Volume discretisation.
virtual const mapDistribute & cellInterpolationMap() const
Return a communication schedule.
const polyBoundaryMesh & patches
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
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.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const FieldField< Field, Type > & internalCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for internal cells
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const volScalarField & psi
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const FieldField< Field, Type > & boundaryCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for boundary cells
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
virtual void write(Ostream &os) const
Write.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
A class for managing temporary objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
static const labelIOList & zoneID(const fvMesh &)
Helper: get reference to registered zoneID. Loads volScalarField.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
PtrList< fvPatch > fvPatchList
Store lists of fvPatch as a PtrList.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and a sub-dictionary) otherwise return nullptr...
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)