fvModels: Improved interface for mass/volume sources

The interface for fvModels has been modified to improve its application
to "proxy" equations. That is, equations that are not straightforward
statements of conservation laws in OpenFOAM's usual convention.

A standard conservation law typically takes the following form:

    fvMatrix<scalar> psiEqn
    (
        fvm::ddt(alpha, rho, psi)
      + <fluxes>
     ==
        <sources>
    );

A proxy equation, on the other hand, may be a derivation or
rearrangement of a law like this, and may be linearised in terms of a
different variable.

The pressure equation is the most common example of a proxy equation. It
represents a statement of the conservation of volume or mass, but it is
a rearrangement of the original continuity equation, and it has been
linearised in terms of a different variable; the pressure. Another
example is that in the pre-predictor of a VoF solver the
phase-continuity equation is constructed, but it is linearised in terms
of volume fraction rather than density.

In these situations, fvModels sources are now applied by calling:

    fvModels().sourceProxy(<conserved-fields ...>, <equation-field>)

Where <conserved-fields ...> are (alpha, rho, psi), (rho, psi), just
(psi), or are omitted entirely (for volume continuity), and the
<equation-field> is the field associated with the proxy equation. This
produces a source term identical in value to the following call:

    fvModels().source(<conserved-fields ...>)

It is only the linearisation in terms of <equation-field> that differs
between these two calls.

This change permits much greater flexibility in the handling of mass and
volume sources than the previous name-based system did. All the relevant
fields are available, dimensions can be used in the logic to determine
what sources are being constructed, and sources relating to a given
conservation law all share the same function.

This commit adds the functionality for injection-type sources in the
compressibleVoF solver. A following commit will add a volume source
model for use in incompressible solvers.
This commit is contained in:
Will Bainbridge
2023-09-26 15:47:12 +01:00
parent bb127a4523
commit a5ea0b41f1
113 changed files with 1866 additions and 1619 deletions

View File

@ -24,7 +24,7 @@ if (pimple.transonic())
+ fvm::div(phid, p) + fvm::div(phid, p)
- fvm::laplacian(rho*invA, p) - fvm::laplacian(rho*invA, p)
== ==
betav*fvModels.source(psi, p, rho.name()) betav*fvModels.sourceProxy(rho, p)
); );
pEqn.solve(); pEqn.solve();
@ -54,7 +54,7 @@ else
+ fvc::div(phiHbyA) + fvc::div(phiHbyA)
- fvm::laplacian(rho*invA, p) - fvm::laplacian(rho*invA, p)
== ==
betav*fvModels.source(psi, p, rho.name()) betav*fvModels.sourceProxy(rho, p)
); );
pEqn.solve(); pEqn.solve();

View File

@ -34,7 +34,7 @@
tpEqn = tpEqn =
( (
fvm::laplacian(rho*trTU(), p) fvm::laplacian(rho*trTU(), p)
+ fvModels.source(psi, p, rho.name()) + fvModels.sourceProxy(rho, p)
== ==
fvc::div(phiHbyA) fvc::div(phiHbyA)
); );
@ -44,7 +44,7 @@
tpEqn = tpEqn =
( (
fvm::laplacian(rho*trAU(), p) fvm::laplacian(rho*trAU(), p)
+ fvModels.source(psi, p, rho.name()) + fvModels.sourceProxy(rho, p)
== ==
fvc::div(phiHbyA) fvc::div(phiHbyA)
); );

View File

@ -88,7 +88,7 @@ void Foam::solvers::compressibleMultiphaseVoF::pressureCorrector()
( (
fvc::ddt(rho) + thermo.psi()*correction(fvm::ddt(p_rgh)) fvc::ddt(rho) + thermo.psi()*correction(fvm::ddt(p_rgh))
+ fvc::div(phi, rho) - fvc::Sp(fvc::div(phi), rho) + fvc::div(phi, rho) - fvc::Sp(fvc::div(phi), rho)
- (fvModels().source(phase, rho)&rho) - fvModels().sourceProxy(phase, rho, p_rgh)
).ptr() ).ptr()
); );
} }

View File

@ -30,46 +30,52 @@ License
void Foam::solvers::compressibleVoF::alphaSuSp void Foam::solvers::compressibleVoF::alphaSuSp
( (
tmp<volScalarField::Internal>& Su, tmp<volScalarField::Internal>& tSu,
tmp<volScalarField::Internal>& Sp tmp<volScalarField::Internal>& tSp
) )
{ {
Sp = volScalarField::Internal::New const dimensionedScalar Szero(dgdt.dimensions(), 0);
(
"Sp",
mesh,
dimensionedScalar(dgdt.dimensions(), 0)
);
Su = volScalarField::Internal::New tSp = volScalarField::Internal::New("Sp", mesh, Szero);
( tSu = volScalarField::Internal::New("Su", mesh, Szero);
"Su",
mesh,
dimensionedScalar(dgdt.dimensions(), 0)
);
if (fvModels().addsSupToField(alpha1.name())) volScalarField::Internal& Sp = tSp.ref();
volScalarField::Internal& Su = tSu.ref();
if (fvModels().addsSupToField(mixture.rho1().name()))
{ {
// Phase change alpha1 source const volScalarField::Internal alpha2ByRho1(alpha2()/mixture.rho1()());
const fvScalarMatrix alphaSup(fvModels().source(alpha1)); const fvScalarMatrix alphaRho1Sup
(
fvModels().sourceProxy(alpha1, mixture.rho1(), alpha1)
);
Su = alphaSup.Su(); Su += alpha2ByRho1*alphaRho1Sup.Su();
Sp = alphaSup.Sp(); Sp += alpha2ByRho1*alphaRho1Sup.Sp();
} }
volScalarField::Internal& SpRef = Sp.ref(); if (fvModels().addsSupToField(mixture.rho2().name()))
volScalarField::Internal& SuRef = Su.ref(); {
const volScalarField::Internal alpha1ByRho2(alpha1()/mixture.rho2()());
const fvScalarMatrix alphaRho2Sup
(
fvModels().sourceProxy(alpha2, mixture.rho2(), alpha2)
);
Su -= alpha1ByRho2*(alphaRho2Sup.Su() + alphaRho2Sup.Sp());
Sp += alpha1ByRho2*alphaRho2Sup.Sp();
}
forAll(dgdt, celli) forAll(dgdt, celli)
{ {
if (dgdt[celli] > 0.0) if (dgdt[celli] > 0.0)
{ {
SpRef[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4); Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
SuRef[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4); Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
} }
else if (dgdt[celli] < 0.0) else if (dgdt[celli] < 0.0)
{ {
SpRef[celli] += dgdt[celli]/max(alpha1[celli], 1e-4); Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
} }
} }
} }

View File

@ -156,7 +156,8 @@ protected:
{ {
return return
!incompressible() !incompressible()
|| fvModels().addsSupToField(alpha1.name()); || fvModels().addsSupToField(alpha1.name())
|| fvModels().addsSupToField(alpha2.name());
} }
//- Return the mixture compressibility/density //- Return the mixture compressibility/density

View File

@ -69,9 +69,7 @@ Foam::fv::compressible::VoFCavitation::VoFCavitation
) )
), ),
cavitation_(Foam::compressible::cavitationModel::New(dict, mixture_)), cavitation_(Foam::compressible::cavitationModel::New(dict, mixture_))
alphaName_(mixture_.alpha1().name())
{} {}
@ -79,14 +77,19 @@ Foam::fv::compressible::VoFCavitation::VoFCavitation
Foam::wordList Foam::fv::compressible::VoFCavitation::addSupFields() const Foam::wordList Foam::fv::compressible::VoFCavitation::addSupFields() const
{ {
return {alphaName_, "p_rgh"}; return
{
mixture_.rho1().name(),
mixture_.rho2().name()
};
} }
void Foam::fv::compressible::VoFCavitation::addSup void Foam::fv::compressible::VoFCavitation::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& alpha,
const word& fieldName const volScalarField& rho,
fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -94,64 +97,68 @@ void Foam::fv::compressible::VoFCavitation::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == alphaName_) if (&rho == &mixture_.rho1() || &rho == &mixture_.rho2())
{ {
const volScalarField::Internal alpha1Coeff const volScalarField& alpha1 = mixture_.alpha1();
( const volScalarField& alpha2 = mixture_.alpha2();
1.0/mixture_.rho1()()
- mixture_.alpha1()()*(1.0/mixture_.rho1()() - 1.0/mixture_.rho2()())
);
const scalar s = &alpha == &alpha1 ? +1 : -1;
// Volume-fraction linearisation
if (&alpha == &eqn.psi())
{
const Pair<tmp<volScalarField::Internal>> mDot12Alpha const Pair<tmp<volScalarField::Internal>> mDot12Alpha
( (
cavitation_->mDot12Alpha() cavitation_->mDot12Alpha()
); );
const volScalarField::Internal& mDot1Alpha2 = mDot12Alpha[0]();
const volScalarField::Internal& mDot2Alpha1 = mDot12Alpha[1]();
const volScalarField::Internal vDot1Alpha(alpha1Coeff*mDot12Alpha[0]()); eqn +=
const volScalarField::Internal vDot2Alpha(alpha1Coeff*mDot12Alpha[1]()); (&alpha == &alpha1 ? mDot1Alpha2 : mDot2Alpha1)
- fvm::Sp(mDot1Alpha2 + mDot2Alpha1, eqn.psi());
eqn += fvm::Sp(-vDot2Alpha - vDot1Alpha, eqn.psi()) + vDot1Alpha;
}
} }
// Pressure linearisation
void Foam::fv::compressible::VoFCavitation::addSup else if (eqn.psi().name() == "p_rgh")
(
const volScalarField&,
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{ {
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
if (fieldName == "p_rgh")
{
const volScalarField::Internal& rho =
mesh().lookupObject<volScalarField>("rho");
const volScalarField::Internal& gh =
mesh().lookupObject<volScalarField>("gh");
const volScalarField::Internal pCoeff
(
1.0/mixture_.rho1()() - 1.0/mixture_.rho2()()
);
const Pair<tmp<volScalarField::Internal>> mDot12P const Pair<tmp<volScalarField::Internal>> mDot12P
( (
cavitation_->mDot12P() cavitation_->mDot12P()
); );
const volScalarField::Internal& mDot1P = mDot12P[0];
const volScalarField::Internal& mDot2P = mDot12P[1];
const volScalarField::Internal vDot1P(pCoeff*mDot12P[0]); const volScalarField::Internal& rho =
const volScalarField::Internal vDot2P(pCoeff*mDot12P[1]); mesh().lookupObject<volScalarField>("rho");
const volScalarField::Internal& gh =
mesh().lookupObject<volScalarField>("gh");
eqn += eqn +=
vDot2P*cavitation_->pSat1() - vDot1P*cavitation_->pSat2() fvm::Sp(s*(mDot1P - mDot2P), eqn.psi())
- (vDot2P - vDot1P)*rho*gh + s*(mDot1P - mDot2P)*rho*gh
- fvm::Sp(vDot2P - vDot1P, eqn.psi()); - s*(mDot1P*cavitation_->pSat1() - mDot2P*cavitation_->pSat2());
}
// Explicit non-linearised value. Used in density predictors and
// continuity error terms.
else
{
const Pair<tmp<volScalarField::Internal>> mDot12Alpha
(
cavitation_->mDot12Alpha()
);
const volScalarField::Internal mDot1(mDot12Alpha[0]*alpha2);
const volScalarField::Internal mDot2(mDot12Alpha[1]*alpha1);
eqn += s*(mDot1 - mDot2);
}
}
else
{
FatalErrorInFunction
<< "Support for field " << alpha.name() << " is not implemented"
<< exit(FatalError);
} }
} }

View File

@ -104,11 +104,9 @@ class VoFCavitation
//- Reference to the mixture properties //- Reference to the mixture properties
const compressibleTwoPhaseVoFMixture& mixture_; const compressibleTwoPhaseVoFMixture& mixture_;
//- The cavitation model
autoPtr<Foam::compressible::cavitationModel> cavitation_; autoPtr<Foam::compressible::cavitationModel> cavitation_;
//- The name of the VoF phase-fraction
word alphaName_;
public: public:
@ -140,19 +138,12 @@ public:
// to the transport equation // to the transport equation
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
//- Add implicit/explicit contributions to VoF phase-fraction equation //- Add a source to the phase continuity equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& alpha,
const word& fieldName const volScalarField& rho,
) const; fvMatrix<scalar>& eqn
//- Add implicit/explicit contributions to p_rgh equation
virtual void addSup
(
const volScalarField& psi,
fvMatrix<scalar>& eqn,
const word& fieldName
) const; ) const;

View File

@ -109,8 +109,8 @@ void Foam::fv::VoFClouds::correct()
void Foam::fv::VoFClouds::addSup void Foam::fv::VoFClouds::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -118,14 +118,14 @@ void Foam::fv::VoFClouds::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == thermo_.rho()().name()) if (&rho == &thermo_.rho()())
{ {
eqn += clouds_.Srho(); eqn += clouds_.Srho();
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << rho.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -135,8 +135,8 @@ void Foam::fv::VoFClouds::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -144,14 +144,14 @@ void Foam::fv::VoFClouds::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == thermo_.he().name()) if (&he == &thermo_.he())
{ {
eqn += clouds_.Sh(eqn.psi()); eqn += clouds_.Sh(eqn.psi());
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << he.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -160,8 +160,8 @@ void Foam::fv::VoFClouds::addSup
void Foam::fv::VoFClouds::addSup void Foam::fv::VoFClouds::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -169,8 +169,17 @@ void Foam::fv::VoFClouds::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (U.name() == "U")
{
eqn += clouds_.SU(eqn.psi()); eqn += clouds_.SU(eqn.psi());
} }
else
{
FatalErrorInFunction
<< "Support for field " << U.name() << " is not implemented"
<< exit(FatalError);
}
}
void Foam::fv::VoFClouds::preUpdateMesh() void Foam::fv::VoFClouds::preUpdateMesh()

View File

@ -130,8 +130,8 @@ public:
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add explicit contribution to phase energy equation //- Add explicit contribution to phase energy equation
@ -139,16 +139,16 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to mixture momentum equation //- Add implicit contribution to mixture momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -132,8 +132,8 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -148,8 +148,8 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup
void Foam::fv::VoFSolidificationMeltingSource::addSup void Foam::fv::VoFSolidificationMeltingSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)

View File

@ -182,16 +182,16 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to mixture momentum equation //- Add implicit contribution to mixture momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -127,8 +127,8 @@ Foam::fv::compressible::VoFTurbulenceDamping::addSupFields() const
void Foam::fv::compressible::VoFTurbulenceDamping::addSup void Foam::fv::compressible::VoFTurbulenceDamping::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -142,12 +142,12 @@ void Foam::fv::compressible::VoFTurbulenceDamping::addSup
+ mixture_.alpha2()()*mixture_.rho2()()*sqr(mixture_.thermo2().nu()()()) + mixture_.alpha2()()*mixture_.rho2()()*sqr(mixture_.thermo2().nu()()())
); );
if (fieldName == "epsilon") if (field.name() == "epsilon")
{ {
eqn += mixture_.interfaceFraction() eqn += mixture_.interfaceFraction()
*C2_*aRhoSqrnu*momentumTransport_.k()()/pow4(delta_); *C2_*aRhoSqrnu*momentumTransport_.k()()/pow4(delta_);
} }
else if (fieldName == "omega") else if (field.name() == "omega")
{ {
eqn += mixture_.interfaceFraction() eqn += mixture_.interfaceFraction()
*beta_*aRhoSqrnu/(sqr(betaStar_)*pow4(delta_)); *beta_*aRhoSqrnu/(sqr(betaStar_)*pow4(delta_));
@ -155,7 +155,7 @@ void Foam::fv::compressible::VoFTurbulenceDamping::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -164,9 +164,9 @@ void Foam::fv::compressible::VoFTurbulenceDamping::addSup
void Foam::fv::compressible::VoFTurbulenceDamping::addSup void Foam::fv::compressible::VoFTurbulenceDamping::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField&, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -193,12 +193,12 @@ void Foam::fv::compressible::VoFTurbulenceDamping::addSup
<< exit(FatalError); << exit(FatalError);
} }
if (fieldName == IOobject::groupName("epsilon", phaseName_)) if (field.name() == IOobject::groupName("epsilon", phaseName_))
{ {
eqn += mixture_.interfaceFraction() eqn += mixture_.interfaceFraction()
*C2_*taRhoSqrnu*momentumTransport_.k()()/pow4(delta_); *C2_*taRhoSqrnu*momentumTransport_.k()()/pow4(delta_);
} }
else if (fieldName == IOobject::groupName("omega", phaseName_)) else if (field.name() == IOobject::groupName("omega", phaseName_))
{ {
eqn += mixture_.interfaceFraction() eqn += mixture_.interfaceFraction()
*beta_*taRhoSqrnu/(sqr(betaStar_)*pow4(delta_)); *beta_*taRhoSqrnu/(sqr(betaStar_)*pow4(delta_));
@ -206,7 +206,7 @@ void Foam::fv::compressible::VoFTurbulenceDamping::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -146,16 +146,21 @@ public:
// Member Functions // Member Functions
// Checks
//- Return the list of fields for which the option adds source term //- Return the list of fields for which the option adds source term
// to the transport equation // to the transport equation
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
// Sources
//- Add explicit contribution to epsilon or omega equation //- Add explicit contribution to epsilon or omega equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add explicit contribution to phase epsilon or omega equation //- Add explicit contribution to phase epsilon or omega equation
@ -163,8 +168,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -81,19 +81,11 @@ void Foam::solvers::compressibleVoF::pressureCorrector()
// Update the pressure BCs to ensure flux consistency // Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF); constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Cache the phase change pressure source // Cache any sources
fvScalarMatrix Sp_rgh fvScalarMatrix p_rghEqnSource
( (
fvModels().source fvModels().sourceProxy(alpha1, rho1, p_rgh)/rho1
( + fvModels().sourceProxy(alpha2, rho2, p_rgh)/rho2
volScalarField::New
(
"1",
mesh,
dimensionedScalar(dimless/dimPressure, 1)
),
p_rgh
)
); );
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion
@ -163,11 +155,6 @@ void Foam::solvers::compressibleVoF::pressureCorrector()
p_rghEqnComp1.ref() *= pos(alpha1); p_rghEqnComp1.ref() *= pos(alpha1);
p_rghEqnComp2.ref() *= pos(alpha2); p_rghEqnComp2.ref() *= pos(alpha2);
p_rghEqnComp1.ref() -=
(fvModels().source(alpha1, mixture_.thermo1().rho())&rho1)/rho1;
p_rghEqnComp2.ref() -=
(fvModels().source(alpha2, mixture_.thermo2().rho())&rho2)/rho2;
if (pimple.transonic()) if (pimple.transonic())
{ {
p_rghEqnComp1.ref().relax(); p_rghEqnComp1.ref().relax();
@ -182,7 +169,7 @@ void Foam::solvers::compressibleVoF::pressureCorrector()
fvScalarMatrix p_rghEqnIncomp fvScalarMatrix p_rghEqnIncomp
( (
fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh) fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
== Sp_rgh == p_rghEqnSource
); );
{ {

View File

@ -89,6 +89,7 @@ void Foam::solvers::incompressibleDenseParticleFluid::correctPressure()
== ==
fvc::ddt(alphac) fvc::ddt(alphac)
+ fvc::div(alphacf*phiHbyAD) + fvc::div(alphacf*phiHbyAD)
+ fvModels().sourceProxy(alphac, p)
); );
pEqn.setReference pEqn.setReference

View File

@ -45,19 +45,37 @@ Foam::solvers::incompressibleDriftFlux::alphaPhi
); );
} }
void Foam::solvers::incompressibleDriftFlux::alphaSuSp void Foam::solvers::incompressibleDriftFlux::alphaSuSp
( (
tmp<volScalarField::Internal>& Su, tmp<volScalarField::Internal>& tSu,
tmp<volScalarField::Internal>& Sp tmp<volScalarField::Internal>& tSp
) )
{ {
if (divergent()) if (!divergent()) return;
{
// Phase change alpha1 source
const fvScalarMatrix alphaSup(fvModels().source(alpha1));
Su = alphaSup.Su(); const dimensionedScalar Szero(dimless/dimTime, 0);
Sp = alphaSup.Sp();
tSp = volScalarField::Internal::New("Sp", mesh, Szero);
tSu = volScalarField::Internal::New("Su", mesh, Szero);
volScalarField::Internal& Sp = tSp.ref();
volScalarField::Internal& Su = tSu.ref();
if (fvModels().addsSupToField(alpha1.name()))
{
const fvScalarMatrix alpha1Sup(fvModels().source(alpha1));
Su += alpha2()*alpha1Sup.Su();
Sp += alpha2()*alpha1Sup.Sp();
}
if (fvModels().addsSupToField(alpha2.name()))
{
const fvScalarMatrix alpha2Sup(fvModels().source(alpha2));
Su -= alpha1()*(alpha2Sup.Su() + alpha2Sup.Sp());
Sp += alpha1()*alpha2Sup.Sp();
} }
} }

View File

@ -133,7 +133,9 @@ protected:
// i.e. includes phase-fraction sources // i.e. includes phase-fraction sources
virtual bool divergent() const virtual bool divergent() const
{ {
return fvModels().addsSupToField(alpha1.name()); return
fvModels().addsSupToField(alpha1.name())
|| fvModels().addsSupToField(alpha2.name());
} }
//- Return the mixture compressibility/density //- Return the mixture compressibility/density

View File

@ -80,12 +80,18 @@ void Foam::solvers::incompressibleFluid::correctPressure()
// Update the pressure BCs to ensure flux consistency // Update the pressure BCs to ensure flux consistency
constrainPressure(p, U, phiHbyA, rAtU(), MRF); constrainPressure(p, U, phiHbyA, rAtU(), MRF);
// Evaluate any volume sources
fvScalarMatrix p_rghEqnSource(fvModels().sourceProxy(p));
// Non-orthogonal pressure corrector loop // Non-orthogonal pressure corrector loop
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
{ {
fvScalarMatrix pEqn fvScalarMatrix pEqn
( (
fvm::laplacian(rAtU(), p) == fvc::div(phiHbyA) fvm::laplacian(rAtU(), p)
==
fvc::div(phiHbyA)
- p_rghEqnSource
); );
pEqn.setReference pEqn.setReference

View File

@ -80,27 +80,20 @@ void Foam::solvers::incompressibleMultiphaseVoF::pressureCorrector()
// Update the pressure BCs to ensure flux consistency // Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF); constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Cache the phase change pressure source // Evaluate any phase sources
fvScalarMatrix Sp_rgh fvScalarMatrix p_rghEqnSource(p_rgh, dimVolume/dimTime);
( forAll(phases, phasei)
fvModels().source {
( p_rghEqnSource +=
volScalarField::New fvModels().sourceProxy(phases[phasei], p_rgh);
( }
"1",
mesh,
dimensionedScalar(dimless/dimPressure, 1)
),
p_rgh
)
);
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
{ {
fvScalarMatrix p_rghEqn fvScalarMatrix p_rghEqn
( (
fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh) fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
== Sp_rgh == p_rghEqnSource
); );
p_rghEqn.setReference p_rghEqn.setReference

View File

@ -30,17 +30,34 @@ License
void Foam::solvers::incompressibleVoF::alphaSuSp void Foam::solvers::incompressibleVoF::alphaSuSp
( (
tmp<volScalarField::Internal>& Su, tmp<volScalarField::Internal>& tSu,
tmp<volScalarField::Internal>& Sp tmp<volScalarField::Internal>& tSp
) )
{ {
if (divergent()) if (!divergent()) return;
{
// Phase change alpha1 source
const fvScalarMatrix alphaSup(fvModels().source(alpha1));
Su = alphaSup.Su(); const dimensionedScalar Szero(dimless/dimTime, 0);
Sp = alphaSup.Sp();
tSp = volScalarField::Internal::New("Sp", mesh, Szero);
tSu = volScalarField::Internal::New("Su", mesh, Szero);
volScalarField::Internal& Sp = tSp.ref();
volScalarField::Internal& Su = tSu.ref();
if (fvModels().addsSupToField(alpha1.name()))
{
const fvScalarMatrix alpha1Sup(fvModels().source(alpha1));
Su += alpha2()*alpha1Sup.Su();
Sp += alpha2()*alpha1Sup.Sp();
}
if (fvModels().addsSupToField(alpha2.name()))
{
const fvScalarMatrix alpha2Sup(fvModels().source(alpha2));
Su -= alpha1()*(alpha2Sup.Su() + alpha2Sup.Sp());
Sp += alpha1()*alpha2Sup.Sp();
} }
} }

View File

@ -68,9 +68,7 @@ Foam::fv::VoFCavitation::VoFCavitation
) )
), ),
cavitation_(cavitationModel::New(dict, mixture_)), cavitation_(cavitationModel::New(dict, mixture_))
alphaName_(mixture_.alpha1().name())
{} {}
@ -78,14 +76,19 @@ Foam::fv::VoFCavitation::VoFCavitation
Foam::wordList Foam::fv::VoFCavitation::addSupFields() const Foam::wordList Foam::fv::VoFCavitation::addSupFields() const
{ {
return {alphaName_, "p_rgh", "U"}; return
{
mixture_.alpha1().name(),
mixture_.alpha2().name(),
"U"
};
} }
void Foam::fv::VoFCavitation::addSup void Foam::fv::VoFCavitation::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& alpha,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -93,63 +96,70 @@ void Foam::fv::VoFCavitation::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == alphaName_) if (&alpha == &mixture_.alpha1() || &alpha == &mixture_.alpha2())
{ {
const volScalarField::Internal alpha1Coeff const volScalarField& alpha1 = mixture_.alpha1();
( const volScalarField& alpha2 = mixture_.alpha2();
1.0/mixture_.rho1()
- mixture_.alpha1()()*(1.0/mixture_.rho1() - 1.0/mixture_.rho2())
);
const dimensionedScalar& rho =
&alpha == &alpha1 ? mixture_.rho1() : mixture_.rho2();
const scalar s = &alpha == &alpha1 ? +1 : -1;
// Volume-fraction linearisation
if (&alpha == &eqn.psi())
{
const Pair<tmp<volScalarField::Internal>> mDot12Alpha const Pair<tmp<volScalarField::Internal>> mDot12Alpha
( (
cavitation_->mDot12Alpha() cavitation_->mDot12Alpha()
); );
const volScalarField::Internal vDot1Alpha2(mDot12Alpha[0]/rho);
const volScalarField::Internal vDot2Alpha1(mDot12Alpha[1]/rho);
const volScalarField::Internal vDot1Alpha(alpha1Coeff*mDot12Alpha[0]()); eqn +=
const volScalarField::Internal vDot2Alpha(alpha1Coeff*mDot12Alpha[1]()); (&alpha == &alpha1 ? vDot1Alpha2 : vDot2Alpha1)
- fvm::Sp(vDot1Alpha2 + vDot2Alpha1, eqn.psi());
eqn += fvm::Sp(-vDot2Alpha - vDot1Alpha, eqn.psi()) + vDot1Alpha;
}
} }
// Pressure linearisation
void Foam::fv::VoFCavitation::addSup else if (eqn.psi().name() == "p_rgh")
(
const volScalarField&,
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{ {
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
if (fieldName == "p_rgh")
{
const volScalarField::Internal& rho =
mesh().lookupObject<volScalarField>("rho");
const volScalarField::Internal& gh =
mesh().lookupObject<volScalarField>("gh");
const dimensionedScalar pCoeff
(
1.0/mixture_.rho1() - 1.0/mixture_.rho2()
);
const Pair<tmp<volScalarField::Internal>> mDot12P const Pair<tmp<volScalarField::Internal>> mDot12P
( (
cavitation_->mDot12P() cavitation_->mDot12P()
); );
const volScalarField::Internal vDot1P(mDot12P[0]/rho);
const volScalarField::Internal vDot2P(mDot12P[1]/rho);
const volScalarField::Internal vDot1P(pCoeff*mDot12P[0]); const volScalarField::Internal& rho =
const volScalarField::Internal vDot2P(pCoeff*mDot12P[1]); mesh().lookupObject<volScalarField>("rho");
const volScalarField::Internal& gh =
mesh().lookupObject<volScalarField>("gh");
eqn += eqn +=
(vDot2P - vDot1P)*(cavitation_->pSat() - rho*gh) fvm::Sp(s*(vDot1P - vDot2P), eqn.psi())
- fvm::Sp(vDot2P - vDot1P, eqn.psi()); + s*(vDot1P - vDot2P)*rho*gh
- s*(vDot1P - vDot2P)*cavitation_->pSat();
}
// Explicit non-linearised value. Probably not used.
else
{
const Pair<tmp<volScalarField::Internal>> mDot12Alpha
(
cavitation_->mDot12Alpha()
);
const volScalarField::Internal vDot1(mDot12Alpha[0]*alpha2/rho);
const volScalarField::Internal vDot2(mDot12Alpha[1]*alpha1/rho);
eqn += s*(vDot1 - vDot2);
}
}
else
{
FatalErrorInFunction
<< "Support for field " << alpha.name() << " is not implemented"
<< exit(FatalError);
} }
} }
@ -157,8 +167,8 @@ void Foam::fv::VoFCavitation::addSup
void Foam::fv::VoFCavitation::addSup void Foam::fv::VoFCavitation::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -166,13 +176,26 @@ void Foam::fv::VoFCavitation::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == "U") if (U.name() == "U")
{ {
const surfaceScalarField& rhoPhi = const surfaceScalarField& rhoPhi =
mesh().lookupObject<surfaceScalarField>("rhoPhi"); mesh().lookupObject<surfaceScalarField>("rhoPhi");
if (&U == &eqn.psi())
{
eqn += fvm::Sp(fvc::ddt(rho) + fvc::div(rhoPhi), eqn.psi()); eqn += fvm::Sp(fvc::ddt(rho) + fvc::div(rhoPhi), eqn.psi());
} }
else
{
eqn += (fvc::ddt(rho) + fvc::div(rhoPhi))*U;
}
}
else
{
FatalErrorInFunction
<< "Support for field " << U.name() << " is not implemented"
<< exit(FatalError);
}
} }

View File

@ -102,11 +102,9 @@ class VoFCavitation
//- Reference to the mixture properties //- Reference to the mixture properties
const incompressibleTwoPhaseVoFMixture& mixture_; const incompressibleTwoPhaseVoFMixture& mixture_;
//- The cavitation model
autoPtr<cavitationModel> cavitation_; autoPtr<cavitationModel> cavitation_;
//- The name of the VoF phase-fraction
word alphaName_;
public: public:
@ -138,27 +136,19 @@ public:
// to the transport equation // to the transport equation
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
//- Add implicit/explicit contributions to VoF phase-fraction equation //- Add a source to the phase continuity equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& alpha,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit/explicit contributions to p_rgh equation //- Add a source to the mixture momentum equation
virtual void addSup
(
const volScalarField& psi,
fvMatrix<scalar>& eqn,
const word& fieldName
) const;
//- Add contribution to U equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -118,8 +118,8 @@ Foam::wordList Foam::fv::VoFTurbulenceDamping::addSupFields() const
void Foam::fv::VoFTurbulenceDamping::addSup void Foam::fv::VoFTurbulenceDamping::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -133,12 +133,12 @@ void Foam::fv::VoFTurbulenceDamping::addSup
+ mixture_.alpha2()()*sqr(mixture_.nuModel2().nu()()()) + mixture_.alpha2()()*sqr(mixture_.nuModel2().nu()()())
); );
if (fieldName == "epsilon") if (field.name() == "epsilon")
{ {
eqn += mixture_.interfaceFraction()*C2_*aSqrnu*turbulence_.k()() eqn += mixture_.interfaceFraction()*C2_*aSqrnu*turbulence_.k()()
/pow4(delta_); /pow4(delta_);
} }
else if (fieldName == "omega") else if (field.name() == "omega")
{ {
eqn += mixture_.interfaceFraction()*beta_*aSqrnu/(sqr(betaStar_) eqn += mixture_.interfaceFraction()*beta_*aSqrnu/(sqr(betaStar_)
*pow4(delta_)); *pow4(delta_));
@ -146,7 +146,7 @@ void Foam::fv::VoFTurbulenceDamping::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -155,9 +155,9 @@ void Foam::fv::VoFTurbulenceDamping::addSup
void Foam::fv::VoFTurbulenceDamping::addSup void Foam::fv::VoFTurbulenceDamping::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField&, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -182,12 +182,12 @@ void Foam::fv::VoFTurbulenceDamping::addSup
<< exit(FatalError); << exit(FatalError);
} }
if (fieldName == IOobject::groupName("epsilon", phaseName_)) if (field.name() == IOobject::groupName("epsilon", phaseName_))
{ {
eqn += mixture_.interfaceFraction()*C2_*taSqrnu*turbulence_.k()() eqn += mixture_.interfaceFraction()*C2_*taSqrnu*turbulence_.k()()
/pow4(delta_); /pow4(delta_);
} }
else if (fieldName == IOobject::groupName("omega", phaseName_)) else if (field.name() == IOobject::groupName("omega", phaseName_))
{ {
eqn += mixture_.interfaceFraction()*beta_*taSqrnu eqn += mixture_.interfaceFraction()*beta_*taSqrnu
/(sqr(betaStar_)*pow4(delta_)); /(sqr(betaStar_)*pow4(delta_));
@ -195,7 +195,7 @@ void Foam::fv::VoFTurbulenceDamping::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -144,15 +144,20 @@ public:
// Member Functions // Member Functions
// Checks
//- Return the list of fields for which the option adds source term //- Return the list of fields for which the option adds source term
// to the transport equation // to the transport equation
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
// Sources
//- Add explicit contribution to epsilon or omega equation //- Add explicit contribution to epsilon or omega equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add explicit contribution to phase epsilon or omega equation //- Add explicit contribution to phase epsilon or omega equation
@ -160,8 +165,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -122,7 +122,9 @@ protected:
// i.e. includes phase-fraction sources // i.e. includes phase-fraction sources
virtual bool divergent() const virtual bool divergent() const
{ {
return fvModels().addsSupToField(alpha1.name()); return
fvModels().addsSupToField(alpha1.name())
|| fvModels().addsSupToField(alpha2.name());
} }
//- Return the mixture compressibility/density //- Return the mixture compressibility/density

View File

@ -138,8 +138,8 @@ inline Foam::fv::filmCloudTransfer::CloudToFilmTransferRate
void Foam::fv::filmCloudTransfer::addSup void Foam::fv::filmCloudTransfer::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& alpha,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -147,7 +147,7 @@ void Foam::fv::filmCloudTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == film_.alpha.name()) if (&alpha == &film_.alpha && &eqn.psi() == &film_.alpha)
{ {
eqn += CloudToFilmTransferRate<scalar>(massFromCloud_, dimMass); eqn += CloudToFilmTransferRate<scalar>(massFromCloud_, dimMass);
@ -159,7 +159,7 @@ void Foam::fv::filmCloudTransfer::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << alpha.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -169,8 +169,8 @@ void Foam::fv::filmCloudTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -178,7 +178,7 @@ void Foam::fv::filmCloudTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == film_.thermo.he().name()) if (&he == &film_.thermo.he() && &eqn.psi() == &film_.thermo.he())
{ {
eqn += CloudToFilmTransferRate<scalar>(energyFromCloud_, dimEnergy); eqn += CloudToFilmTransferRate<scalar>(energyFromCloud_, dimEnergy);
@ -190,7 +190,7 @@ void Foam::fv::filmCloudTransfer::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << he.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -200,8 +200,8 @@ void Foam::fv::filmCloudTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -209,7 +209,7 @@ void Foam::fv::filmCloudTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == film_.U.name()) if (&U == &film_.U && &U == &film_.U)
{ {
eqn += CloudToFilmTransferRate<vector>(momentumFromCloud_, dimMomentum); eqn += CloudToFilmTransferRate<vector>(momentumFromCloud_, dimMomentum);
@ -221,7 +221,7 @@ void Foam::fv::filmCloudTransfer::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << U.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -144,32 +144,32 @@ public:
virtual void correct(); virtual void correct();
// Add explicit and implicit contributions to compressible equation // Sources
//- Add explicit contribution to phase continuity //- Add source to phase continuity equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho,
const volScalarField& alpha, const volScalarField& alpha,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn
const word& fieldName
) const; ) const;
//- Add explicit contribution to phase energy equation //- Add source to phase energy equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to mixture momentum equation //- Add source to mixture momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -105,7 +105,6 @@ Foam::wordList Foam::fv::VoFFilmTransfer::addSupFields() const
{ {
return wordList return wordList
{ {
alpha_.name(),
thermo_.rho()().name(), thermo_.rho()().name(),
thermo_.he().name(), thermo_.he().name(),
VoF_.U.name() VoF_.U.name()
@ -241,41 +240,11 @@ inline Foam::fv::VoFFilmTransfer::filmVoFTransferRate
} }
void Foam::fv::VoFFilmTransfer::addSup
(
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
if (fieldName == alpha_.name())
{
eqn +=
filmVoFTransferRate<scalar>
(
&filmVoFTransfer::transferRate,
dimVolume
)
- fvm::Sp(transferRate_, eqn.psi());
}
else
{
FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented"
<< exit(FatalError);
}
}
void Foam::fv::VoFFilmTransfer::addSup void Foam::fv::VoFFilmTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -283,20 +252,34 @@ void Foam::fv::VoFFilmTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == thermo_.rho()().name()) if (&rho == &thermo_.rho()())
{ {
// Explicit transfer into the VoF
eqn += eqn +=
filmVoFTransferRate<scalar> filmVoFTransferRate<scalar>
( (
&filmVoFTransfer::rhoTransferRate, &filmVoFTransfer::rhoTransferRate,
dimMass dimMass
) );
- fvm::Sp(alpha()*transferRate_, eqn.psi());
// Potentially implicit transfer out of the VoF
if (&rho == &eqn.psi())
{
eqn -= fvm::Sp(alpha()*transferRate_, eqn.psi());
}
else if (&alpha == &eqn.psi())
{
eqn -= fvm::Sp(rho()*transferRate_, eqn.psi());
}
else
{
eqn -= alpha()*rho()*transferRate_;
}
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << rho.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -306,8 +289,8 @@ void Foam::fv::VoFFilmTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -315,20 +298,30 @@ void Foam::fv::VoFFilmTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == thermo_.he().name()) if (&he == &thermo_.he())
{ {
// Explicit transfer into the VoF
eqn += eqn +=
filmVoFTransferRate<scalar> filmVoFTransferRate<scalar>
( (
&filmVoFTransfer::heTransferRate, &filmVoFTransfer::heTransferRate,
dimEnergy dimEnergy
) );
- fvm::Sp(alpha()*rho()*transferRate_, eqn.psi());
// Potentially implicit transfer out of the VoF
if (&he == &eqn.psi())
{
eqn -= fvm::Sp(alpha()*rho()*transferRate_, eqn.psi());
}
else
{
eqn -= alpha()*rho()*he*transferRate_;
}
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << he.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -337,8 +330,8 @@ void Foam::fv::VoFFilmTransfer::addSup
void Foam::fv::VoFFilmTransfer::addSup void Foam::fv::VoFFilmTransfer::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -346,13 +339,32 @@ void Foam::fv::VoFFilmTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (&U == &VoF_.U)
{
// Explicit transfer into the VoF
eqn += eqn +=
filmVoFTransferRate<vector> filmVoFTransferRate<vector>
( (
&filmVoFTransfer::UTransferRate, &filmVoFTransfer::UTransferRate,
dimMass*dimVelocity dimMass*dimVelocity
) );
- fvm::Sp(alpha_()*thermo_.rho()()*transferRate_, eqn.psi());
// Potentially implicit transfer out of the VoF
if (&U == &eqn.psi())
{
eqn -= fvm::Sp(alpha_()*rho()*transferRate_, eqn.psi());
}
else
{
eqn -= alpha_()*rho()*U*transferRate_;
}
}
else
{
FatalErrorInFunction
<< "Support for field " << U.name() << " is not implemented"
<< exit(FatalError);
}
} }

View File

@ -172,21 +172,14 @@ public:
virtual void correct(); virtual void correct();
// Add explicit and implicit contributions to compressible equation // Sources
//- Add implicit contribution to phase-fraction equation //- Add implicit contribution to phase continuity equation
virtual void addSup
(
fvMatrix<scalar>& eqn,
const word& fieldName
) const;
//- Add implicit contribution to phase density equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to phase energy equation //- Add implicit contribution to phase energy equation
@ -194,16 +187,16 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to mixture momentum equation //- Add implicit contribution to mixture momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -243,8 +243,8 @@ inline Foam::fv::filmVoFTransfer::VoFToFilmTransferRate
void Foam::fv::filmVoFTransfer::addSup void Foam::fv::filmVoFTransfer::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& alpha,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -252,20 +252,30 @@ void Foam::fv::filmVoFTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == film_.alpha.name()) if (&alpha == &film_.alpha)
{ {
// Explicit transfer into the film
eqn += eqn +=
VoFToFilmTransferRate<scalar> VoFToFilmTransferRate<scalar>
( (
&VoFFilmTransfer::rhoTransferRate, &VoFFilmTransfer::rhoTransferRate,
dimMass dimMass
) );
- fvm::Sp(transferRate_*rho(), eqn.psi());
// Potentially implicit transfer out of the film
if (&alpha == &eqn.psi())
{
eqn -= fvm::Sp(rho()*transferRate_, eqn.psi());
}
else
{
eqn -= alpha()*rho()*transferRate_;
}
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << alpha.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -275,8 +285,8 @@ void Foam::fv::filmVoFTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -284,20 +294,30 @@ void Foam::fv::filmVoFTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == film_.thermo.he().name()) if (&he == &film_.thermo.he())
{ {
// Explicit transfer into the film
eqn += eqn +=
VoFToFilmTransferRate<scalar> VoFToFilmTransferRate<scalar>
( (
&VoFFilmTransfer::heTransferRate, &VoFFilmTransfer::heTransferRate,
dimEnergy dimEnergy
) );
- fvm::Sp(alpha()*rho()*transferRate_, eqn.psi());
// Potentially implicit transfer out of the film
if (&he == &eqn.psi())
{
eqn -= fvm::Sp(alpha()*rho()*transferRate_, eqn.psi());
}
else
{
eqn -= alpha()*rho()*he*transferRate_;
}
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << he.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -307,8 +327,8 @@ void Foam::fv::filmVoFTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -316,13 +336,32 @@ void Foam::fv::filmVoFTransfer::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (&U == &film_.U)
{
// Explicit transfer into the film
eqn += eqn +=
VoFToFilmTransferRate<vector> VoFToFilmTransferRate<vector>
( (
&VoFFilmTransfer::UTransferRate, &VoFFilmTransfer::UTransferRate,
dimMomentum dimMomentum
) );
- fvm::Sp(alpha()*rho()*transferRate_, eqn.psi());
// Potentially implicit transfer out of the film
if (&U == &eqn.psi())
{
eqn -= fvm::Sp(alpha()*rho()*transferRate_, eqn.psi());
}
else
{
eqn -= alpha()*rho()*U()*transferRate_;
}
}
else
{
FatalErrorInFunction
<< "Support for field " << U.name() << " is not implemented"
<< exit(FatalError);
}
} }

View File

@ -147,32 +147,32 @@ public:
virtual void correct(); virtual void correct();
// Add explicit and implicit contributions to compressible equation // Sources
//- Add explicit contribution to phase continuity //- Add source to phase continuity equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho,
const volScalarField& alpha, const volScalarField& alpha,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn
const word& fieldName
) const; ) const;
//- Add explicit contribution to phase energy equation //- Add source to phase energy equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to mixture momentum equation //- Add source to mixture momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -142,7 +142,7 @@ void Foam::solvers::isothermalFluid::correctBuoyantPressure()
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh)) fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phiHbyA) + fvm::div(phid, p_rgh) + fvc::div(phiHbyA) + fvm::div(phid, p_rgh)
== ==
fvModels().source(psi, p_rgh, rho.name()) fvModels().sourceProxy(rho, p_rgh)
); );
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
@ -183,7 +183,7 @@ void Foam::solvers::isothermalFluid::correctBuoyantPressure()
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh)) fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phiHbyA) + fvc::div(phiHbyA)
== ==
fvModels().source(psi, p_rgh, rho.name()) fvModels().sourceProxy(rho, p_rgh)
); );
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())

View File

@ -130,7 +130,7 @@ void Foam::solvers::isothermalFluid::correctPressure()
fvc::ddt(rho) + psi*correction(fvm::ddt(p)) fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phiHbyA) + fvm::div(phid, p) + fvc::div(phiHbyA) + fvm::div(phid, p)
== ==
fvModels().source(psi, p, rho.name()) fvModels().sourceProxy(rho, p)
); );
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
@ -179,7 +179,7 @@ void Foam::solvers::isothermalFluid::correctPressure()
fvc::ddt(rho) + psi*correction(fvm::ddt(p)) fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phiHbyA) + fvc::div(phiHbyA)
== ==
fvModels().source(psi, p, rho.name()) fvModels().sourceProxy(rho, p)
); );
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())

View File

@ -102,7 +102,7 @@ Foam::solvers::multiphaseEuler::compressibilityEqns
// Option sources // Option sources
if (fvModels().addsSupToField(rho.name())) if (fvModels().addsSupToField(rho.name()))
{ {
pEqnComp -= (fvModels().source(alpha, rho) & rho)/rho; pEqnComp -= fvModels().sourceProxy(alpha, rho, p_rgh)/rho;
} }
// Mass transfer // Mass transfer

View File

@ -131,8 +131,8 @@ template<class RhoType>
void Foam::fv::interfaceTurbulenceDamping::addRhoSup void Foam::fv::interfaceTurbulenceDamping::addRhoSup
( (
const RhoType& rho, const RhoType& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -154,12 +154,12 @@ void Foam::fv::interfaceTurbulenceDamping::addRhoSup
movingPhases[phasei]*sqr(movingPhases[phasei].thermo().nu()()()); movingPhases[phasei]*sqr(movingPhases[phasei].thermo().nu()()());
} }
if (fieldName == "epsilon") if (field.name() == "epsilon")
{ {
eqn += rho*interfaceFraction(phase_)*C2_*aSqrnu*turbulence_.k()() eqn += rho*interfaceFraction(phase_)*C2_*aSqrnu*turbulence_.k()()
/pow4(delta_); /pow4(delta_);
} }
else if (fieldName == "omega") else if (field.name() == "omega")
{ {
eqn += rho*interfaceFraction(phase_)*beta_*aSqrnu eqn += rho*interfaceFraction(phase_)*beta_*aSqrnu
/(sqr(betaStar_)*pow4(delta_)); /(sqr(betaStar_)*pow4(delta_));
@ -167,7 +167,7 @@ void Foam::fv::interfaceTurbulenceDamping::addRhoSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -241,22 +241,22 @@ Foam::wordList Foam::fv::interfaceTurbulenceDamping::addSupFields() const
void Foam::fv::interfaceTurbulenceDamping::addSup void Foam::fv::interfaceTurbulenceDamping::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
addRhoSup(one(), eqn, fieldName); addRhoSup(one(), field, eqn);
} }
void Foam::fv::interfaceTurbulenceDamping::addSup void Foam::fv::interfaceTurbulenceDamping::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
addRhoSup(rho(), eqn, fieldName); addRhoSup(rho(), field, eqn);
} }
@ -264,8 +264,8 @@ void Foam::fv::interfaceTurbulenceDamping::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -273,17 +273,17 @@ void Foam::fv::interfaceTurbulenceDamping::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
volScalarField::Internal aSqrnu const volScalarField::Internal aSqrnu
( (
alpha*sqr(phase_.thermo().nu()()()) alpha*sqr(phase_.thermo().nu()()())
); );
if (fieldName == IOobject::groupName("epsilon", phaseName_)) if (field.name() == IOobject::groupName("epsilon", phaseName_))
{ {
eqn += rho()*interfaceFraction(alpha) eqn += rho()*interfaceFraction(alpha)
*C2_*aSqrnu*turbulence_.k()()/pow4(delta_); *C2_*aSqrnu*turbulence_.k()()/pow4(delta_);
} }
else if (fieldName == IOobject::groupName("omega", phaseName_)) else if (field.name() == IOobject::groupName("omega", phaseName_))
{ {
eqn += rho()*interfaceFraction(alpha) eqn += rho()*interfaceFraction(alpha)
*beta_*aSqrnu/(sqr(betaStar_)*pow4(delta_)); *beta_*aSqrnu/(sqr(betaStar_)*pow4(delta_));
@ -291,7 +291,7 @@ void Foam::fv::interfaceTurbulenceDamping::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -131,8 +131,8 @@ class interfaceTurbulenceDamping
void addRhoSup void addRhoSup
( (
const RhoType& rho, const RhoType& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
@ -162,33 +162,37 @@ public:
// Member Functions // Member Functions
// Checks
//- Return the list of fields for which the option adds source term //- Return the list of fields for which the option adds source term
// to the transport equation // to the transport equation
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
//- Add explicit contribution to mixture epsilon or omega equation
// Sources
//- Add source to mixture epsilon or omega equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add explicit contribution to compressible //- Add source to compressible mixture epsilon or omega equation
// mixture epsilon or omega equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add explicit contribution to phase epsilon or omega equation //- Add source to phase epsilon or omega equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -50,10 +50,11 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fv::phaseTurbulenceStabilisation::addSup void Foam::fv::phaseTurbulenceStabilisation::addAlphaRhoSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
const volScalarField& field,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn,
tmp<volScalarField> tmp<volScalarField>
(phaseCompressible::momentumTransportModel::*psi)() const (phaseCompressible::momentumTransportModel::*psi)() const
@ -184,36 +185,39 @@ void Foam::fv::phaseTurbulenceStabilisation::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (fieldName == IOobject::groupName("k", phaseName_)) if (field.name() == IOobject::groupName("k", phaseName_))
{ {
addSup addAlphaRhoSup
( (
alpha, alpha,
rho, rho,
field,
eqn, eqn,
&phaseCompressible::momentumTransportModel::k &phaseCompressible::momentumTransportModel::k
); );
} }
else if (fieldName == IOobject::groupName("epsilon", phaseName_)) else if (field.name() == IOobject::groupName("epsilon", phaseName_))
{ {
addSup addAlphaRhoSup
( (
alpha, alpha,
rho, rho,
field,
eqn, eqn,
&phaseCompressible::momentumTransportModel::epsilon &phaseCompressible::momentumTransportModel::epsilon
); );
} }
else if (fieldName == IOobject::groupName("omega", phaseName_)) else if (field.name() == IOobject::groupName("omega", phaseName_))
{ {
addSup addAlphaRhoSup
( (
alpha, alpha,
rho, rho,
field,
eqn, eqn,
&phaseCompressible::momentumTransportModel::omega &phaseCompressible::momentumTransportModel::omega
); );
@ -221,7 +225,7 @@ void Foam::fv::phaseTurbulenceStabilisation::addSup
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented" << "Support for field " << field.name() << " is not implemented"
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -112,10 +112,11 @@ class phaseTurbulenceStabilisation
// Private Member Functions // Private Member Functions
//- Add contribution to phase psi equation //- Add contribution to phase psi equation
void addSup void addAlphaRhoSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
const volScalarField& field,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn,
tmp<volScalarField> tmp<volScalarField>
(phaseCompressible::momentumTransportModel::*psi)() const (phaseCompressible::momentumTransportModel::*psi)() const
@ -148,19 +149,22 @@ public:
// Member Functions // Member Functions
// Checks
//- Return the list of fields for which the option adds source term //- Return the list of fields for which the option adds source term
// to the transport equation // to the transport equation
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
using fvModel::addSup;
// Sources
//- Add contribution to phase k, epsilon or omega equation //- Add contribution to phase k, epsilon or omega equation
virtual void addSup virtual void addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -83,19 +83,11 @@ void Foam::solvers::twoPhaseSolver::incompressiblePressureCorrector
// Update the pressure BCs to ensure flux consistency // Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF); constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Cache the phase change pressure source // Cache any sources
fvScalarMatrix Sp_rgh fvScalarMatrix p_rghEqnSource
( (
fvModels().source fvModels().sourceProxy(alpha1, p_rgh)
( + fvModels().sourceProxy(alpha2, p_rgh)
volScalarField::New
(
"1",
mesh,
dimensionedScalar(dimless/dimPressure, 1)
),
p_rgh
)
); );
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
@ -103,7 +95,7 @@ void Foam::solvers::twoPhaseSolver::incompressiblePressureCorrector
fvScalarMatrix p_rghEqn fvScalarMatrix p_rghEqn
( (
fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh) fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
== Sp_rgh == p_rghEqnSource
); );
p_rghEqn.setReference p_rghEqn.setReference

View File

@ -127,8 +127,8 @@ ${typeName}FvModel${SourceType}::
void ${typeName}FvModel${SourceType}::addSup void ${typeName}FvModel${SourceType}::addSup
( (
fvMatrix<${TemplateType}>& eqn, const VolField<${TemplateType}>& field,
const word& fieldName fvMatrix<${TemplateType}>& eqn
) const ) const
{ {
if (${verbose}) if (${verbose})
@ -145,8 +145,8 @@ void ${typeName}FvModel${SourceType}::addSup
void ${typeName}FvModel${SourceType}::addSup void ${typeName}FvModel${SourceType}::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn, const VolField<${TemplateType}>& field,
const word& fieldName fvMatrix<${TemplateType}>& eqn
) const ) const
{ {
if (${verbose}) if (${verbose})
@ -164,8 +164,8 @@ void ${typeName}FvModel${SourceType}::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn, const VolField<${TemplateType}>& field,
const word& fieldName fvMatrix<${TemplateType}>& eqn
) const ) const
{ {
if (${verbose}) if (${verbose})

View File

@ -89,8 +89,8 @@ public:
//- Explicit and implicit matrix contributions //- Explicit and implicit matrix contributions
virtual void addSup virtual void addSup
( (
fvMatrix<${TemplateType}>& eqn, const VolField<${TemplateType}>& field,
const word& fieldName fvMatrix<${TemplateType}>& eqn
) const; ) const;
//- Explicit and implicit matrix contributions for compressible //- Explicit and implicit matrix contributions for compressible
@ -98,8 +98,8 @@ public:
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn, const VolField<${TemplateType}>& field,
const word& fieldName fvMatrix<${TemplateType}>& eqn
) const; ) const;
//- Explicit and implicit matrix contributions for phase equations //- Explicit and implicit matrix contributions for phase equations
@ -107,8 +107,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn, const VolField<${TemplateType}>& field,
const word& fieldName fvMatrix<${TemplateType}>& eqn
) const; ) const;

View File

@ -37,11 +37,16 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::fvModel::addSupType(fvMatrix<Type>& eqn) const
{}
template<class Type> template<class Type>
void Foam::fvModel::addSupType void Foam::fvModel::addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{} {}
@ -50,8 +55,8 @@ template<class Type>
void Foam::fvModel::addSupType void Foam::fvModel::addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{} {}
@ -61,8 +66,8 @@ void Foam::fvModel::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{} {}
@ -175,13 +180,16 @@ Foam::scalar Foam::fvModel::maxDeltaT() const
} }
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_SUP, fvModel); FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_SUP, fvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_SUP, fvModel); FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_FIELD_SUP, fvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, fvModel); FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP, fvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP, fvModel)
void Foam::fvModel::preUpdateMesh() void Foam::fvModel::preUpdateMesh()

