STYLE: scalarTransport function object clean-up

This commit is contained in:
Andrew Heather
2016-12-20 16:54:00 +00:00
parent 953594286f
commit 46ce5659b4
2 changed files with 18 additions and 42 deletions

View File

@ -74,6 +74,11 @@ Foam::volScalarField& Foam::functionObjects::scalarTransport::transportedField()
) )
); );
store(fieldName_, tfldPtr); store(fieldName_, tfldPtr);
if (phaseName_ != "none")
{
mesh_.setFluxRequired(fieldName_);
}
} }
return const_cast<volScalarField&> return const_cast<volScalarField&>
@ -86,8 +91,7 @@ Foam::volScalarField& Foam::functionObjects::scalarTransport::transportedField()
Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D
( (
const volScalarField& s, const volScalarField& s,
const surfaceScalarField& phi, const surfaceScalarField& phi
const volScalarField& alpha
) const ) const
{ {
typedef incompressible::turbulenceModel icoModel; typedef incompressible::turbulenceModel icoModel;
@ -95,8 +99,6 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D
word Dname("D" + s.name()); word Dname("D" + s.name());
volScalarField phaseMask(pos(alpha - 0.99));
if (constantD_) if (constantD_)
{ {
tmp<volScalarField> tD tmp<volScalarField> tD
@ -116,7 +118,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D
) )
); );
return phaseMask*tD; return tD;
} }
else if (nutName_ != "none") else if (nutName_ != "none")
{ {
@ -125,7 +127,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D
return tmp<volScalarField> return tmp<volScalarField>
( (
new volScalarField(Dname, phaseMask*nutMean) new volScalarField(Dname, nutMean)
); );
} }
else if (foundObject<icoModel>(turbulenceModel::propertiesName)) else if (foundObject<icoModel>(turbulenceModel::propertiesName))
@ -137,7 +139,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D
return tmp<volScalarField> return tmp<volScalarField>
( (
new volScalarField(Dname, phaseMask*model.nuEff()) new volScalarField(Dname, model.nuEff())
); );
} }
else if (foundObject<cmpModel>(turbulenceModel::propertiesName)) else if (foundObject<cmpModel>(turbulenceModel::propertiesName))
@ -149,7 +151,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::D
return tmp<volScalarField> return tmp<volScalarField>
( (
new volScalarField(Dname, phaseMask*model.muEff()) new volScalarField(Dname, model.muEff())
); );
} }
else else
@ -268,7 +270,8 @@ bool Foam::functionObjects::scalarTransport::execute()
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_.time(), mesh_.time(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
false
), ),
mesh_, mesh_,
dimensionedScalar("tPhi", dimMass/dimTime, 0.0) dimensionedScalar("tPhi", dimMass/dimTime, 0.0)
@ -314,37 +317,10 @@ bool Foam::functionObjects::scalarTransport::execute()
} }
} }
tmp<volScalarField> tPhaseMask
(
new volScalarField
(
IOobject
(
"tPhaseMask",
mesh_.time().timeName(),
mesh_.time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("tPhaseMask", dimless, 1.0)
)
);
volScalarField& phaseMask = tPhaseMask.ref();
// Set phaseMask if s is transported in a phase
if (phaseName_ != "none")
{
const volScalarField& alpha =
mesh_.lookupObject<volScalarField>(phaseName_);
phaseMask = alpha;
}
volScalarField& s = transportedField(); volScalarField& s = transportedField();
// Calculate the diffusivity // Calculate the diffusivity
volScalarField D(this->D(s, phi, phaseMask)); volScalarField D(this->D(s, phi));
word divScheme("div(phi," + schemesField_ + ")"); word divScheme("div(phi," + schemesField_ + ")");
word laplacianScheme("laplacian(" + D.name() + "," + schemesField_ + ")"); word laplacianScheme("laplacian(" + D.name() + "," + schemesField_ + ")");
@ -356,7 +332,7 @@ bool Foam::functionObjects::scalarTransport::execute()
relaxCoeff = mesh_.equationRelaxationFactor(schemesField_); relaxCoeff = mesh_.equationRelaxationFactor(schemesField_);
} }
// two phase scalar transport // Two phase scalar transport
if (phaseName_ != "none") if (phaseName_ != "none")
{ {
const volScalarField& alpha = const volScalarField& alpha =
@ -365,6 +341,7 @@ bool Foam::functionObjects::scalarTransport::execute()
const surfaceScalarField& limitedPhiAlpa = const surfaceScalarField& limitedPhiAlpa =
mesh_.lookupObject<surfaceScalarField>(phasePhiCompressedName_); mesh_.lookupObject<surfaceScalarField>(phasePhiCompressedName_);
D *= pos(alpha - 0.99);
/* /*
surfaceScalarField phic(2.0*mag(phi/mesh_.magSf())); surfaceScalarField phic(2.0*mag(phi/mesh_.magSf()));
@ -402,8 +379,8 @@ bool Foam::functionObjects::scalarTransport::execute()
// Reset D dimensions consistent with limitedPhiAlpa // Reset D dimensions consistent with limitedPhiAlpa
D.dimensions().reset(limitedPhiAlpa.dimensions()/dimLength); D.dimensions().reset(limitedPhiAlpa.dimensions()/dimLength);
tmp<surfaceScalarField> tTPhiUD;
// Solve // Solve
tmp<surfaceScalarField> tTPhiUD;
for (label i = 0; i <= nCorr_; i++) for (label i = 0; i <= nCorr_; i++)
{ {
fvScalarMatrix sEqn fvScalarMatrix sEqn

View File

@ -212,8 +212,7 @@ class scalarTransport
tmp<volScalarField> D tmp<volScalarField> D
( (
const volScalarField& s, const volScalarField& s,
const surfaceScalarField& phi, const surfaceScalarField& phi
const volScalarField& alpha
) const; ) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct