mappedPatchBase: Rationalised the names of mapping functions

to improve code comprehensibility:

    distribute -> fromNeigbour
    reverseDistribute -> toNeigbour
This commit is contained in:
Henry Weller
2023-03-10 15:10:12 +00:00
parent 5b9fe57c23
commit b3231229f4
17 changed files with 93 additions and 82 deletions

View File

@ -144,32 +144,41 @@ void VoFPatchTransfer::correct
// Do not correct if no patches selected
if (!patchIDs_.size()) return;
// Film properties
const thermoSurfaceFilm& film = filmType<thermoSurfaceFilm>();
const scalarField& delta = film.delta();
const scalarField& rho = film.rho();
const vectorField& U = film.U();
const scalarField& he = film.thermo().he();
const scalarField& magSf = film.magSf();
const polyBoundaryMesh& pbm = film.mesh().boundaryMesh();
// Primary region properties
const fvMesh& primaryMesh = film.primaryMesh();
const compressibleTwoPhaseVoFMixture& thermo
(
film.primaryMesh().lookupObject<compressibleTwoPhaseVoFMixture>
primaryMesh.lookupObject<compressibleTwoPhaseVoFMixture>
(
"phaseProperties"
)
);
const volVectorField& UVoF
(
film.primaryMesh().lookupObject<volVectorField>("U")
);
const volScalarField& alphaVoF = thermo.alpha1();
const volScalarField& rhoVoF = thermo.thermo1().rho()();
const volScalarField& heVoF = thermo.thermo1().he();
const volVectorField& UVoF
(
primaryMesh.lookupObject<volVectorField>("U")
);
forAll(patchIDs_, pidi)
{
const label patchi = patchIDs_[pidi];
@ -192,7 +201,7 @@ void VoFPatchTransfer::correct
film.toFilm
(
patchi,
film.primaryMesh().boundary()[primaryPatchi].deltaCoeffs()
primaryMesh.boundary()[primaryPatchi].deltaCoeffs()
)
);
@ -221,17 +230,14 @@ void VoFPatchTransfer::correct
film.toFilm
(
patchi,
film.primaryMesh().boundary()[primaryPatchi]
.patchInternalField(film.primaryMesh().V())
primaryMesh.boundary()[primaryPatchi]
.patchInternalField(primaryMesh.V())
)
);
const polyPatch& pp = pbm[patchi];
const labelList& faceCells = pp.faceCells();
const vectorField& U = film.U();
const scalarField& he = film.thermo().he();
// Accumulate the total mass removed from patch
scalar dMassPatch = 0;

View File

@ -72,8 +72,8 @@ Foam::solvers::isothermalFilm::contactForce(const volScalarField& sigma) const
}
// Filter for film wall and surface patches
labelHashSet wallSurfacePatches(wallPatchIDs);
wallSurfacePatches.insert(surfacePatchIDs);
labelHashSet wallAndSurfacePatches(wallPatchIDs);
wallAndSurfacePatches.insert(surfacePatchID);
const volScalarField::Boundary& deltaBf = delta.boundaryField();
@ -82,7 +82,7 @@ Foam::solvers::isothermalFilm::contactForce(const volScalarField& sigma) const
const fvPatch& p(mesh.boundary()[patchi]);
// For internal coupled patches
if (p.coupled() && !wallSurfacePatches.found(patchi))
if (p.coupled() && !wallAndSurfacePatches.found(patchi))
{
tmp<scalarField> tdeltan = deltaBf[patchi].patchNeighbourField();
const scalarField& deltan = tdeltan();

View File

@ -129,7 +129,7 @@ void Foam::filmSurfaceVelocityFvPatchVectorField::updateCoeffs()
);
// Set the reference value to the neighbouring fluid internal velocity
refValue() = mpp.distribute(UpNbr);
refValue() = mpp.fromNeigbour(UpNbr);
// Remove the normal component of the surface vel
const vectorField n(patch().nf());
@ -164,7 +164,7 @@ void Foam::filmSurfaceVelocityFvPatchVectorField::updateCoeffs()
// Get the patch laminar viscosity
const tmp<scalarField> nuEffByDeltaNbr
(
mpp.distribute
mpp.fromNeigbour
(
transportModelNbr.nuEff(patchiNbr)*patchNbr.deltaCoeffs()
)

View File

@ -152,10 +152,8 @@ bool Foam::solvers::isothermalFilm::initFilmMesh()
wallPatchIDs.transfer(wallPatchIDs_);
// Search for film surface patches
label nSurfaceFaces = 0;
DynamicList<label> surfacePatchIDs_;
// Search for film surface patch
surfacePatchID = -1;
forAll(bm, patchi)
{
@ -163,16 +161,23 @@ bool Foam::solvers::isothermalFilm::initFilmMesh()
if (isA<filmSurfacePolyPatch>(p))
{
surfacePatchIDs_.append(patchi);
nSurfaceFaces += p.faceCells().size();
if (surfacePatchID == -1)
{
surfacePatchID = patchi;
}
else
{
FatalErrorInFunction
<< "More than one filmSurface patch defined: "
<< surfacePatchID << " and " << patchi
<< exit(FatalError);
}
}
}
surfacePatchIDs.transfer(surfacePatchIDs_);
if (returnReduce(nSurfaceFaces, sumOp<label>()) == 0)
if (surfacePatchID == -1)
{
Info<< "There are no filmSurface faces in the mesh"
Info<< "The filmSurface patch is not defined"
<< endl;
}
@ -215,9 +220,9 @@ Foam::wordList Foam::solvers::isothermalFilm::alphaTypes() const
alphaTypes[wallPatchIDs[i]] = alphaOneFvPatchScalarField::typeName;
}
forAll(surfacePatchIDs, i)
if (surfacePatchID != -1)
{
alphaTypes[surfacePatchIDs[i]] = alphaOneFvPatchScalarField::typeName;
alphaTypes[surfacePatchID] = alphaOneFvPatchScalarField::typeName;
}
return alphaTypes;