View File

@ -80,12 +80,16 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Add a source term to an equation
template<class Type>
void addSupType(fvMatrix<Type>& eqn) const;
//- Add a source term to an equation //- Add a source term to an equation
template<class Type> template<class Type>
void addSupType void addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
@ -93,8 +97,8 @@ protected:
void addSupType void addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a phase equation //- Add a source term to a phase equation
@ -103,19 +107,17 @@ protected:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Return a source for an equation
//- Return source for equation with specified name and dimensions
template<class Type, class ... AlphaRhoFieldTypes> template<class Type, class ... AlphaRhoFieldTypes>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceTerm
( (
const VolField<Type>& field, const VolField<Type>& eqnField,
const word& fieldName,
const dimensionSet& ds, const dimensionSet& ds,
const AlphaRhoFieldTypes& ... alphaRhos const AlphaRhoFieldTypes& ... alphaRhoFields
) const; ) const;
@ -145,29 +147,35 @@ public:
// Static Member Functions // Static Member Functions
//- Return the dimensions of the matrix of a source term //- Return the dimensions of the matrix of a source term
template template<class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
< static dimensionSet sourceDims
class Type,
class AlphaRhoFieldType,
class ... AlphaRhoFieldTypes
>
inline static dimensionSet sourceDims
( (
const VolField<Type>& field,
const dimensionSet& ds, const dimensionSet& ds,
const AlphaRhoFieldType& alphaRho, const AlphaRhoFieldType& alphaRhoField,
const AlphaRhoFieldTypes& ... alphaRhos const AlphaRhoFieldTypes& ... alphaRhoFields
); );
//- Return the dimensions of the matrix of a source term (base //- Return the dimensions of the matrix of a source term (base
// condition for the above) // condition for the above)
template<class Type> inline static const dimensionSet& sourceDims(const dimensionSet& ds);
inline static dimensionSet sourceDims
//- Return the name of the field associated with a source term
template<class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
static const word& fieldName
( (
const VolField<Type>& field, const AlphaRhoFieldType& alphaRhoField,
const dimensionSet& ds const AlphaRhoFieldTypes& ... alphaRhoFields
); );
//- Return the name of the field associated with a source term (base
// condition for the above)
template<class AlphaRhoFieldType>
static const word& fieldName(const AlphaRhoFieldType& alphaRhoField);
//- Return the name of the field associated with a source term. Special
// overload for volume sources with no associated field.
static const word& fieldName();
// Constructors // Constructors
@ -267,13 +275,23 @@ public:
// Sources // Sources
//- Add a source term to an equation //- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP)
//- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP)
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
//- Return source for an equation
template<class Type>
tmp<fvMatrix<Type>> sourceProxy
(
const VolField<Type>& eqnField
) const;
//- Return source for an equation //- Return source for an equation
template<class Type> template<class Type>
@ -282,12 +300,12 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for an equation with a specified name //- Return source for an equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceProxy
( (
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const; ) const;
//- Return source for a compressible equation //- Return source for a compressible equation
@ -298,13 +316,13 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for a compressible equation with a specified name //- Return source for a compressible equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceProxy
( (
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const; ) const;
//- Return source for a phase equation //- Return source for a phase equation
@ -316,14 +334,14 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for a phase equation with a specified name //- Return source for a phase equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceProxy
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const; ) const;
//- Return source for a phase equation //- Return source for a phase equation
@ -360,14 +378,6 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for an equation with a second time derivative
template<class Type>
tmp<fvMatrix<Type>> d2dt2
(
const VolField<Type>& field,
const word& fieldName
) const;
// Mesh changes // Mesh changes

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,6 +23,25 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvModel.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
inline const Foam::dimensionSet& Foam::fvModel::sourceDims
(
const dimensionSet& ds
)
{
return ds;
}
inline const Foam::word& Foam::fvModel::fieldName()
{
return word::null;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::fvModel::name() const inline const Foam::word& Foam::fvModel::name() const

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,60 +24,69 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#define DEFINE_FV_MODEL_ADD_SUP(Type, nullArg) \ #define DEFINE_FV_MODEL_ADD_SUP(Type, nullArg) \
virtual void addSup \ virtual void addSup(fvMatrix<Type>& eqn) const;
( \
fvMatrix<Type>& eqn, \
const word& fieldName \
) const;
#define IMPLEMENT_FV_MODEL_ADD_SUP(Type, modelType) \ #define IMPLEMENT_FV_MODEL_ADD_SUP(Type, modelType) \
void Foam::modelType::addSup \ void Foam::modelType::addSup(fvMatrix<Type>& eqn) const \
( \
fvMatrix<Type>& eqn, \
const word& fieldName \
) const \
{ \ { \
addSupType(eqn, fieldName); \ addSupType(eqn); \
} }
#define DEFINE_FV_MODEL_ADD_RHO_SUP(Type, nullArg) \ #define DEFINE_FV_MODEL_ADD_FIELD_SUP(Type, nullArg) \
virtual void addSup \
( \
const VolField<Type>& field, \
fvMatrix<Type>& eqn \
) const;
#define IMPLEMENT_FV_MODEL_ADD_FIELD_SUP(Type, modelType) \
void Foam::modelType::addSup \
( \
const VolField<Type>& field, \
fvMatrix<Type>& eqn \
) const \
{ \
addSupType(field, eqn); \
}
#define DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP(Type, nullArg) \
virtual void addSup \ virtual void addSup \
( \ ( \
const volScalarField& rho, \ const volScalarField& rho, \
fvMatrix<Type>& eqn, \ const VolField<Type>& field, \
const word& fieldName \ fvMatrix<Type>& eqn \
) const; ) const;
#define IMPLEMENT_FV_MODEL_ADD_RHO_SUP(Type, modelType) \ #define IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP(Type, modelType) \
void Foam::modelType::addSup \ void Foam::modelType::addSup \
( \ ( \
const volScalarField& rho, \ const volScalarField& rho, \
fvMatrix<Type>& eqn, \ const VolField<Type>& field, \
const word& fieldName \ fvMatrix<Type>& eqn \
) const \ ) const \
{ \ { \
addSupType(rho, eqn, fieldName); \ addSupType(rho, field, eqn); \
} }
#define DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP(Type, nullArg) \ #define DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, nullArg) \
virtual void addSup \ virtual void addSup \
( \ ( \
const volScalarField& alpha, \ const volScalarField& alpha, \
const volScalarField& rho, \ const volScalarField& rho, \
fvMatrix<Type>& eqn, \ const VolField<Type>& field, \
const word& fieldName \ fvMatrix<Type>& eqn \
) const; ) const;
#define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP(Type, modelType) \ #define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, modelType) \
void Foam::modelType::addSup \ void Foam::modelType::addSup \
( \ ( \
const volScalarField& alpha, \ const volScalarField& alpha, \
const volScalarField& rho, \ const volScalarField& rho, \
fvMatrix<Type>& eqn, \ const VolField<Type>& field, \
const word& fieldName \ fvMatrix<Type>& eqn \
) const \ ) const \
{ \ { \
addSupType(alpha, rho, eqn, fieldName); \ addSupType(alpha, rho, field, eqn); \
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,56 +23,66 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // #include "fvModel.H"
template<class Type, class AlphaRhoFieldType, class ... AlphaRhoFieldTypes> // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
template<class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
Foam::dimensionSet Foam::fvModel::sourceDims Foam::dimensionSet Foam::fvModel::sourceDims
( (
const VolField<Type>& field,
const dimensionSet& ds, const dimensionSet& ds,
const AlphaRhoFieldType& alphaRho, const AlphaRhoFieldType& alphaRhoField,
const AlphaRhoFieldTypes& ... alphaRhos const AlphaRhoFieldTypes& ... alphaRhoFields
) )
{ {
return alphaRho.dimensions()*sourceDims(field, ds, alphaRhos ...); return alphaRhoField.dimensions()*sourceDims(ds, alphaRhoFields ...);
} }
template<class Type> template<class AlphaRhoFieldType, class ... AlphaRhoFieldTypes>
Foam::dimensionSet Foam::fvModel::sourceDims const Foam::word& Foam::fvModel::fieldName
( (
const VolField<Type>& field, const AlphaRhoFieldType& alphaRhoField,
const dimensionSet& ds const AlphaRhoFieldTypes& ... alphaRhoFields
) )
{ {
return field.dimensions()*ds; return fieldName(alphaRhoFields ...);
}
template<class AlphaRhoFieldType>
const Foam::word& Foam::fvModel::fieldName
(
const AlphaRhoFieldType& alphaRhoField
)
{
return alphaRhoField.name();
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type, class ... AlphaRhoFieldTypes> template<class Type, class ... AlphaRhoFieldTypes>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::sourceTerm
( (
const VolField<Type>& field, const VolField<Type>& eqnField,
const word& fieldName,
const dimensionSet& ds, const dimensionSet& ds,
const AlphaRhoFieldTypes& ... alphaRhos const AlphaRhoFieldTypes& ... alphaRhoFields
) const ) const
{ {
tmp<fvMatrix<Type>> tmtx tmp<fvMatrix<Type>> tmtx
( (
new fvMatrix<Type> new fvMatrix<Type>
( (
field, eqnField,
sourceDims(field, ds, alphaRhos ...) sourceDims(ds, alphaRhoFields ...)
) )
); );
fvMatrix<Type>& mtx = tmtx.ref(); fvMatrix<Type>& mtx = tmtx.ref();
if (addsSupToField(fieldName)) if (addsSupToField(fieldName(alphaRhoFields ...)))
{ {
addSup(alphaRhos ..., mtx, fieldName); addSup(alphaRhoFields ..., mtx);
} }
return tmtx; return tmtx;
@ -82,23 +92,33 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::sourceProxy
( (
const VolField<Type>& field const VolField<Type>& eqnField
) const ) const
{ {
return this->source(field, field.name()); return sourceTerm(eqnField, dimVolume/dimTime);
} }
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
( (
const VolField<Type>& field, const VolField<Type>& field
const word& fieldName
) const ) const
{ {
return source(field, fieldName, dimVolume/dimTime); return sourceTerm(field, dimVolume/dimTime, field);
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::sourceProxy
(
const VolField<Type>& field,
const VolField<Type>& eqnField
) const
{
return sourceTerm(eqnField, dimVolume/dimTime, field);
} }
@ -109,19 +129,19 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(rho, field, field.name()); return sourceTerm(field, dimVolume/dimTime, rho, field);
} }
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::sourceProxy
( (
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const ) const
{ {
return source(field, fieldName, dimVolume/dimTime, rho); return sourceTerm(eqnField, dimVolume/dimTime, rho, field);
} }
@ -133,20 +153,20 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(alpha, rho, field, field.name()); return sourceTerm(field, dimVolume/dimTime, alpha, rho, field);
} }
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::sourceProxy
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const ) const
{ {
return source(field, fieldName, dimVolume/dimTime, alpha, rho); return sourceTerm(eqnField, dimVolume/dimTime, alpha, rho, field);
} }
@ -158,7 +178,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(field, field.name()); return this->source(field);
} }
@ -185,7 +205,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
dimensionedScalar(dimless, 1.0) dimensionedScalar(dimless, 1.0)
); );
return this->source(alpha, one, field, field.name()); return this->source(alpha, one, field);
} }
@ -197,30 +217,18 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(rho, field, field.name()); return this->source(rho, field);
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::d2dt2 Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::d2dt2
( (
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->d2dt2(field, field.name()); return sourceTerm(field, dimVolume/sqr(dimTime), field);
} }
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModel::d2dt2
(
const VolField<Type>& field,
const word& fieldName
) const
{
return source(field, fieldName, dimVolume/sqr(dimTime));
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -81,14 +81,13 @@ class fvModels
//- Check that all fvModels have been applied //- Check that all fvModels have been applied
void checkApplied() const; void checkApplied() const;
//- Return source for equation with specified name and dimensions //- Return a source for an equation
template<class Type, class ... AlphaRhoFieldTypes> template<class Type, class ... AlphaRhoFieldTypes>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceTerm
( (
const VolField<Type>& field, const VolField<Type>& eqnField,
const word& fieldName,
const dimensionSet& ds, const dimensionSet& ds,
const AlphaRhoFieldTypes& ... alphaRhos const AlphaRhoFieldTypes& ... alphaRhoFields
) const; ) const;
@ -153,6 +152,13 @@ public:
// e.g. solve equations, update model, for film, Lagrangian etc. // e.g. solve equations, update model, for film, Lagrangian etc.
virtual void correct(); virtual void correct();
//- Return source for an equation
template<class Type>
tmp<fvMatrix<Type>> sourceProxy
(
const VolField<Type>& eqnField
) const;
//- Return source for an equation //- Return source for an equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> source
@ -160,12 +166,12 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for an equation with a specified name //- Return source for an equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceProxy
( (
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const; ) const;
//- Return source for a compressible equation //- Return source for a compressible equation
@ -176,13 +182,13 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for a compressible equation with a specified name //- Return source for a compressible equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceProxy
( (
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const; ) const;
//- Return source for a phase equation //- Return source for a phase equation
@ -194,14 +200,14 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for a phase equation with a specified name //- Return source for a phase equation
template<class Type> template<class Type>
tmp<fvMatrix<Type>> source tmp<fvMatrix<Type>> sourceProxy
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const; ) const;
//- Return source for a phase equation //- Return source for a phase equation
@ -238,14 +244,6 @@ public:
const VolField<Type>& field const VolField<Type>& field
) const; ) const;
//- Return source for an equation with a second time derivative
template<class Type>
tmp<fvMatrix<Type>> d2dt2
(
const VolField<Type>& field,
const word& fieldName
) const;
// Mesh changes // Mesh changes

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,15 +23,16 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvModels.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type, class ... AlphaRhoFieldTypes> template<class Type, class ... AlphaRhoFieldTypes>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::sourceTerm
( (
const VolField<Type>& field, const VolField<Type>& eqnField,
const word& fieldName,
const dimensionSet& ds, const dimensionSet& ds,
const AlphaRhoFieldTypes& ... alphaRhos const AlphaRhoFieldTypes& ... alphaRhoFields
) const ) const
{ {
checkApplied(); checkApplied();
@ -40,14 +41,16 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
( (
new fvMatrix<Type> new fvMatrix<Type>
( (
field, eqnField,
fvModel::sourceDims(field, ds, alphaRhos ...) fvModel::sourceDims(ds, alphaRhoFields ...)
) )
); );
fvMatrix<Type>& mtx = tmtx.ref(); fvMatrix<Type>& mtx = tmtx.ref();
const PtrListDictionary<fvModel>& modelList(*this); const PtrListDictionary<fvModel>& modelList(*this);
const word& fieldName = fvModel::fieldName(alphaRhoFields ...);
forAll(modelList, i) forAll(modelList, i)
{ {
const fvModel& model = modelList[i]; const fvModel& model = modelList[i];
@ -62,7 +65,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
<< fieldName << endl; << fieldName << endl;
} }
model.addSup(alphaRhos ..., mtx, fieldName); model.addSup(alphaRhoFields ..., mtx);
} }
} }
@ -73,23 +76,33 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::sourceProxy
( (
const VolField<Type>& field const VolField<Type>& eqnField
) const ) const
{ {
return this->source(field, field.name()); return sourceTerm(eqnField, dimVolume/dimTime);
} }
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
( (
const VolField<Type>& field, const VolField<Type>& field
const word& fieldName
) const ) const
{ {
return source(field, fieldName, dimVolume/dimTime); return sourceTerm(field, dimVolume/dimTime, field);
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::sourceProxy
(
const VolField<Type>& field,
const VolField<Type>& eqnField
) const
{
return sourceTerm(eqnField, dimVolume/dimTime, field);
} }
@ -100,19 +113,19 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(rho, field, field.name()); return sourceTerm(field, dimVolume/dimTime, rho, field);
} }
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::sourceProxy
( (
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const ) const
{ {
return source(field, fieldName, dimVolume/dimTime, rho); return sourceTerm(eqnField, dimVolume/dimTime, rho, field);
} }
@ -124,20 +137,20 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(alpha, rho, field, field.name()); return sourceTerm(field, dimVolume/dimTime, alpha, rho, field);
} }
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::sourceProxy
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
const VolField<Type>& field, const VolField<Type>& field,
const word& fieldName const VolField<Type>& eqnField
) const ) const
{ {
return source(field, fieldName, dimVolume/dimTime, alpha, rho); return sourceTerm(eqnField, dimVolume/dimTime, alpha, rho, field);
} }
@ -149,7 +162,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(field, field.name()); return this->source(field);
} }
@ -176,7 +189,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
dimensionedScalar(dimless, 1.0) dimensionedScalar(dimless, 1.0)
); );
return this->source(alpha, one, field, field.name()); return this->source(alpha, one, field);
} }
@ -188,30 +201,17 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::source
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->source(rho, field, field.name()); return this->source(rho, field);
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::d2dt2 Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::d2dt2
( (
const VolField<Type>& field const VolField<Type>& field
) const ) const
{ {
return this->d2dt2(field, field.name()); return sourceTerm(field, dimVolume/sqr(dimTime), field);
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvModels::d2dt2
(
const VolField<Type>& field,
const word& fieldName
) const
{
return source(field, fieldName, dimVolume/sqr(dimTime));
} }

View File

@ -854,7 +854,9 @@ Foam::tmp<Foam::volScalarField::Internal> Foam::fvMatrix<Type>::Sp() const
"Sp(" + psi_.name() + ')', "Sp(" + psi_.name() + ')',
psi_.mesh(), psi_.mesh(),
dimensions_/psi_.dimensions()/dimVol, dimensions_/psi_.dimensions()/dimVol,
diag()/psi_.mesh().V() hasDiag()
? diag()/psi_.mesh().V()
: tmp<scalarField>(new scalarField(lduAddr().size(), scalar(0)))
) )
); );

