Commit 43f904ba authored by Kutalmis Bercin's avatar Kutalmis Bercin Committed by Andrew Heather
Browse files

STYLE: phaseSystemModels: modernise code style

BUG: LemmertChawla: add missing write function

BUG: alphatPhaseChangeJayatillekeWallFunction:
     remove unused maxExp, Tw, and Tp objects

BUG: alphatFixedDmdtWallBoilingWallFunction: add missing ctor entries
parent 50137a48
......@@ -81,7 +81,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class alphaContactAngleFvPatch Declaration
Class alphaContactAngleFvPatch Declaration
\*---------------------------------------------------------------------------*/
class alphaContactAngleFvPatchScalarField
......@@ -108,13 +108,16 @@ public:
public:
// Constructors
//- Default construct
interfaceThetaProps()
{}
//- Construct from Istream
interfaceThetaProps(Istream&);
// Member functions
// Member Functions
//- Return the equilibrium contact angle theta0
scalar theta0(bool matched=true) const
......@@ -124,7 +127,7 @@ public:
}
//- Return the dynamic contact angle velocity scale
scalar uTheta() const
scalar uTheta() const noexcept
{
return uTheta_;
}
......@@ -144,7 +147,7 @@ public:
}
// IO functions
// IOstream operators
friend Istream& operator>>(Istream&, interfaceThetaProps&);
friend Ostream& operator<<(Ostream&, const interfaceThetaProps&);
......@@ -160,8 +163,9 @@ public:
private:
// Private data
// Private Data
//- Interface properties
thetaPropsTable thetaProps_;
......@@ -189,7 +193,7 @@ public:
);
//- Construct by mapping given alphaContactAngleFvPatchScalarField
// onto a new patch
//- onto a new patch
alphaContactAngleFvPatchScalarField
(
const alphaContactAngleFvPatchScalarField&,
......@@ -227,10 +231,10 @@ public:
}
// Member functions
// Member Functions
//- Return the contact angle properties
const thetaPropsTable& thetaProps() const
const thetaPropsTable& thetaProps() const noexcept
{
return thetaProps_;
}
......
......@@ -65,7 +65,7 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
)
:
alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField(p, iF, dict),
vaporPhaseName_(dict.lookup("vaporPhase")),
vaporPhaseName_(dict.get<word>("vaporPhase")),
relax_(dict.getOrDefault<scalar>("relax", 1)),
fixedDmdt_(dict.getOrDefault<scalar>("fixedDmdt", 0)),
L_(dict.getOrDefault<scalar>("L", 0))
......@@ -88,6 +88,8 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
iF,
mapper
),
vaporPhaseName_(psf.vaporPhaseName_),
relax_(psf.relax_),
fixedDmdt_(psf.fixedDmdt_),
L_(psf.L_)
{}
......@@ -100,6 +102,7 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
)
:
alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField(psf),
vaporPhaseName_(psf.vaporPhaseName_),
relax_(psf.relax_),
fixedDmdt_(psf.fixedDmdt_),
L_(psf.L_)
......@@ -114,6 +117,7 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
)
:
alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField(psf, iF),
vaporPhaseName_(psf.vaporPhaseName_),
relax_(psf.relax_),
fixedDmdt_(psf.fixedDmdt_),
L_(psf.L_)
......@@ -129,10 +133,8 @@ activePhasePair(const phasePairKey& phasePair) const
{
return true;
}
else
{
return false;
}
return false;
}
......@@ -143,14 +145,12 @@ dmdt(const phasePairKey& phasePair) const
{
return dmdt_;
}
else
{
FatalErrorInFunction
<< " dmdt requested for invalid phasePair!"
<< abort(FatalError);
return mDotL_;
}
FatalErrorInFunction
<< " dmdt requested for invalid phasePair!"
<< abort(FatalError);
return mDotL_;
}
......@@ -161,14 +161,12 @@ mDotL(const phasePairKey& phasePair) const
{
return mDotL_;
}
else
{
FatalErrorInFunction
<< " mDotL requested for invalid phasePair!"
<< abort(FatalError);
return mDotL_;
}
FatalErrorInFunction
<< " mDotL requested for invalid phasePair!"
<< abort(FatalError);
return mDotL_;
}
......@@ -179,7 +177,9 @@ void alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
return;
}
dmdt_ = (1 - relax_)*dmdt_ + relax_*fixedDmdt_;
dmdt_ *= (scalar(1) - relax_);
dmdt_ += relax_*fixedDmdt_;
mDotL_ = dmdt_*L_;
operator==(calcAlphat(*this));
......
......@@ -96,12 +96,12 @@ class alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
:
public alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField
{
// Private data
// Private Data
//- name on the phase
//- Name of the vapor phase
word vaporPhaseName_;
//- dmdt relaxationFactor
//- Relaxation factor for dmdt
scalar relax_;
//- Volumetric phase-change mass flux in near wall cells
......@@ -135,8 +135,8 @@ public:
);
//- Construct by mapping given
// alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
// onto a new patch
//- alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
//- onto a new patch
alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
(
const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField&,
......@@ -187,7 +187,7 @@ public:
}
// Member functions
// Member Functions
//- Is there phase change mass transfer for this phasePair
virtual bool activePhasePair(const phasePairKey&) const;
......@@ -198,7 +198,8 @@ public:
//- Return the rate of phase-change for specific phase pair
virtual const scalarField& mDotL(const phasePairKey&) const;
// Evaluation functions
// Evaluation
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
......
......@@ -45,14 +45,12 @@ namespace compressible
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
scalar alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::maxExp_
= 50.0;
scalar alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::tolerance_
= 0.01;
label alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::maxIters_
= 10;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::checkType()
{
......@@ -83,18 +81,18 @@ alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
const scalarField& Prat
) const
{
tmp<scalarField> typsf(new scalarField(this->size()));
scalarField& ypsf = typsf.ref();
auto typsf = tmp<scalarField>::New(this->size());
auto& ypsf = typsf.ref();
forAll(ypsf, facei)
{
scalar ypt = 11.0;
for (int i=0; i<maxIters_; i++)
for (int i = 0; i < maxIters_; ++i)
{
scalar f = ypt - (log(E_*ypt)/kappa_ + P[facei])/Prat[facei];
scalar df = 1 - 1.0/(ypt*kappa_*Prat[facei]);
scalar yptNew = ypt - f/df;
const scalar f = ypt - (log(E_*ypt)/kappa_ + P[facei])/Prat[facei];
const scalar df = 1.0 - 1.0/(ypt*kappa_*Prat[facei]);
const scalar yptNew = ypt - f/df;
if (yptNew < VSMALL)
{
......@@ -116,26 +114,23 @@ alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
return typsf;
}
tmp<scalarField>
alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::calcAlphat
(
const scalarField& prevAlphat
) const
{
// Lookup the fluid model
const phaseSystem& fluid =
db().lookupObject<phaseSystem>("phaseProperties");
const phaseModel& phase
(
fluid.phases()[internalField().group()]
);
const phaseModel& phase = fluid.phases()[internalField().group()];
const label patchi = patch().index();
// Retrieve turbulence properties from model
const phaseCompressibleTurbulenceModel& turbModel =
const auto& turbModel =
db().lookupObject<phaseCompressibleTurbulenceModel>
(
IOobject::groupName(turbulenceModel::propertiesName, phase.name())
......@@ -163,11 +158,6 @@ alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::calcAlphat
const fvPatchScalarField& hew =
phase.thermo().he().boundaryField()[patchi];
const fvPatchScalarField& Tw =
phase.thermo().T().boundaryField()[patchi];
scalarField Tp(Tw.patchInternalField());
// Heat flux [W/m2] - lagging alphatw
const scalarField qDot
(
......@@ -178,18 +168,19 @@ alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::calcAlphat
scalarField yPlus(uTau*y/(muw/rhow));
scalarField Pr(muw/alphaw);
const scalarField Pr(muw/alphaw);
// Molecular-to-turbulent Prandtl number ratio
scalarField Prat(Pr/Prt_);
const scalarField Prat(Pr/Prt_);
// Thermal sublayer thickness
scalarField P(this->Psmooth(Prat));
const scalarField P(this->Psmooth(Prat));
scalarField yPlusTherm(this->yPlusTherm(P, Prat));
tmp<scalarField> tyPlusTherm = this->yPlusTherm(P, Prat);
const scalarField& yPlusTherm = tyPlusTherm.cref();
tmp<scalarField> talphatConv(new scalarField(this->size()));
scalarField& alphatConv = talphatConv.ref();
auto talphatConv = tmp<scalarField>::New(this->size());
auto& alphatConv = talphatConv.ref();
// Populate boundary values
forAll(alphatConv, facei)
......@@ -198,19 +189,20 @@ alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::calcAlphat
scalar alphaEff = 0.0;
if (yPlus[facei] < yPlusTherm[facei])
{
scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei];
scalar B = qDot[facei]*Pr[facei]*yPlus[facei];
scalar C = Pr[facei]*0.5*rhow[facei]*uTau[facei]*sqr(magUp[facei]);
const scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei];
const scalar B = qDot[facei]*Pr[facei]*yPlus[facei];
const scalar C =
Pr[facei]*0.5*rhow[facei]*uTau[facei]*sqr(magUp[facei]);
alphaEff = A/(B + C + VSMALL);
}
else
{
scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei];
scalar B =
const scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei];
const scalar B =
qDot[facei]*Prt_*(1.0/kappa_*log(E_*yPlus[facei]) + P[facei]);
scalar magUc =
const scalar magUc =
uTau[facei]/kappa_*log(E_*yPlusTherm[facei]) - mag(Uw[facei]);
scalar C =
const scalar C =
0.5*rhow[facei]*uTau[facei]
*(Prt_*sqr(magUp[facei]) + (Pr[facei] - Prt_)*sqr(magUc));
alphaEff = A/(B + C + VSMALL);
......
......@@ -95,27 +95,28 @@ class alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField
:
public alphatPhaseChangeWallFunctionFvPatchScalarField
{
protected:
// Protected data
// Protected Data
//- Turbulent Prandtl number
scalar Prt_;
//- Cmu coefficient
//- Empirical model coefficient
scalar Cmu_;
//- Von Karman constant
scalar kappa_;
//- E coefficient
//- Wall roughness parameter
scalar E_;
// Solution parameters
static scalar maxExp_;
//- Absolute tolerance
static scalar tolerance_;
//- Maximum number of iterations
static label maxIters_;
......@@ -165,8 +166,8 @@ public:
);
//- Construct by mapping given
// alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField
// onto a new patch
//- alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField
//- onto a new patch
alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField
(
const alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField&,
......@@ -217,9 +218,9 @@ public:
}
// Member functions
// Member Functions
// Evaluation functions
// Evaluation
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
......
......@@ -119,8 +119,8 @@ public:
);
//- Construct by mapping given
// alphatPhaseChangeWallFunctionFvPatchScalarField
// onto a new patch
//- alphatPhaseChangeWallFunctionFvPatchScalarField
//- onto a new patch
alphatPhaseChangeWallFunctionFvPatchScalarField
(
const alphatPhaseChangeWallFunctionFvPatchScalarField&,
......@@ -190,9 +190,9 @@ public:
}
// Evaluation Functions
// Evaluation
//- Update the coefficients associated with the patch field
//- Update the coefficients associated with the patch field
virtual void updateCoeffs() = 0;
......
......@@ -395,10 +395,8 @@ activePhasePair(const phasePairKey& phasePair) const
{
return true;
}
else
{
return false;
}
return false;
}
const scalarField& alphatWallBoilingWallFunctionFvPatchScalarField::
......@@ -408,14 +406,12 @@ dmdt(const phasePairKey& phasePair) const
{
return dmdt_;
}
else
{
FatalErrorInFunction
<< " dmdt requested for invalid phasePair!"
<< abort(FatalError);
return dmdt_;
}
FatalErrorInFunction
<< " dmdt requested for invalid phasePair!"
<< abort(FatalError);
return dmdt_;
}
const scalarField& alphatWallBoilingWallFunctionFvPatchScalarField::
......@@ -425,19 +421,17 @@ mDotL(const phasePairKey& phasePair) const
{
return mDotL_;
}
else
{
FatalErrorInFunction
<< " mDotL requested for invalid phasePair!"
<< abort(FatalError);
return mDotL_;
}
FatalErrorInFunction
<< " mDotL requested for invalid phasePair!"
<< abort(FatalError);
return mDotL_;
}
void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
......@@ -458,13 +452,13 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
db().lookupObject<phaseSystem>("phaseProperties")
);
const saturationModel& satModel =
const auto& satModel =
db().lookupObject<saturationModel>("saturationModel");
const label patchi = patch().index();
const scalar t = this->db().time().timeOutputValue();
scalar relax = relax_->value(t);
const scalar relax = relax_->value(t);
switch (phaseType_)
{
......@@ -562,7 +556,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
const phaseModel& vapor(fluid.phases()[otherPhaseName_]);
// Retrieve turbulence properties from models
const phaseCompressibleTurbulenceModel& turbModel =
const auto& turbModel =
db().lookupObject<phaseCompressibleTurbulenceModel>
(
IOobject::groupName
......@@ -571,7 +565,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
liquid.name()
)
);
const phaseCompressibleTurbulenceModel& vaporTurbModel =
const auto& vaporTurbModel =
db().lookupObject<phaseCompressibleTurbulenceModel>
(
IOobject::groupName
......@@ -583,7 +577,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
const tmp<scalarField> tnutw = turbModel.nut(patchi);
const scalar Cmu25(pow025(Cmu_));
const scalar Cmu25 = pow025(Cmu_);
const scalarField& y = turbModel.y()[patchi];
......@@ -636,7 +630,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
satModel.Tsat(liquid.thermo().p());
const volScalarField& Tsat = tTsat();
const fvPatchScalarField& Tsatw(Tsat.boundaryField()[patchi]);
const fvPatchScalarField& Tsatw = Tsat.boundaryField()[patchi];