View File

@ -107,11 +107,12 @@ protected:
// Film
//- List film wall patch IDs
//- List of film wall patch IDs
labelList wallPatchIDs;
//- List of film surface patch IDs
labelList surfacePatchIDs;
//- Film surface patch ID
// Set to -1 if the surface patch is empty or not coupled
label surfacePatchID;
//- Film wall normal
volVectorField nHat;

View File

@ -37,10 +37,9 @@ void Foam::solvers::isothermalFilm::constrainField
fieldBf[patchi] = Zero;
}
forAll(surfacePatchIDs, i)
if (surfacePatchID != -1)
{
const label patchi = surfacePatchIDs[i];
fieldBf[patchi] = Zero;
fieldBf[surfacePatchID] = Zero;
}
}

View File

@ -325,7 +325,7 @@ void Foam::coupledTemperatureFvPatchScalarField::updateCoeffs()
if (qrNbrName_ != "none")
{
sumq += mpp.distribute
sumq += mpp.fromNeigbour
(
patchNbr.lookupPatchField<volScalarField, scalar>(qrNbrName_)
);
@ -354,8 +354,8 @@ void Foam::coupledTemperatureFvPatchScalarField::updateCoeffs()
qNbr
);
add(sumKappaTByDelta, mpp.distribute(sumKappaTByDeltaNbr));
add(sumKappaByDelta, mpp.distribute(sumKappaByDeltaNbr));
add(sumKappaTByDelta, mpp.fromNeigbour(sumKappaTByDeltaNbr));
add(sumKappaByDelta, mpp.fromNeigbour(sumKappaByDeltaNbr));
}
else
{
@ -364,12 +364,12 @@ void Foam::coupledTemperatureFvPatchScalarField::updateCoeffs()
coupledTemperatureNbr.getNbr(TwNbr, qNbr);
add(sumKappaByDelta, scalarField(size(), wallKappaByDelta_));
add(sumKappaTByDelta, wallKappaByDelta_*mpp.distribute(TwNbr));
add(sumKappaTByDelta, wallKappaByDelta_*mpp.fromNeigbour(TwNbr));
}
if (qNbr.valid())
{
sumq += mpp.distribute(qNbr);
sumq += mpp.fromNeigbour(qNbr);
}
}

View File

@ -239,7 +239,7 @@ baffleThickness() const
else
{
const mappedPatchBase& mpp = mappedPatchBase::getMap(patch().patch());
return mpp.distribute(nbrField().baffleThickness());
return mpp.fromNeigbour(nbrField().baffleThickness());
}
}
@ -254,7 +254,7 @@ tmp<scalarField> thermalBaffle1DFvPatchScalarField<solidType>::qs() const
else
{
const mappedPatchBase& mpp = mappedPatchBase::getMap(patch().patch());
return mpp.distribute(nbrField().qs());
return mpp.fromNeigbour(nbrField().qs());
}
}
@ -348,7 +348,7 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
const scalarField kappaDelta(kappap*patch().deltaCoeffs());
// Neighbour properties
const scalarField nbrTp(mpp.distribute(nbrField()));
const scalarField nbrTp(mpp.fromNeigbour(nbrField()));
// Solid properties
scalarField kappas(patch().size(), 0.0);

View File

@ -71,7 +71,7 @@ Foam::mappedFvPatchField<Type>::mappedValues
UPstream::msgType() = oldTag + 1;
// Map values
tmp<Field<Type>> tResult = this->mapper().distribute(nbrPatchField);
tmp<Field<Type>> tResult = this->mapper().fromNeigbour(nbrPatchField);
// Set the average, if necessary
if (setAverage_)