View File

@ -168,38 +168,47 @@ Foam::fv::zeroDimensionalFixedPressureConstraint::constrainedFields() const
} }
const Foam::volScalarField::Internal& Foam::tmp<Foam::volScalarField::Internal>
Foam::fv::zeroDimensionalFixedPressureConstraint::pEqnSource Foam::fv::zeroDimensionalFixedPressureConstraint::pEqnSource
( (
const volScalarField& rho,
fvMatrix<scalar>& pEqn fvMatrix<scalar>& pEqn
) const ) const
{ {
// Ensure the corresponding fvModel exits // Ensure the corresponding fvModel exits
model(); model();
// Construct the source if it does not yet exist // Return zero if the source does not yet exist
if (!sourcePtr_.valid()) if (!sourcePtr_.valid())
{ {
sourcePtr_.set return
( volScalarField::Internal::New
new volScalarField::Internal
(
IOobject
( (
typedName("source"), typedName("source"),
mesh().time().timeName(),
mesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh(), mesh(),
dimensionedScalar(pEqn.dimensions()/dimVolume, 0) dimensionedScalar(pEqn.dimensions()/dimVolume, 0)
)
); );
} }
// Return the source, multiplying by density if needed
if (sourcePtr_->dimensions() == pEqn.dimensions()/dimVolume)
{
return sourcePtr_(); return sourcePtr_();
} }
else if (sourcePtr_->dimensions() == pEqn.dimensions()/dimMass)
{
return rho()*sourcePtr_();
}
else
{
FatalErrorInFunction
<< "Dimensions of equation for pressure "
<< pEqn.psi().name() << " not recognised"
<< exit(FatalError);
return tmp<volScalarField::Internal>(nullptr);
}
}
Foam::tmp<Foam::volScalarField::Internal> Foam::tmp<Foam::volScalarField::Internal>
@ -229,11 +238,26 @@ bool Foam::fv::zeroDimensionalFixedPressureConstraint::constrain
const word& fieldName const word& fieldName
) const ) const
{ {
// Construct the source if it does not yet exist // Create the source field if it does not already exist
pEqnSource(pEqn); if (!sourcePtr_.valid())
{
// Check the dimensions have not changed sourcePtr_.set
sourcePtr_->dimensions() = pEqn.dimensions()/dimVolume; (
new volScalarField::Internal
(
IOobject
(
typedName("source"),
mesh().time().timeName(),
mesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar(pEqn.dimensions()/dimVolume, 0)
)
);
}
// Remove the previous iteration's source from the pressure equation // Remove the previous iteration's source from the pressure equation
pEqn += sourcePtr_(); pEqn += sourcePtr_();

View File

@ -160,8 +160,9 @@ public:
// Constraints // Constraints
//- Return the mass or volume source for the pressure equation //- Return the mass or volume source for the pressure equation
const volScalarField::Internal& pEqnSource tmp<volScalarField::Internal> pEqnSource
( (
const volScalarField& rho,
fvMatrix<scalar>& pEqn fvMatrix<scalar>& pEqn
) const; ) const;

View File

@ -76,12 +76,12 @@ Foam::fv::zeroDimensionalFixedPressureModel::constraint() const
template<class Type> template<class Type>
void Foam::fv::zeroDimensionalFixedPressureModel::addSupType void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot add a fixed pressure source to field " << fieldName << "Cannot add a fixed pressure source of field " << field.name()
<< " because this field's equation is not in mass-conservative form" << " because this field's equation is not in mass-conservative form"
<< exit(FatalError); << exit(FatalError);
} }
@ -89,17 +89,26 @@ void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
void Foam::fv::zeroDimensionalFixedPressureModel::addSupType void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
( (
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (IOobject::member(fieldName) == constraint().rhoName()) if (IOobject::member(rho.name()) == constraint().rhoName())
{ {
eqn += constraint().massSource(eqn.psi()()); if (IOobject::member(eqn.psi().name()) == constraint().pName())
{
eqn += constraint().pEqnSource(rho, eqn);
} }
else else
{ {
addSupType<scalar>(eqn, fieldName); // error above eqn += constraint().massSource(rho());
}
}
else
{
// This is actually an incompressible single-phase equation. Rho is
// actually a property field. Fall back (and error).
addSupType<scalar>(rho, eqn);
} }
} }
@ -108,46 +117,45 @@ template<class Type>
void Foam::fv::zeroDimensionalFixedPressureModel::addSupType void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
if (&field != &eqn.psi())
{
FatalErrorInFunction
<< "Cannot add a fixed pressure source of field " << field.name()
<< " into an equation for field " << eqn.psi().name()
<< exit(FatalError);
}
eqn -= fvm::SuSp(-constraint().massSource(rho()), eqn.psi()); eqn -= fvm::SuSp(-constraint().massSource(rho()), eqn.psi());
} }
void Foam::fv::zeroDimensionalFixedPressureModel::addSupType void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
( (
const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn
const word& fieldName
) const ) const
{ {
if (IOobject::member(fieldName) == constraint().rhoName()) if (IOobject::member(rho.name()) == constraint().rhoName())
{ {
if (IOobject::member(eqn.psi().name()) == constraint().pName()) if (IOobject::member(eqn.psi().name()) == constraint().pName())
{ {
eqn += constraint().pEqnSource(eqn); eqn += alpha()*constraint().pEqnSource(rho, eqn);
} }
else if (IOobject::member(eqn.psi().name()) == constraint().rhoName()) else
{ {
// Phase density equation. Argument names are misleading.
const volScalarField& alpha = rho;
const volScalarField& rho = eqn.psi();
eqn += constraint().massSource(alpha(), rho()); eqn += constraint().massSource(alpha(), rho());
} }
else
{
FatalErrorInFunction
<< "Cannot add source for density field " << fieldName
<< " into an equation for " << eqn.psi().name()
<< exit(FatalError);
}
} }
else else
{ {
addSupType<scalar>(rho, eqn, fieldName); // This is actually a compressible single-phase equation. Alpha is
// actually rho, and rho is actually a property field. Fall back.
addSupType<scalar>(alpha, rho, eqn);
} }
} }
@ -157,47 +165,19 @@ void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
eqn -= fvm::SuSp(-constraint().massSource(alpha(), rho()), eqn.psi()); if (&field != &eqn.psi())
}
void Foam::fv::zeroDimensionalFixedPressureModel::addSupType
(
const volScalarField& alpha,
const volScalarField& rho,
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{
if (IOobject::member(fieldName) == constraint().rhoName())
{
if (IOobject::member(eqn.psi().name()) == constraint().pName())
{
eqn += alpha*constraint().pEqnSource(eqn);
}
else if (IOobject::member(eqn.psi().name()) == constraint().rhoName())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot add source for density field " << fieldName << "Cannot add a fixed pressure source of field " << field.name()
<< " into a phase-conservative equation for " << " into an equation for field " << eqn.psi().name()
<< eqn.psi().name() << exit(FatalError);
}
else
{
FatalErrorInFunction
<< "Cannot add source for density field " << fieldName
<< " into an equation for " << eqn.psi().name()
<< exit(FatalError); << exit(FatalError);
} }
}
else eqn -= fvm::SuSp(-constraint().massSource(alpha(), rho()), eqn.psi());
{
addSupType<scalar>(alpha, rho, eqn, fieldName);
}
} }
@ -243,23 +223,23 @@ bool Foam::fv::zeroDimensionalFixedPressureModel::addsSupToField
FOR_ALL_FIELD_TYPES FOR_ALL_FIELD_TYPES
( (
IMPLEMENT_FV_MODEL_ADD_SUP, IMPLEMENT_FV_MODEL_ADD_FIELD_SUP,
fv::zeroDimensionalFixedPressureModel fv::zeroDimensionalFixedPressureModel
); )
FOR_ALL_FIELD_TYPES FOR_ALL_FIELD_TYPES
( (
IMPLEMENT_FV_MODEL_ADD_RHO_SUP, IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP,
fv::zeroDimensionalFixedPressureModel fv::zeroDimensionalFixedPressureModel
); )
FOR_ALL_FIELD_TYPES FOR_ALL_FIELD_TYPES
( (
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP,
fv::zeroDimensionalFixedPressureModel fv::zeroDimensionalFixedPressureModel
); )
bool Foam::fv::zeroDimensionalFixedPressureModel::movePoints() bool Foam::fv::zeroDimensionalFixedPressureModel::movePoints()

View File

@ -79,26 +79,34 @@ class zeroDimensionalFixedPressureModel
//- Add a source term to an equation //- Add a source term to an equation
template<class Type> template<class Type>
void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const; void addSupType
(
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const;
//- Add a source term to a scalar equation //- Add a source term to a compressible continuity equation
void addSupType(fvMatrix<scalar>& eqn, const word& fieldName) const; void addSupType
(
const volScalarField& rho,
fvMatrix<scalar>& eqn
) const;
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
template<class Type> template<class Type>
void addSupType void addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a scalar compressible equation //- Add a source term to a phase continuity equation
void addSupType void addSupType
( (
const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn
const word& fieldName
) const; ) const;
//- Add a source term to a phase equation //- Add a source term to a phase equation
@ -107,17 +115,8 @@ class zeroDimensionalFixedPressureModel
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const;
//- Add a source term to a scalar phase equation
void addSupType
(
const volScalarField& alpha,
const volScalarField& rho,
fvMatrix<scalar>& eqn,
const word& fieldName
) const; ) const;
@ -155,13 +154,13 @@ public:
// Sources // Sources
//- Add a source term to an equation //- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP)
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
// Mesh changes // Mesh changes

View File

@ -23,6 +23,7 @@ derived/phaseLimitStabilisation/phaseLimitStabilisation.C
derived/accelerationSource/accelerationSource.C derived/accelerationSource/accelerationSource.C
derived/volumeFractionSource/volumeFractionSource.C derived/volumeFractionSource/volumeFractionSource.C
derived/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C derived/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C
derived/volumeSource/volumeSource.C
derived/massSource/massSource.C derived/massSource/massSource.C
derived/heatSource/heatSource.C derived/heatSource/heatSource.C
derived/heatTransfer/heatTransfer.C derived/heatTransfer/heatTransfer.C

View File

@ -51,6 +51,32 @@ void Foam::fv::accelerationSource::readCoeffs()
} }
template<class AlphaRhoFieldType>
void Foam::fv::accelerationSource::add
(
const AlphaRhoFieldType& alphaRho,
fvMatrix<vector>& eqn
) const
{
const DimensionedField<scalar, volMesh>& V = mesh().V();
const scalar t = mesh().time().value();
const scalar dt = mesh().time().deltaTValue();
const vector dU =
velocity_->value(mesh().time().timeToUserTime(t))
- velocity_->value(mesh().time().timeToUserTime(t - dt));
const vector a = dU/mesh().time().deltaTValue();
const labelUList cells = set_.cells();
forAll(cells, i)
{
const label celli = cells[i];
eqn.source()[celli] -= V[celli]*alphaRho[celli]*a;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::accelerationSource::accelerationSource Foam::fv::accelerationSource::accelerationSource
@ -80,22 +106,22 @@ Foam::wordList Foam::fv::accelerationSource::addSupFields() const
void Foam::fv::accelerationSource::addSup void Foam::fv::accelerationSource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
add(geometricOneField(), eqn, fieldName); add(geometricOneField(), eqn);
} }
void Foam::fv::accelerationSource::addSup void Foam::fv::accelerationSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
add(rho, eqn, fieldName); add(rho, eqn);
} }
@ -103,11 +129,11 @@ void Foam::fv::accelerationSource::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
add((alpha*rho)(), eqn, fieldName); add((alpha*rho)(), eqn);
} }

View File

@ -96,11 +96,10 @@ class accelerationSource
//- Source term to momentum equation //- Source term to momentum equation
template<class AlphaRhoFieldType> template<class AlphaRhoFieldType>
void add inline void add
( (
const AlphaRhoFieldType& rho, const AlphaRhoFieldType& rho,
fvMatrix<vector>& eqn, fvMatrix<vector>& eqn
const word& fieldName
) const; ) const;
@ -141,16 +140,16 @@ public:
//- Source term to momentum equation //- Source term to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to compressible momentum equation //- Source term to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to phase momentum equation //- Source term to phase momentum equation
@ -158,8 +157,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
@ -192,12 +191,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "accelerationSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class AlphaRhoFieldType>
void Foam::fv::accelerationSource::add
(
const AlphaRhoFieldType& alphaRho,
fvMatrix<vector>& eqn,
const word& fieldName
) const
{
const DimensionedField<scalar, volMesh>& V = mesh().V();
const scalar t = mesh().time().value();
const scalar dt = mesh().time().deltaTValue();
const vector dU =
velocity_->value(mesh().time().timeToUserTime(t))
- velocity_->value(mesh().time().timeToUserTime(t - dt));
const vector a = dU/mesh().time().deltaTValue();
const labelUList cells = set_.cells();
forAll(cells, i)
{
const label celli = cells[i];
eqn.source()[celli] -= V[celli]*alphaRho[celli]*a;
}
}
// ************************************************************************* //

View File

