surfaceFilmModels::surfaceFilm: Cache the fieldNames to simplify equation source selection

This commit is contained in:
Henry Weller
2021-12-17 15:13:09 +00:00
parent 083b51e30d
commit 7934ed693c
2 changed files with 26 additions and 18 deletions

View File

@ -65,23 +65,21 @@ Foam::fv::surfaceFilm::surfaceFilm
mesh.lookupObject<uniformDimensionedVectorField>("g"), mesh.lookupObject<uniformDimensionedVectorField>("g"),
"surfaceFilm" "surfaceFilm"
), ),
curTimeIndex_(-1) fieldNames_
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::wordList Foam::fv::surfaceFilm::addSupFields() const
{
wordList fieldNames
( (
{ {
surfaceFilm_.rhoPrimary().name(), mesh.foundObject<volScalarField>
(
IOobject::groupName("rho", surfaceFilm_.phaseName())
)
? IOobject::groupName("rho", surfaceFilm_.phaseName())
: surfaceFilm_.primaryThermo().rho()().name(),
surfaceFilm_.UPrimary().name(), surfaceFilm_.UPrimary().name(),
surfaceFilm_.primaryThermo().he().name() surfaceFilm_.primaryThermo().he().name()
} }
); ),
curTimeIndex_(-1)
{
if (isA<basicSpecieMixture>(surfaceFilm_.primaryThermo())) if (isA<basicSpecieMixture>(surfaceFilm_.primaryThermo()))
{ {
const basicSpecieMixture& composition = const basicSpecieMixture& composition =
@ -93,12 +91,18 @@ Foam::wordList Foam::fv::surfaceFilm::addSupFields() const
{ {
if (composition.solve(i)) if (composition.solve(i))
{ {
fieldNames.append(Y[i].name()); fieldNames_.append(Y[i].name());
} }
} }
} }
}
return fieldNames;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::wordList Foam::fv::surfaceFilm::addSupFields() const
{
return fieldNames_;
} }
@ -126,7 +130,7 @@ void Foam::fv::surfaceFilm::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == surfaceFilm_.rhoPrimary().name()) if (fieldName == fieldNames_[0])
{ {
eqn += surfaceFilm_.Srho(); eqn += surfaceFilm_.Srho();
} }
@ -151,11 +155,11 @@ void Foam::fv::surfaceFilm::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == surfaceFilm_.rhoPrimary().name()) if (fieldName == fieldNames_[0])
{ {
eqn += surfaceFilm_.Srho(); eqn += surfaceFilm_.Srho();
} }
else if (fieldName == surfaceFilm_.primaryThermo().he().name()) else if (fieldName == fieldNames_[2])
{ {
eqn += surfaceFilm_.Sh(); eqn += surfaceFilm_.Sh();
} }
@ -195,7 +199,7 @@ void Foam::fv::surfaceFilm::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl; Info<< type() << ": applying source to " << eqn.psi().name() << endl;
} }
if (fieldName == surfaceFilm_.UPrimary().name()) if (fieldName == fieldNames_[1])
{ {
eqn += surfaceFilm_.SU(); eqn += surfaceFilm_.SU();
} }

View File

@ -67,6 +67,10 @@ class surfaceFilm
//- The surface film model //- The surface film model
regionModels::surfaceFilmModels::thermoSingleLayer surfaceFilm_; regionModels::surfaceFilmModels::thermoSingleLayer surfaceFilm_;
//- List of fields for which the fvModel adds source term
// to the transport equation
wordList fieldNames_;
//- Current time index (used for updating) //- Current time index (used for updating)
mutable label curTimeIndex_; mutable label curTimeIndex_;