View File

@ -123,7 +123,7 @@ void Foam::mappedFlowRateVelocityFvPatchVectorField::updateCoeffs()
const scalarField phip
(
mapper.distribute
mapper.fromNeigbour
(
nbrPatch.lookupPatchField<surfaceScalarField, scalar>(nbrPhiName_)
)

View File

@ -110,9 +110,9 @@ void Foam::mappedVelocityFluxFvPatchField::updateCoeffs()
surfaceScalarField& phiField =
nbrMesh.lookupObjectRef<surfaceScalarField>(phiName_);
operator==(mapper.distribute(UField.boundaryField()[nbrPatchi]));
operator==(mapper.fromNeigbour(UField.boundaryField()[nbrPatchi]));
phiField.boundaryFieldRef()[patch().index()] ==
mapper.distribute(phiField.boundaryField()[nbrPatchi]);
mapper.fromNeigbour(phiField.boundaryField()[nbrPatchi]);
// Restore tag
UPstream::msgType() = oldTag;

View File

@ -121,14 +121,14 @@ Foam::mappedExtrudedPatchBase::patchFaceAreas() const
bottomFaceAreasPtr_.set
(
nbrPp.reverseDistribute
nbrPp.toNeigbour
(
nbrPp.patch_.primitivePatch::faceAreas()
).ptr()
);
bottomFaceCentresPtr_.set
(
nbrPp.reverseDistribute
nbrPp.toNeigbour
(
nbrPp.patch_.primitivePatch::faceCentres()
).ptr()

View File

@ -249,21 +249,21 @@ public:
// Distribute
//- Wrapper around map/interpolate data distribution
//- Map/interpolate the neighbour patch field to this patch
template<class Type>
tmp<Field<Type>> distribute(const Field<Type>& fld) const;
tmp<Field<Type>> fromNeigbour(const Field<Type>& nbrFld) const;
//- Wrapper around map/interpolate data distribution
//- Map/interpolate the neighbour patch field to this patch
template<class Type>
tmp<Field<Type>> distribute(const tmp<Field<Type>>& fld) const;
tmp<Field<Type>> fromNeigbour(const tmp<Field<Type>>& nbrFld) const;
//- Wrapper around map/interpolate data distribution
//- Map/interpolate patch field to the neighbour patch
template<class Type>
tmp<Field<Type>> reverseDistribute(const Field<Type>& fld) const;
tmp<Field<Type>> toNeigbour(const Field<Type>& fld) const;
//- Wrapper around map/interpolate data distribution
//- Map/interpolate patch field to the neighbour patch
template<class Type>
tmp<Field<Type>> reverseDistribute
tmp<Field<Type>> toNeigbour
(
const tmp<Field<Type>>& fld
) const;

View File

@ -106,11 +106,11 @@ void Foam::mappedPatchBase::validateForField
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::mappedPatchBase::distribute(const Field<Type>& fld) const
Foam::mappedPatchBase::fromNeigbour(const Field<Type>& nbrFld) const
{
if (sameUntransformedPatch())
{
return fld;
return nbrFld;
}
if (!patchToPatchIsUsed_)
@ -120,7 +120,7 @@ Foam::mappedPatchBase::distribute(const Field<Type>& fld) const
calcMapping();
}
tmp<Field<Type>> tResult(new Field<Type>(fld, nbrPatchFaceIndices_));
tmp<Field<Type>> tResult(new Field<Type>(nbrFld, nbrPatchFaceIndices_));
mapPtr_->distribute(tResult.ref());
return transform_.transform().transform(tResult);
}
@ -144,8 +144,8 @@ Foam::mappedPatchBase::distribute(const Field<Type>& fld) const
transform_.transform().transform
(
patchToPatchIsValid_
? patchToPatchPtr_->tgtToSrc(fld)
: nbrMappedPatch().patchToPatchPtr_->srcToTgt(fld)
? patchToPatchPtr_->tgtToSrc(nbrFld)
: nbrMappedPatch().patchToPatchPtr_->srcToTgt(nbrFld)
);
}
}
@ -153,17 +153,17 @@ Foam::mappedPatchBase::distribute(const Field<Type>& fld) const
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::mappedPatchBase::distribute(const tmp<Field<Type>>& fld) const
Foam::mappedPatchBase::fromNeigbour(const tmp<Field<Type>>& nbrFld) const
{
tmp<Field<Type>> tResult = distribute(fld());
fld.clear();
tmp<Field<Type>> tResult = fromNeigbour(nbrFld());
nbrFld.clear();
return tResult;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::mappedPatchBase::reverseDistribute(const Field<Type>& fld) const
Foam::mappedPatchBase::toNeigbour(const Field<Type>& fld) const
{
if (sameUntransformedPatch())
{
@ -207,9 +207,9 @@ Foam::mappedPatchBase::reverseDistribute(const Field<Type>& fld) const
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::mappedPatchBase::reverseDistribute(const tmp<Field<Type>>& fld) const
Foam::mappedPatchBase::toNeigbour(const tmp<Field<Type>>& fld) const
{
tmp<Field<Type>> tResult = reverseDistribute(fld());
tmp<Field<Type>> tResult = toNeigbour(fld());
fld.clear();
return tResult;
}

View File

@ -146,7 +146,7 @@ Foam::tmp<Foam::scalarField> Foam::radiationCoupledBase::emissivity() const
// emissivity of the surface rather than the emission coefficient
// and the input specification MUST correspond to this.
return
mpp.distribute
mpp.fromNeigbour
(
radiation.absorptionEmission().e()().boundaryField()
[

View File

@ -115,7 +115,7 @@ Foam::semiPermeableBaffleMassFractionFvPatchScalarField::calcPhiYp() const
const scalarField Yc(patchInternalField());
const scalarField nbrYc
(
mpp.distribute
mpp.fromNeigbour
(
nbrPatch.lookupPatchField<volScalarField, scalar>(YName)
.patchInternalField()
@ -134,7 +134,7 @@ Foam::semiPermeableBaffleMassFractionFvPatchScalarField::calcPhiYp() const
const scalarField nbrAlphaEffDeltap
(
mpp.distribute
mpp.fromNeigbour
(
ttm.kappaEff(nbrPatch.index())*nbrPatch.deltaCoeffs()
/ttm.thermo().Cp().boundaryField()[nbrPatch.index()]
@ -154,7 +154,7 @@ Foam::semiPermeableBaffleMassFractionFvPatchScalarField::calcPhiYp() const
if (property_ == moleFraction || property_ == partialPressure)
{
tW = thermo.W(patch().index());
tNbrW = mpp.distribute(thermo.W(nbrPatch.index()));
tNbrW = mpp.fromNeigbour(thermo.W(nbrPatch.index()));
}
// Construct coefficients that convert mass fraction to the property that
@ -174,7 +174,7 @@ Foam::semiPermeableBaffleMassFractionFvPatchScalarField::calcPhiYp() const
{
k *= thermo.rho(patch().index())/Wi;
tmp<scalarField> nbrRhop =
mpp.distribute(thermo.rho(nbrPatch.index()));
mpp.fromNeigbour(thermo.rho(nbrPatch.index()));
nbrK *= nbrRhop/Wi;
}
break;
@ -183,7 +183,7 @@ Foam::semiPermeableBaffleMassFractionFvPatchScalarField::calcPhiYp() const
{
k *= thermo.p().boundaryField()[patch().index()]*tW/Wi;
tmp<scalarField> nbrPp =
mpp.distribute
mpp.fromNeigbour
(
thermo.p().boundaryField()[nbrPatch.index()]
);

View File

@ -40,12 +40,12 @@ void Foam::surfaceFilm::toPrimary
{
if (intCoupledPatchIDs_[i] == filmPatchi)
{
const mappedPatchBase& mpb =
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>
(
mesh().boundaryMesh()[filmPatchi]
);
filmField = mpb.reverseDistribute(filmField);
filmField = mpp.toNeigbour(filmField);
return;
}
}
@ -67,13 +67,13 @@ Foam::tmp<Foam::Field<Type>> Foam::surfaceFilm::toFilm
{
if (intCoupledPatchIDs_[i] == filmPatchi)
{
const mappedPatchBase& mpb =
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>
(
mesh().boundaryMesh()[filmPatchi]
);
return mpb.distribute(primaryPatchField);
return mpp.fromNeigbour(primaryPatchField);
}
}
@ -96,13 +96,13 @@ Foam::tmp<Foam::Field<Type>> Foam::surfaceFilm::toFilm
{
if (intCoupledPatchIDs_[i] == filmPatchi)
{
const mappedPatchBase& mpb =
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>
(
mesh().boundaryMesh()[filmPatchi]
);
return mpb.distribute(tprimaryPatchField);
return mpp.fromNeigbour(tprimaryPatchField);
}
}
@ -129,11 +129,11 @@ void Foam::surfaceFilm::toFilm
const polyPatch& filmPatch =
mesh().boundaryMesh()[filmPatchi];
const mappedPatchBase& mpb =
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(filmPatch);
UIndirectList<Type>(rf, filmPatch.faceCells()) =
mpb.distribute(pBf[primaryPatchi]);
mpp.fromNeigbour(pBf[primaryPatchi]);
}
}