@ -95,6 +95,37 @@ void Foam::fv::actuationDiskSource::readCoeffs()
} }
template<class AlphaFieldType, class RhoFieldType>
void Foam::fv::actuationDiskSource::addActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,
const scalarField& Vcells,
const AlphaFieldType& alpha,
const RhoFieldType& rho,
const vectorField& U
) const
{
const scalar a = 1 - Cp_/Ct_;
const vector dHat(diskDir_/mag(diskDir_));
scalar dHatUo(vGreat);
if (upstreamCellId_ != -1)
{
dHatUo = dHat & U[upstreamCellId_];
}
reduce(dHatUo, minOp<scalar>());
const vector T = 2*diskArea_*sqr(dHatUo)*a*(1 - a)*dHat;
forAll(cells, i)
{
Usource[cells[i]] +=
(alpha[cells[i]]*rho[cells[i]]*(Vcells[cells[i]]/set_.V()))*T;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::actuationDiskSource::actuationDiskSource Foam::fv::actuationDiskSource::actuationDiskSource
@ -130,19 +161,15 @@ Foam::wordList Foam::fv::actuationDiskSource::addSupFields() const
void Foam::fv::actuationDiskSource::addSup void Foam::fv::actuationDiskSource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
const scalarField& cellsV = mesh().V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
addActuationDiskAxialInertialResistance addActuationDiskAxialInertialResistance
( (
Usource, eqn.source(),
set_.cells(), set_.cells(),
cellsV, mesh().V(),
geometricOneField(), geometricOneField(),
geometricOneField(), geometricOneField(),
U U
@ -153,19 +180,15 @@ void Foam::fv::actuationDiskSource::addSup
void Foam::fv::actuationDiskSource::addSup void Foam::fv::actuationDiskSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
const scalarField& cellsV = mesh().V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
addActuationDiskAxialInertialResistance addActuationDiskAxialInertialResistance
( (
Usource, eqn.source(),
set_.cells(), set_.cells(),
cellsV, mesh().V(),
geometricOneField(), geometricOneField(),
rho, rho,
U U
@ -177,19 +200,15 @@ void Foam::fv::actuationDiskSource::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
const scalarField& cellsV = mesh().V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
addActuationDiskAxialInertialResistance addActuationDiskAxialInertialResistance
( (
Usource, eqn.source(),
set_.cells(), set_.cells(),
cellsV, mesh().V(),
alpha, alpha,
rho, rho,
U U

View File

@ -129,7 +129,7 @@ private:
//- Add resistance to the UEqn //- Add resistance to the UEqn
template<class AlphaFieldType, class RhoFieldType> template<class AlphaFieldType, class RhoFieldType>
void addActuationDiskAxialInertialResistance inline void addActuationDiskAxialInertialResistance
( (
vectorField& Usource, vectorField& Usource,
const labelList& cells, const labelList& cells,
@ -180,16 +180,16 @@ public:
//- Source term to momentum equation //- Source term to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to compressible momentum equation //- Source term to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Explicit and implicit sources for phase equations //- Explicit and implicit sources for phase equations
@ -197,8 +197,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
@ -237,12 +237,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "actuationDiskSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,62 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "actuationDiskSource.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class AlphaFieldType, class RhoFieldType>
void Foam::fv::actuationDiskSource::addActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,
const scalarField& Vcells,
const AlphaFieldType& alpha,
const RhoFieldType& rho,
const vectorField& U
) const
{
const scalar a = 1 - Cp_/Ct_;
const vector dHat(diskDir_/mag(diskDir_));
scalar dHatUo(vGreat);
if (upstreamCellId_ != -1)
{
dHatUo = dHat & U[upstreamCellId_];
}
reduce(dHatUo, minOp<scalar>());
const vector T = 2*diskArea_*sqr(dHatUo)*a*(1 - a)*dHat;
forAll(cells, i)
{
Usource[cells[i]] +=
(alpha[cells[i]]*rho[cells[i]]*(Vcells[cells[i]]/set_.V()))*T;
}
}
// ************************************************************************* //

View File

@ -96,8 +96,8 @@ Foam::wordList Foam::fv::buoyancyEnergy::addSupFields() const
void Foam::fv::buoyancyEnergy::addSup void Foam::fv::buoyancyEnergy::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const uniformDimensionedVectorField& g = const uniformDimensionedVectorField& g =
@ -113,8 +113,8 @@ void Foam::fv::buoyancyEnergy::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const uniformDimensionedVectorField& g = const uniformDimensionedVectorField& g =

View File

@ -116,8 +116,8 @@ public:
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add explicit contribution to phase energy equation //- Add explicit contribution to phase energy equation
@ -125,8 +125,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -99,8 +99,8 @@ Foam::wordList Foam::fv::buoyancyForce::addSupFields() const
void Foam::fv::buoyancyForce::addSup void Foam::fv::buoyancyForce::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
eqn += g_; eqn += g_;
@ -110,8 +110,8 @@ void Foam::fv::buoyancyForce::addSup
void Foam::fv::buoyancyForce::addSup void Foam::fv::buoyancyForce::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
eqn += rho*g_; eqn += rho*g_;
@ -122,8 +122,8 @@ void Foam::fv::buoyancyForce::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
eqn += alpha*rho*g_; eqn += alpha*rho*g_;

View File

@ -118,16 +118,16 @@ public:
//- Add explicit contribution to incompressible momentum equation //- Add explicit contribution to incompressible momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Add explicit contribution to compressible momentum equation //- Add explicit contribution to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Add explicit contribution to phase momentum equation //- Add explicit contribution to phase momentum equation
@ -135,8 +135,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -210,8 +210,8 @@ Foam::wordList Foam::fv::effectivenessHeatExchangerSource::addSupFields() const
void Foam::fv::effectivenessHeatExchangerSource::addSup void Foam::fv::effectivenessHeatExchangerSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const basicThermo& thermo = const basicThermo& thermo =

View File

@ -213,8 +213,8 @@ public:
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -102,8 +102,8 @@ Foam::wordList Foam::fv::explicitPorositySource::addSupFields() const
void Foam::fv::explicitPorositySource::addSup void Foam::fv::explicitPorositySource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions()); fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
@ -115,8 +115,8 @@ void Foam::fv::explicitPorositySource::addSup
void Foam::fv::explicitPorositySource::addSup void Foam::fv::explicitPorositySource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions()); fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
@ -129,8 +129,8 @@ void Foam::fv::explicitPorositySource::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions()); fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());

View File

@ -154,16 +154,16 @@ public:
//- Add implicit contribution to momentum equation //- Add implicit contribution to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Add implicit contribution to compressible momentum equation //- Add implicit contribution to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Add implicit contribution to phase momentum equation //- Add implicit contribution to phase momentum equation
@ -171,8 +171,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -123,8 +123,8 @@ Foam::wordList Foam::fv::heatSource::addSupFields() const
void Foam::fv::heatSource::addSup void Foam::fv::heatSource::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const labelUList cells = set_.cells(); const labelUList cells = set_.cells();
@ -142,11 +142,11 @@ void Foam::fv::heatSource::addSup
void Foam::fv::heatSource::addSup void Foam::fv::heatSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
addSup(eqn, fieldName); addSup(he, eqn);
} }

View File

@ -117,16 +117,16 @@ public:
//- Source term to energy equation //- Source term to energy equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Source term to compressible energy equation //- Source term to compressible energy equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -71,8 +71,7 @@ template<class AlphaFieldType>
void Foam::fv::heatTransfer::add void Foam::fv::heatTransfer::add
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn
const word& fieldName
) const ) const
{ {
const volScalarField& he = eqn.psi(); const volScalarField& he = eqn.psi();
@ -162,22 +161,22 @@ Foam::wordList Foam::fv::heatTransfer::addSupFields() const
void Foam::fv::heatTransfer::addSup void Foam::fv::heatTransfer::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
add(geometricOneField(), eqn, fieldName); add(geometricOneField(), eqn);
} }
void Foam::fv::heatTransfer::addSup void Foam::fv::heatTransfer::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
add(geometricOneField(), eqn, fieldName); add(geometricOneField(), eqn);
} }
@ -185,11 +184,11 @@ void Foam::fv::heatTransfer::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
add(alpha, eqn, fieldName); add(alpha, eqn);
} }

View File

@ -124,11 +124,10 @@ class heatTransfer
//- Source term to energy equation //- Source term to energy equation
template<class AlphaFieldType> template<class AlphaFieldType>
void add inline void add
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn
const word& fieldName
) const; ) const;
@ -168,16 +167,16 @@ public:
//- Source term to energy equation //- Source term to energy equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Source term to compressible energy equation //- Source term to compressible energy equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Source term to phase energy equation //- Source term to phase energy equation
@ -185,8 +184,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -74,20 +74,68 @@ void Foam::fv::massSourceBase::readCoeffs()
template<class Type> template<class Type>
void Foam::fv::massSourceBase::addGeneralSupType void Foam::fv::massSourceBase::addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const
{
FatalErrorInFunction
<< "Cannot add a mass source for field " << field.name()
<< " because this field's equation is not in mass-conservative form"
<< exit(FatalError);
}
void Foam::fv::massSourceBase::addSupType
(
const volScalarField& field,
fvMatrix<scalar>& eqn
) const
{
// Continuity equation. Add the mass flow rate.
if (field.name() == rhoName_)
{
const labelUList cells = set_.cells();
const scalar massFlowRate = this->massFlowRate();
forAll(cells, i)
{
eqn.source()[cells[i]] -=
mesh().V()[cells[i]]/set_.V()*massFlowRate;
}
return;
}
// Non-mass conservative property equation. Fail.
addSupType<scalar>(field, eqn);
}
template<class Type>
void Foam::fv::massSourceBase::addSupType
(
const volScalarField& rho,
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const ) const
{ {
const labelUList cells = set_.cells(); const labelUList cells = set_.cells();
const scalar massFlowRate = this->massFlowRate(); const scalar massFlowRate = this->massFlowRate();
// Property equation. If the source is positive, introduce the value
// specified by the user. If negative, then sink the current internal value
// using an implicit term.
if (massFlowRate > 0) if (massFlowRate > 0)
{ {
const Type value = const Type value =
fieldValues_[fieldName]->value<Type>(mesh().time().userTimeValue()); fieldValues_[field.name()]->template value<Type>
(
mesh().time().userTimeValue()
);
forAll(cells, i) forAll(cells, i)
{ {
@ -106,37 +154,25 @@ void Foam::fv::massSourceBase::addGeneralSupType
} }
template<class Type>
void Foam::fv::massSourceBase::addSupType void Foam::fv::massSourceBase::addSupType
( (
fvMatrix<Type>& eqn, const volScalarField& rho,
const word& fieldName const volScalarField& field,
fvMatrix<scalar>& eqn
) const ) const
{ {
addGeneralSupType(eqn, fieldName); // Multiphase continuity equation. Same source as single-phase case.
if (field.name() == rhoName_)
{
addSupType(field, eqn);
return;
} }
// Energy equation. Special handling for if temperature is specified.
void Foam::fv::massSourceBase::addSupType if (field.name() == heName_ && fieldValues_.found(TName_))
(
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{ {
const labelUList cells = set_.cells(); const labelUList cells = set_.cells();
if (fieldName == rhoName_)
{
const scalar massFlowRate = this->massFlowRate();
forAll(cells, i)
{
eqn.source()[cells[i]] -=
mesh().V()[cells[i]]/set_.V()*massFlowRate;
}
}
else if (fieldName == heName_ && fieldValues_.found(TName_))
{
const scalar massFlowRate = this->massFlowRate(); const scalar massFlowRate = this->massFlowRate();
if (massFlowRate > 0) if (massFlowRate > 0)
@ -184,23 +220,12 @@ void Foam::fv::massSourceBase::addSupType
mesh().V()[cells[i]]/set_.V()*massFlowRate; mesh().V()[cells[i]]/set_.V()*massFlowRate;
} }
} }
}
else return;
{
addGeneralSupType(eqn, fieldName);
}
} }
// Property equation
template<class Type> addSupType<scalar>(rho, field, eqn);
void Foam::fv::massSourceBase::addSupType
(
const volScalarField& rho,
fvMatrix<Type>& eqn,
const word& fieldName
) const
{
addSupType(eqn, fieldName);
} }
@ -209,11 +234,12 @@ void Foam::fv::massSourceBase::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
addSupType(eqn, fieldName); // Multiphase property equation. Same source as the single phase case.
addSupType(rho, field, eqn);
} }
@ -300,11 +326,12 @@ Foam::fv::massSource::massSource
bool Foam::fv::massSourceBase::addsSupToField(const word& fieldName) const bool Foam::fv::massSourceBase::addsSupToField(const word& fieldName) const
{ {
const bool isMixture = IOobject::group(fieldName) == word::null;
const bool isThisPhase = IOobject::group(fieldName) == phaseName_; const bool isThisPhase = IOobject::group(fieldName) == phaseName_;
if if
( (
isThisPhase (isMixture || isThisPhase)
&& massFlowRate() > 0 && massFlowRate() > 0
&& !(fieldName == rhoName_) && !(fieldName == rhoName_)
&& !(fieldName == heName_ && fieldValues_.found(TName_)) && !(fieldName == heName_ && fieldValues_.found(TName_))
@ -318,7 +345,7 @@ bool Foam::fv::massSourceBase::addsSupToField(const word& fieldName) const
return false; return false;
} }
return isThisPhase; return isMixture || isThisPhase;
} }
@ -335,13 +362,25 @@ Foam::wordList Foam::fv::massSourceBase::addSupFields() const
} }
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_SUP, fv::massSourceBase); FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_FIELD_SUP,
fv::massSourceBase
)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_SUP, fv::massSourceBase); FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP,
fv::massSourceBase
)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, fv::massSourceBase); FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP,
fv::massSourceBase
)
bool Foam::fv::massSourceBase::movePoints() bool Foam::fv::massSourceBase::movePoints()

View File

@ -123,26 +123,34 @@ private:
//- Add a source term to an equation //- Add a source term to an equation
template<class Type> template<class Type>
void addGeneralSupType void addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to an equation
template<class Type>
void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const;
//- Add a source term to a scalar equation //- Add a source term to a scalar equation
void addSupType(fvMatrix<scalar>& eqn, const word& fieldName) const; void addSupType
(
const volScalarField& field,
fvMatrix<scalar>& eqn
) const;
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
template<class Type> template<class Type>
void addSupType void addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const;
//- Add a source term to a compressible scalar equation
void addSupType
(
const volScalarField& rho,
const volScalarField& field,
fvMatrix<scalar>& eqn
) const; ) const;
//- Add a source term to a phase equation //- Add a source term to a phase equation
@ -151,8 +159,8 @@ private:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
@ -204,13 +212,13 @@ public:
// Sources // Sources
//- Add a source term to an equation //- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP)
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
// Mesh changes // Mesh changes

View File

@ -62,16 +62,14 @@ void Foam::fv::phaseLimitStabilisation::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
const VolField<Type>& psi = eqn.psi(); const uniformDimensionedScalarField& rate =
uniformDimensionedScalarField& rate =
mesh().lookupObjectRef<uniformDimensionedScalarField>(rateName_); mesh().lookupObjectRef<uniformDimensionedScalarField>(rateName_);
eqn -= fvm::Sp(max(residualAlpha_ - alpha, scalar(0))*rho*rate, psi); eqn -= fvm::Sp(max(residualAlpha_ - alpha, scalar(0))*rho*rate, eqn.psi());
} }
@ -104,9 +102,9 @@ Foam::wordList Foam::fv::phaseLimitStabilisation::addSupFields() const
FOR_ALL_FIELD_TYPES FOR_ALL_FIELD_TYPES
( (
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP,
fv::phaseLimitStabilisation fv::phaseLimitStabilisation
); )
bool Foam::fv::phaseLimitStabilisation::movePoints() bool Foam::fv::phaseLimitStabilisation::movePoints()

View File

@ -98,8 +98,8 @@ class phaseLimitStabilisation
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
@ -141,7 +141,7 @@ public:
// Sources // Sources
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
// Mesh changes // Mesh changes

View File

@ -24,6 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "radialActuationDiskSource.H" #include "radialActuationDiskSource.H"
#include "volFields.H"
#include "fvMatrix.H"
#include "geometricOneField.H" #include "geometricOneField.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -51,6 +53,70 @@ void Foam::fv::radialActuationDiskSource::readCoeffs()
} }
template<class RhoFieldType>
void Foam::fv::radialActuationDiskSource::
addRadialActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,
const scalarField& Vcells,
const RhoFieldType& rho,
const vectorField& U
) const
{
scalar a = 1.0 - Cp_/Ct_;
scalarField Tr(cells.size());
const vector uniDiskDir = diskDir_/mag(diskDir_);
tensor E(Zero);
E.xx() = uniDiskDir.x();
E.yy() = uniDiskDir.y();
E.zz() = uniDiskDir.z();
const Field<vector> zoneCellCentres(mesh().cellCentres(), cells);
const Field<scalar> zoneCellVolumes(mesh().cellVolumes(), cells);
const vector avgCentre = gSum(zoneCellVolumes*zoneCellCentres)/set_.V();
const scalar maxR = gMax(mag(zoneCellCentres - avgCentre));
scalar intCoeffs =
radialCoeffs_[0]
+ radialCoeffs_[1]*sqr(maxR)/2.0
+ radialCoeffs_[2]*pow4(maxR)/3.0;
vector upU = vector(vGreat, vGreat, vGreat);
scalar upRho = vGreat;
if (upstreamCellId_ != -1)
{
upU = U[upstreamCellId_];
upRho = rho[upstreamCellId_];
}
reduce(upU, minOp<vector>());
reduce(upRho, minOp<scalar>());
scalar T = 2.0*upRho*diskArea_*mag(upU)*a*(1.0 - a);
forAll(cells, i)
{
scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre);
Tr[i] =
T
*(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2))
/intCoeffs;
Usource[cells[i]] += ((Vcells[cells[i]]/set_.V())*Tr[i]*E) & upU;
}
if (debug)
{
Info<< "Source name: " << name() << nl
<< "Average centre: " << avgCentre << nl
<< "Maximum radius: " << maxR << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::radialActuationDiskSource::radialActuationDiskSource Foam::fv::radialActuationDiskSource::radialActuationDiskSource
@ -72,19 +138,15 @@ Foam::fv::radialActuationDiskSource::radialActuationDiskSource
void Foam::fv::radialActuationDiskSource::addSup void Foam::fv::radialActuationDiskSource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
const scalarField& cellsV = mesh().V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
addRadialActuationDiskAxialInertialResistance addRadialActuationDiskAxialInertialResistance
( (
Usource, eqn.source(),
set_.cells(), set_.cells(),
cellsV, mesh().V(),
geometricOneField(), geometricOneField(),
U U
); );
@ -94,19 +156,15 @@ void Foam::fv::radialActuationDiskSource::addSup
void Foam::fv::radialActuationDiskSource::addSup void Foam::fv::radialActuationDiskSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
const scalarField& cellsV = mesh().V();
vectorField& Usource = eqn.source();
const vectorField& U = eqn.psi();
addRadialActuationDiskAxialInertialResistance addRadialActuationDiskAxialInertialResistance
( (
Usource, eqn.source(),
set_.cells(), set_.cells(),
cellsV, mesh().V(),
rho, rho,
U U
); );

View File

@ -115,7 +115,7 @@ class radialActuationDiskSource
//- Add resistance to the UEqn //- Add resistance to the UEqn
template<class RhoFieldType> template<class RhoFieldType>
void addRadialActuationDiskAxialInertialResistance inline void addRadialActuationDiskAxialInertialResistance
( (
vectorField& Usource, vectorField& Usource,
const labelList& cells, const labelList& cells,
@ -156,16 +156,16 @@ public:
//- Source term to momentum equation //- Source term to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to compressible momentum equation //- Source term to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
@ -189,12 +189,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "radialActuationDiskSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -554,8 +554,8 @@ Foam::wordList Foam::fv::rotorDiskSource::addSupFields() const
void Foam::fv::rotorDiskSource::addSup void Foam::fv::rotorDiskSource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
volVectorField::Internal force volVectorField::Internal force
@ -578,7 +578,7 @@ void Foam::fv::rotorDiskSource::addSup
// Read the reference density for incompressible flow // Read the reference density for incompressible flow
coeffs().lookup("rhoRef") >> rhoRef_; coeffs().lookup("rhoRef") >> rhoRef_;
const vectorField Uin(inflowVelocity(eqn.psi())); const vectorField Uin(inflowVelocity(U));
trim_->correct(Uin, force); trim_->correct(Uin, force);
calculate(geometricOneField(), Uin, trim_->thetag(), force); calculate(geometricOneField(), Uin, trim_->thetag(), force);
@ -595,8 +595,8 @@ void Foam::fv::rotorDiskSource::addSup
void Foam::fv::rotorDiskSource::addSup void Foam::fv::rotorDiskSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
volVectorField::Internal force volVectorField::Internal force
@ -616,7 +616,7 @@ void Foam::fv::rotorDiskSource::addSup
) )
); );
const vectorField Uin(inflowVelocity(eqn.psi())); const vectorField Uin(inflowVelocity(U));
trim_->correct(rho, Uin, force); trim_->correct(rho, Uin, force);
calculate(rho, Uin, trim_->thetag(), force); calculate(rho, Uin, trim_->thetag(), force);

View File

@ -318,16 +318,16 @@ public:
//- Source term to momentum equation //- Source term to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to compressible momentum equation //- Source term to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

View File

@ -26,6 +26,7 @@ License
#include "sixDoFAccelerationSource.H" #include "sixDoFAccelerationSource.H"
#include "fvMatrices.H" #include "fvMatrices.H"
#include "geometricOneField.H" #include "geometricOneField.H"
#include "uniformDimensionedFields.H"
#include "makeFunction1s.H" #include "makeFunction1s.H"
#include "makeTableReaders.H" #include "makeTableReaders.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -105,6 +106,68 @@ void Foam::fv::sixDoFAccelerationSource::readCoeffs()
} }
template<class AlphaFieldType, class RhoFieldType>
void Foam::fv::sixDoFAccelerationSource::addForce
(
const AlphaFieldType& alpha,
const RhoFieldType& rho,
const volVectorField& U,
fvMatrix<vector>& eqn
) const
{
const Vector<vector> accelerations
(
accelerations_->value(mesh().time().userTimeValue())
);
// If gravitational force is present combine with the linear acceleration
if (mesh().foundObject<uniformDimensionedVectorField>("g"))
{
uniformDimensionedVectorField& g =
mesh().lookupObjectRef<uniformDimensionedVectorField>("g");
const uniformDimensionedScalarField& hRef =
mesh().lookupObject<uniformDimensionedScalarField>("hRef");
g = g_ - dimensionedVector("a", dimAcceleration, accelerations.x());
dimensionedScalar ghRef(- mag(g)*hRef);
mesh().lookupObjectRef<volScalarField>("gh") = (g & mesh().C()) - ghRef;
mesh().lookupObjectRef<surfaceScalarField>("ghf") =
(g & mesh().Cf()) - ghRef;
}
// ... otherwise include explicitly in the momentum equation
else
{
const dimensionedVector a("a", dimAcceleration, accelerations.x());
eqn -= alpha*rho*a;
}
dimensionedVector Omega
(
"Omega",
dimensionSet(0, 0, -1, 0, 0),
accelerations.y()
);
dimensionedVector dOmegaDT
(
"dOmegaDT",
dimensionSet(0, 0, -2, 0, 0),
accelerations.z()
);
eqn -=
(
alpha*rho*(2*Omega ^ U) // Coriolis force
+ alpha*rho*(Omega ^ (Omega ^ mesh().C())) // Centrifugal force
+ alpha*rho*(dOmegaDT ^ mesh().C()) // Angular acceleration force
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::sixDoFAccelerationSource::sixDoFAccelerationSource Foam::fv::sixDoFAccelerationSource::sixDoFAccelerationSource
@ -139,22 +202,22 @@ Foam::wordList Foam::fv::sixDoFAccelerationSource::addSupFields() const
void Foam::fv::sixDoFAccelerationSource::addSup void Foam::fv::sixDoFAccelerationSource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
addForce(geometricOneField(), geometricOneField(), eqn, fieldName); addForce(geometricOneField(), geometricOneField(), U, eqn);
} }
void Foam::fv::sixDoFAccelerationSource::addSup void Foam::fv::sixDoFAccelerationSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
addForce(geometricOneField(), rho, eqn, fieldName); addForce(geometricOneField(), rho, U, eqn);
} }
@ -162,11 +225,11 @@ void Foam::fv::sixDoFAccelerationSource::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
addForce(alpha, rho, eqn, fieldName); addForce(alpha, rho, U, eqn);
} }

View File

@ -98,12 +98,12 @@ private:
//- Add force to a momentum equation //- Add force to a momentum equation
template<class AlphaFieldType, class RhoFieldType> template<class AlphaFieldType, class RhoFieldType>
void addForce inline void addForce
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
const RhoFieldType& rho, const RhoFieldType& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
@ -145,16 +145,16 @@ public:
//- Source term to momentum equation //- Source term to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to compressible momentum equation //- Source term to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Source term to phase momentum equation //- Source term to phase momentum equation
@ -162,8 +162,8 @@ public:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
@ -200,12 +200,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "sixDoFAccelerationSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,95 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "sixDoFAccelerationSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "uniformDimensionedFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class AlphaFieldType, class RhoFieldType>
void Foam::fv::sixDoFAccelerationSource::addForce
(
const AlphaFieldType& alpha,
const RhoFieldType& rho,
fvMatrix<vector>& eqn,
const word& fieldName
) const
{
const Vector<vector> accelerations
(
accelerations_->value(mesh().time().userTimeValue())
);
// If gravitational force is present combine with the linear acceleration
if (mesh().foundObject<uniformDimensionedVectorField>("g"))
{
uniformDimensionedVectorField& g =
mesh().lookupObjectRef<uniformDimensionedVectorField>("g");
const uniformDimensionedScalarField& hRef =
mesh().lookupObject<uniformDimensionedScalarField>("hRef");
g = g_ - dimensionedVector("a", dimAcceleration, accelerations.x());
dimensionedScalar ghRef(- mag(g)*hRef);
mesh().lookupObjectRef<volScalarField>("gh") = (g & mesh().C()) - ghRef;
mesh().lookupObjectRef<surfaceScalarField>("ghf") =
(g & mesh().Cf()) - ghRef;
}
// ... otherwise include explicitly in the momentum equation
else
{
const dimensionedVector a("a", dimAcceleration, accelerations.x());
eqn -= alpha*rho*a;
}
dimensionedVector Omega
(
"Omega",
dimensionSet(0, 0, -1, 0, 0),
accelerations.y()
);
dimensionedVector dOmegaDT
(
"dOmegaDT",
dimensionSet(0, 0, -2, 0, 0),
accelerations.z()
);
eqn -=
(
alpha*rho*(2*Omega ^ eqn.psi()) // Coriolis force
+ alpha*rho*(Omega ^ (Omega ^ mesh().C())) // Centrifugal force
+ alpha*rho*(dOmegaDT ^ mesh().C()) // Angular acceleration force
);
}
// ************************************************************************* //

View File

@ -144,8 +144,8 @@ Foam::wordList Foam::fv::solidEquilibriumEnergySource::addSupFields() const
void Foam::fv::solidEquilibriumEnergySource::addSup void Foam::fv::solidEquilibriumEnergySource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const volScalarField alphahe const volScalarField alphahe
@ -172,8 +172,8 @@ void Foam::fv::solidEquilibriumEnergySource::addSup
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const volScalarField alphahe const volScalarField alphahe

View File

@ -138,18 +138,18 @@ public:
//- Explicit and implicit sources for compressible equations //- Explicit and implicit sources for compressible equations
virtual void addSup virtual void addSup
( (
const volScalarField&, const volScalarField& rho,
fvMatrix<scalar>&, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Explicit and implicit sources for phase equations //- Explicit and implicit sources for phase equations
virtual void addSup virtual void addSup
( (
const volScalarField&, const volScalarField& alpha,
const volScalarField&, const volScalarField& rho,
fvMatrix<scalar>&, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "solidificationMeltingSource.H" #include "solidificationMeltingSource.H"
#include "fvcDdt.H"
#include "fvMatrices.H" #include "fvMatrices.H"
#include "basicThermo.H" #include "basicThermo.H"
#include "uniformDimensionedFields.H" #include "uniformDimensionedFields.H"
@ -214,6 +215,36 @@ void Foam::fv::solidificationMeltingSource::update
} }
template<class RhoFieldType>
void Foam::fv::solidificationMeltingSource::apply
(
const RhoFieldType& rho,
fvMatrix<scalar>& eqn
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
const volScalarField Cp(this->Cp());
update(Cp);
dimensionedScalar L("L", dimEnergy/dimMass, L_);
// Contributions added to rhs of solver equation
if (eqn.psi().dimensions() == dimTemperature)
{
eqn -= L/Cp*(fvc::ddt(rho, alpha1_));
}
else
{
eqn -= L*(fvc::ddt(rho, alpha1_));
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::solidificationMeltingSource::solidificationMeltingSource Foam::fv::solidificationMeltingSource::solidificationMeltingSource
@ -286,8 +317,8 @@ Foam::wordList Foam::fv::solidificationMeltingSource::addSupFields() const
void Foam::fv::solidificationMeltingSource::addSup void Foam::fv::solidificationMeltingSource::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
apply(geometricOneField(), eqn); apply(geometricOneField(), eqn);
@ -297,8 +328,8 @@ void Foam::fv::solidificationMeltingSource::addSup
void Foam::fv::solidificationMeltingSource::addSup void Foam::fv::solidificationMeltingSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
apply(rho, eqn); apply(rho, eqn);
@ -307,8 +338,8 @@ void Foam::fv::solidificationMeltingSource::addSup
void Foam::fv::solidificationMeltingSource::addSup void Foam::fv::solidificationMeltingSource::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -347,12 +378,11 @@ void Foam::fv::solidificationMeltingSource::addSup
void Foam::fv::solidificationMeltingSource::addSup void Foam::fv::solidificationMeltingSource::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
// Momentum source uses a Boussinesq approximation - redirect addSup(U, eqn);
addSup(eqn, fieldName);
} }

View File

@ -230,7 +230,7 @@ private:
//- Helper function to apply to the energy equation //- Helper function to apply to the energy equation
template<class RhoFieldType> template<class RhoFieldType>
void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn) const; inline void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn) const;
public: public:
@ -266,39 +266,36 @@ public:
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
// Add explicit and implicit contributions // Evaluation
//- Add explicit contribution to enthalpy equation //- Add explicit contribution to enthalpy equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to momentum equation //- Add implicit contribution to momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
// Add explicit and implicit contributions to compressible equation
//- Add explicit contribution to compressible enthalpy equation //- Add explicit contribution to compressible enthalpy equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add implicit contribution to compressible momentum equation //- Add implicit contribution to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
@ -337,12 +334,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "solidificationMeltingSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,61 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fvMatrices.H"
#include "fvcDdt.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class RhoFieldType>
void Foam::fv::solidificationMeltingSource::apply
(
const RhoFieldType& rho,
fvMatrix<scalar>& eqn
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
const volScalarField Cp(this->Cp());
update(Cp);
dimensionedScalar L("L", dimEnergy/dimMass, L_);
// Contributions added to rhs of solver equation
if (eqn.psi().dimensions() == dimTemperature)
{
eqn -= L/Cp*(fvc::ddt(rho, alpha1_));
}
else
{
eqn -= L*(fvc::ddt(rho, alpha1_));
}
}
// ************************************************************************* //

View File

@ -128,21 +128,20 @@ Foam::tmp<Foam::volScalarField> Foam::fv::volumeFractionSource::D
template <class Type, class AlphaFieldType> template <class Type, class AlphaFieldType>
void Foam::fv::volumeFractionSource::addGeneralSup void Foam::fv::volumeFractionSource::addGeneralSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<Type>& eqn, fvMatrix<Type>& eqn
const word& fieldName
) const ) const
{ {
const word phiName = const word phiName =
IOobject::groupName(phiName_, IOobject::group(fieldName)); IOobject::groupName(phiName_, IOobject::group(eqn.psi().name()));
const surfaceScalarField& phi = const surfaceScalarField& phi =
mesh().lookupObject<surfaceScalarField>(phiName); mesh().lookupObject<surfaceScalarField>(phiName);
const volScalarField B(1 - volumeAlpha()); const volScalarField B(1 - volumeAlpha());
const volScalarField AByB(volumeAlpha()/B); const volScalarField AByB(volumeAlpha()/B);
const volScalarField D(this->D(fieldName)); const volScalarField D(this->D(eqn.psi().name()));
// Divergence term // Divergence term
const word divScheme = "div(" + phiName + "," + eqn.psi().name() + ")"; const word divScheme = "div(" + phiName + "," + eqn.psi().name() + ")";
@ -161,11 +160,11 @@ template<class Type, class AlphaFieldType>
void Foam::fv::volumeFractionSource::addAlphaSupType void Foam::fv::volumeFractionSource::addAlphaSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
addGeneralSup(alpha, eqn, fieldName); addGeneralSupType(alpha, eqn);
} }
@ -173,14 +172,14 @@ template<class AlphaFieldType>
void Foam::fv::volumeFractionSource::addAlphaSupType void Foam::fv::volumeFractionSource::addAlphaSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (IOobject::member(fieldName) == rhoName_) if (IOobject::member(field.name()) == rhoName_)
{ {
const word phiName = const word phiName =
IOobject::groupName(phiName_, IOobject::group(fieldName)); IOobject::groupName(phiName_, IOobject::group(field.name()));
const surfaceScalarField& phi = const surfaceScalarField& phi =
mesh().lookupObject<surfaceScalarField>(phiName); mesh().lookupObject<surfaceScalarField>(phiName);
@ -190,7 +189,7 @@ void Foam::fv::volumeFractionSource::addAlphaSupType
} }
else else
{ {
addGeneralSup(alpha, eqn, fieldName); addGeneralSupType(alpha, eqn);
} }
} }
@ -199,14 +198,14 @@ template<class AlphaFieldType>
void Foam::fv::volumeFractionSource::addAlphaSupType void Foam::fv::volumeFractionSource::addAlphaSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<vector>& eqn, const volVectorField& field,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (IOobject::member(fieldName) == UName_) if (IOobject::member(field.name()) == UName_)
{ {
const word phiName = const word phiName =
IOobject::groupName(phiName_, IOobject::group(fieldName)); IOobject::groupName(phiName_, IOobject::group(field.name()));
const surfaceScalarField& phi = const surfaceScalarField& phi =
mesh().lookupObject<surfaceScalarField>(phiName); mesh().lookupObject<surfaceScalarField>(phiName);
@ -218,7 +217,7 @@ void Foam::fv::volumeFractionSource::addAlphaSupType
} }
else else
{ {
addGeneralSup(alpha, eqn, fieldName); addGeneralSupType(alpha, eqn);
} }
} }
@ -226,11 +225,11 @@ void Foam::fv::volumeFractionSource::addAlphaSupType
template<class Type> template<class Type>
void Foam::fv::volumeFractionSource::addSupType void Foam::fv::volumeFractionSource::addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
addAlphaSupType(geometricOneField(), eqn, fieldName); addAlphaSupType(geometricOneField(), field, eqn);
} }
@ -238,11 +237,11 @@ template<class Type>
void Foam::fv::volumeFractionSource::addSupType void Foam::fv::volumeFractionSource::addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
addAlphaSupType(geometricOneField(), eqn, fieldName); addAlphaSupType(geometricOneField(), field, eqn);
} }
@ -251,11 +250,11 @@ void Foam::fv::volumeFractionSource::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
addAlphaSupType(alpha, eqn, fieldName); addAlphaSupType(alpha, field, eqn);
} }
@ -300,17 +299,25 @@ Foam::wordList Foam::fv::volumeFractionSource::addSupFields() const
} }
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_SUP, fv::volumeFractionSource); FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_FIELD_SUP,
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_SUP, fv::volumeFractionSource); fv::volumeFractionSource
)
FOR_ALL_FIELD_TYPES FOR_ALL_FIELD_TYPES
( (
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP,
fv::volumeFractionSource fv::volumeFractionSource
); )
FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP,
fv::volumeFractionSource
)
bool Foam::fv::volumeFractionSource::movePoints() bool Foam::fv::volumeFractionSource::movePoints()

View File

@ -120,11 +120,10 @@ class volumeFractionSource
//- Add source terms to an equation //- Add source terms to an equation
template<class Type, class AlphaFieldType> template<class Type, class AlphaFieldType>
void addGeneralSup void addGeneralSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<Type>&, fvMatrix<Type>&
const word& fieldName
) const; ) const;
//- Add a source term to an equation //- Add a source term to an equation
@ -132,8 +131,8 @@ class volumeFractionSource
void addAlphaSupType void addAlphaSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a scalar equation //- Add a source term to a scalar equation
@ -141,8 +140,8 @@ class volumeFractionSource
void addAlphaSupType void addAlphaSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add a source term to a vector equation //- Add a source term to a vector equation
@ -150,21 +149,25 @@ class volumeFractionSource
void addAlphaSupType void addAlphaSupType
( (
const AlphaFieldType& alpha, const AlphaFieldType& alpha,
fvMatrix<vector>& eqn, const volVectorField& field,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Add a source term to an equation //- Add a source term to an equation
template<class Type> template<class Type>
void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const; void addSupType
(
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const;
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
template<class Type> template<class Type>
void addSupType void addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a phase equation //- Add a source term to a phase equation
@ -173,13 +176,11 @@ class volumeFractionSource
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
public: public:
//- Runtime type information //- Runtime type information
@ -221,13 +222,13 @@ public:
// Sources // Sources
//- Add a source term to an equation //- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP)
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
// Mesh changes // Mesh changes

View File

@ -133,7 +133,6 @@ const Foam::dictionary& Foam::fv::codedFvModel::codeDict() const
Foam::wordList Foam::fv::codedFvModel::codeKeys() const Foam::wordList Foam::fv::codedFvModel::codeKeys() const
{ {
return return
{ {
"codeAddSup", "codeAddSup",
@ -165,8 +164,8 @@ Foam::fvModel& Foam::fv::codedFvModel::redirectFvModel() const
template<class Type> template<class Type>
void Foam::fv::codedFvModel::addSupType void Foam::fv::codedFvModel::addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
if (fieldPrimitiveTypeName() != word::null) if (fieldPrimitiveTypeName() != word::null)
@ -177,7 +176,7 @@ void Foam::fv::codedFvModel::addSupType
} }
updateLibrary(); updateLibrary();
redirectFvModel().addSup(eqn, fieldName); redirectFvModel().addSup(field, eqn);
} }
} }
@ -186,8 +185,8 @@ template<class Type>
void Foam::fv::codedFvModel::addSupType void Foam::fv::codedFvModel::addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
if (fieldPrimitiveTypeName() != word::null) if (fieldPrimitiveTypeName() != word::null)
@ -198,7 +197,7 @@ void Foam::fv::codedFvModel::addSupType
} }
updateLibrary(); updateLibrary();
redirectFvModel().addSup(rho, eqn, fieldName); redirectFvModel().addSup(rho, field, eqn);
} }
} }
@ -208,8 +207,8 @@ void Foam::fv::codedFvModel::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
if (fieldPrimitiveTypeName() != word::null) if (fieldPrimitiveTypeName() != word::null)
@ -220,7 +219,7 @@ void Foam::fv::codedFvModel::addSupType
} }
updateLibrary(); updateLibrary();
redirectFvModel().addSup(alpha, rho, eqn, fieldName); redirectFvModel().addSup(alpha, rho, field, eqn);
} }
} }
@ -250,13 +249,17 @@ Foam::wordList Foam::fv::codedFvModel::addSupFields() const
} }
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_SUP, fv::codedFvModel); FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_FIELD_SUP, fv::codedFvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_SUP, fv::codedFvModel); FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP, fv::codedFvModel)
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, fv::codedFvModel); FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP,
fv::codedFvModel
)
bool Foam::fv::codedFvModel::movePoints() bool Foam::fv::codedFvModel::movePoints()

View File

@ -136,8 +136,8 @@ class codedFvModel
template<class Type> template<class Type>
void addSupType void addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
@ -145,8 +145,8 @@ class codedFvModel
void addSupType void addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a phase equation //- Add a source term to a phase equation
@ -155,8 +155,8 @@ class codedFvModel
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
@ -190,13 +190,13 @@ public:
// Sources // Sources
//- Add a source term to an equation //- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP)
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
// Mesh changes // Mesh changes

View File

@ -86,16 +86,10 @@ void Foam::fv::semiImplicitSource::readCoeffs()
template<class Type> template<class Type>
void Foam::fv::semiImplicitSource::addSupType void Foam::fv::semiImplicitSource::addSupType
( (
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
if (debug)
{
Info<< "semiImplicitSource<" << pTraits<Type>::typeName
<< ">::addSup for source " << name() << endl;
}
const scalar t = mesh().time().userTimeValue(); const scalar t = mesh().time().userTimeValue();
const VolField<Type>& psi = eqn.psi(); const VolField<Type>& psi = eqn.psi();
@ -104,7 +98,7 @@ void Foam::fv::semiImplicitSource::addSupType
( (
IOobject IOobject
( (
name() + fieldName + "Su", name() + field.name() + "Su",
mesh().time().name(), mesh().time().name(),
mesh(), mesh(),
IOobject::NO_READ, IOobject::NO_READ,
@ -134,13 +128,13 @@ void Foam::fv::semiImplicitSource::addSupType
// Explicit source function for the field // Explicit source function for the field
UIndirectList<Type>(Su, set_.cells()) = UIndirectList<Type>(Su, set_.cells()) =
fieldSu_[fieldName]->value<Type>(t)/VDash; fieldSu_[field.name()]->template value<Type>(t)/VDash;
volScalarField::Internal Sp volScalarField::Internal Sp
( (
IOobject IOobject
( (
name() + fieldName + "Sp", name() + field.name() + "Sp",
mesh().time().name(), mesh().time().name(),
mesh(), mesh(),
IOobject::NO_READ, IOobject::NO_READ,
@ -158,7 +152,7 @@ void Foam::fv::semiImplicitSource::addSupType
// Implicit source function for the field // Implicit source function for the field
UIndirectList<scalar>(Sp, set_.cells()) = UIndirectList<scalar>(Sp, set_.cells()) =
fieldSp_[fieldName]->value(t)/VDash; fieldSp_[field.name()]->value(t)/VDash;
eqn += Su - fvm::SuSp(-Sp, psi); eqn += Su - fvm::SuSp(-Sp, psi);
} }
@ -168,11 +162,11 @@ template<class Type>
void Foam::fv::semiImplicitSource::addSupType void Foam::fv::semiImplicitSource::addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
return this->addSup(eqn, fieldName); return addSup(field, eqn);
} }
@ -181,11 +175,11 @@ void Foam::fv::semiImplicitSource::addSupType
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const ) const
{ {
return this->addSup(eqn, fieldName); return addSup(field, eqn);
} }
@ -221,17 +215,25 @@ Foam::wordList Foam::fv::semiImplicitSource::addSupFields() const
} }
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_SUP, fv::semiImplicitSource); FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_FIELD_SUP,
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_SUP, fv::semiImplicitSource); fv::semiImplicitSource
)
FOR_ALL_FIELD_TYPES FOR_ALL_FIELD_TYPES
( (
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_SUP, IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP,
fv::semiImplicitSource fv::semiImplicitSource
); )
FOR_ALL_FIELD_TYPES
(
IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP,
fv::semiImplicitSource
)
bool Foam::fv::semiImplicitSource::movePoints() bool Foam::fv::semiImplicitSource::movePoints()

View File

@ -154,15 +154,19 @@ private:
//- Add a source term to an equation //- Add a source term to an equation
template <class Type> template <class Type>
void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const; void addSupType
(
const VolField<Type>& field,
fvMatrix<Type>& eqn
) const;
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
template <class Type> template <class Type>
void addSupType void addSupType
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
//- Add a source term to a phase equation //- Add a source term to a phase equation
@ -171,8 +175,8 @@ private:
( (
const volScalarField& alpha, const volScalarField& alpha,
const volScalarField& rho, const volScalarField& rho,
fvMatrix<Type>& eqn, const VolField<Type>& field,
const word& fieldName fvMatrix<Type>& eqn
) const; ) const;
@ -209,13 +213,13 @@ public:
// Sources // Sources
//- Add a source term to an equation //- Add a source term to an equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
//- Add a source term to a compressible equation //- Add a source term to a compressible equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP)
//- Add a source term to a phase equation //- Add a source term to a phase equation
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP); FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP)
// Mesh changes // Mesh changes

View File

@ -152,9 +152,8 @@ Foam::fv::interRegionExplicitPorositySource::addSupFields() const
void Foam::fv::interRegionExplicitPorositySource::addSup void Foam::fv::interRegionExplicitPorositySource::addSup
( (
const volScalarField& rho, const volVectorField& U,
fvMatrix<vector>& eqn, fvMatrix<vector>& eqn
const word& fieldName
) const ) const
{ {
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions()); fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
@ -163,6 +162,33 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
} }
void Foam::fv::interRegionExplicitPorositySource::addSup
(
const volScalarField& rho,
const volVectorField& U,
fvMatrix<vector>& eqn
) const
{
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
porosityPtr_->addResistance(porosityEqn);
eqn -= filter_*porosityEqn;
}
void Foam::fv::interRegionExplicitPorositySource::addSup
(
const volScalarField& alpha,
const volScalarField& rho,
const volVectorField& U,
fvMatrix<vector>& eqn
) const
{
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
porosityPtr_->addResistance(porosityEqn);
eqn -= alpha*filter_*porosityEqn;
}
bool Foam::fv::interRegionExplicitPorositySource::movePoints() bool Foam::fv::interRegionExplicitPorositySource::movePoints()
{ {
NotImplemented; NotImplemented;

View File

@ -139,13 +139,30 @@ public:
virtual wordList addSupFields() const; virtual wordList addSupFields() const;
// Add explicit and implicit contributions to compressible equation // Evaluation
//- Add source to momentum equation
virtual void addSup
(
const volVectorField& U,
fvMatrix<vector>& eqn
) const;
//- Add source to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const;
//- Add source to phase momentum equation
virtual void addSup
(
const volScalarField& alpha,
const volScalarField& rho,
const volVectorField& U,
fvMatrix<vector>& eqn
) const; ) const;

View File

@ -114,12 +114,10 @@ Foam::wordList Foam::fv::interRegionHeatTransfer::addSupFields() const
void Foam::fv::interRegionHeatTransfer::addSup void Foam::fv::interRegionHeatTransfer::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
const volScalarField& he = eqn.psi();
const volScalarField& T = const volScalarField& T =
mesh().lookupObject<volScalarField>(TName_); mesh().lookupObject<volScalarField>(TName_);
@ -199,11 +197,11 @@ void Foam::fv::interRegionHeatTransfer::addSup
void Foam::fv::interRegionHeatTransfer::addSup void Foam::fv::interRegionHeatTransfer::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
addSup(eqn, fieldName); addSup(he, eqn);
} }

View File

@ -111,7 +111,7 @@ class interRegionHeatTransfer
// Private member functions // Private member functions
//- Non-virtual read //- Non-virtual readalpha*
void readCoeffs(); void readCoeffs();
//- Get the neighbour heat transfer //- Get the neighbour heat transfer
@ -160,16 +160,16 @@ public:
//- Source term to energy equation //- Source term to energy equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Source term to compressible energy equation //- Source term to compressible energy equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& he,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;

View File

@ -172,13 +172,11 @@ Foam::wordList Foam::fv::clouds::addSupFields() const
const multicomponentThermo& carrierMcThermo = const multicomponentThermo& carrierMcThermo =
refCast<const multicomponentThermo>(carrierThermo); refCast<const multicomponentThermo>(carrierThermo);
const PtrList<volScalarField>& Y = carrierMcThermo.Y(); forAll(carrierMcThermo.Y(), i)
forAll(Y, i)
{ {
if (carrierMcThermo.solveSpecie(i)) if (carrierMcThermo.solveSpecie(i))
{ {
fieldNames.append(Y[i].name()); fieldNames.append(carrierMcThermo.Y()[i].name());
} }
} }
} }
@ -208,8 +206,8 @@ void Foam::fv::clouds::correct()
void Foam::fv::clouds::addSup void Foam::fv::clouds::addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -225,18 +223,24 @@ void Foam::fv::clouds::addSup
<< exit(FatalError); << exit(FatalError);
} }
if (fieldName == rhoName_) if (rho.name() == rhoName_)
{ {
eqn += cloudsPtr_().Srho(eqn.psi()); eqn += cloudsPtr_().Srho(eqn.psi());
} }
else
{
FatalErrorInFunction
<< "Support for field " << rho.name() << " is not implemented"
<< exit(FatalError);
}
} }
void Foam::fv::clouds::addSup void Foam::fv::clouds::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -254,36 +258,41 @@ void Foam::fv::clouds::addSup
const fluidThermo& carrierThermo = tCarrierThermo_(); const fluidThermo& carrierThermo = tCarrierThermo_();
if (fieldName == rhoName_) if (&field == &carrierThermo.he())
{
eqn += cloudsPtr_().Srho(eqn.psi());
}
else if (fieldName == carrierThermo.he().name())
{ {
eqn += cloudsPtr_().Sh(eqn.psi()); eqn += cloudsPtr_().Sh(eqn.psi());
return;
} }
else if (isA<multicomponentThermo>(carrierThermo))
if (isA<multicomponentThermo>(carrierThermo))
{ {
const multicomponentThermo& carrierMcThermo = const multicomponentThermo& carrierMcThermo =
refCast<const multicomponentThermo>(carrierThermo); refCast<const multicomponentThermo>(carrierThermo);
if (carrierMcThermo.containsSpecie(eqn.psi().name())) if (carrierMcThermo.containsSpecie(field.name()))
{ {
eqn += eqn +=
cloudsPtr_().SYi cloudsPtr_().SYi
( (
carrierMcThermo.specieIndex(eqn.psi()), carrierMcThermo.specieIndex(field),
eqn.psi() field
); );
return;
} }
} }
{
FatalErrorInFunction
<< "Support for field " << field.name() << " is not implemented"
<< exit(FatalError);
}
} }
void Foam::fv::clouds::addSup void Foam::fv::clouds::addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -299,18 +308,24 @@ void Foam::fv::clouds::addSup
<< exit(FatalError); << exit(FatalError);
} }
if (fieldName == UName_) if (U.name() == UName_)
{ {
eqn += cloudsPtr_().SU(eqn.psi())/tRho_(); eqn += cloudsPtr_().SU(eqn.psi())/tRho_();
} }
else
{
FatalErrorInFunction
<< "Support for field " << U.name() << " is not implemented"
<< exit(FatalError);
}
} }
void Foam::fv::clouds::addSup void Foam::fv::clouds::addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const ) const
{ {
if (debug) if (debug)
@ -326,10 +341,16 @@ void Foam::fv::clouds::addSup
<< exit(FatalError); << exit(FatalError);
} }
if (fieldName == UName_) if (U.name() == UName_)
{ {
eqn += cloudsPtr_().SU(eqn.psi()); eqn += cloudsPtr_().SU(eqn.psi());
} }
else
{
FatalErrorInFunction
<< "Support for field " << U.name() << " is not implemented"
<< exit(FatalError);
}
} }

View File

@ -177,31 +177,31 @@ public:
//- Add source to continuity equation //- Add source to continuity equation
virtual void addSup virtual void addSup
( (
fvMatrix<scalar>& eqn, const volScalarField& rho,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add source to enthalpy or species equation //- Add source to enthalpy or species equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, const volScalarField& field,
const word& fieldName fvMatrix<scalar>& eqn
) const; ) const;
//- Add source to incompressible momentum equation //- Add source to incompressible momentum equation
virtual void addSup virtual void addSup
( (
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;
//- Add source to compressible momentum equation //- Add source to compressible momentum equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<vector>& eqn, const volVectorField& U,
const word& fieldName fvMatrix<vector>& eqn
) const; ) const;

Some files were not shown because too many files have changed in this diff Show More