mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
use dictionary::lookupOrDefault to simplify some code
This commit is contained in:
@ -77,13 +77,13 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
:
|
||||
mixedFvPatchScalarField(p, iF),
|
||||
accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
|
||||
Twall_("Twall", dict, p.size())
|
||||
Twall_("Twall", dict, p.size()),
|
||||
gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4))
|
||||
{
|
||||
if
|
||||
(
|
||||
mag(accommodationCoeff_) < SMALL
|
||||
||
|
||||
mag(accommodationCoeff_) > 2.0
|
||||
|| mag(accommodationCoeff_) > 2.0
|
||||
)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
@ -96,8 +96,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
" const dictionary&"
|
||||
")",
|
||||
dict
|
||||
) << "unphysical accommodationCoeff_ specified"
|
||||
<< "(0 < accommodationCoeff_ <= 1)" << endl
|
||||
) << "unphysical accommodationCoeff specified"
|
||||
<< "(0 < accommodationCoeff <= 1)" << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -113,15 +113,6 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
fvPatchField<scalar>::operator=(patchInternalField());
|
||||
}
|
||||
|
||||
if (dict.found("gamma"))
|
||||
{
|
||||
gamma_ = readScalar(dict.lookup("gamma"));
|
||||
}
|
||||
else
|
||||
{
|
||||
gamma_ = 1.4;
|
||||
}
|
||||
|
||||
refValue() = *this;
|
||||
refGrad() = 0.0;
|
||||
valueFraction() = 0.0;
|
||||
|
||||
@ -3,20 +3,11 @@
|
||||
int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors")));
|
||||
int nCorr(readInt(pimple.lookup("nCorrectors")));
|
||||
|
||||
int nNonOrthCorr = 0;
|
||||
if (pimple.found("nNonOrthogonalCorrectors"))
|
||||
{
|
||||
nNonOrthCorr = readInt(pimple.lookup("nNonOrthogonalCorrectors"));
|
||||
}
|
||||
int nNonOrthCorr =
|
||||
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
|
||||
|
||||
bool momentumPredictor = true;
|
||||
if (pimple.found("momentumPredictor"))
|
||||
{
|
||||
momentumPredictor = Switch(pimple.lookup("momentumPredictor"));
|
||||
}
|
||||
bool momentumPredictor =
|
||||
pimple.lookupOrDefault<Switch>("momentumPredictor", true);
|
||||
|
||||
bool transonic = false;
|
||||
if (pimple.found("transonic"))
|
||||
{
|
||||
transonic = Switch(pimple.lookup("transonic"));
|
||||
}
|
||||
bool transonic =
|
||||
pimple.lookupOrDefault<Switch>("transonic", false);
|
||||
|
||||
@ -2,32 +2,18 @@
|
||||
|
||||
int nCorr(readInt(piso.lookup("nCorrectors")));
|
||||
|
||||
int nNonOrthCorr = 0;
|
||||
if (piso.found("nNonOrthogonalCorrectors"))
|
||||
{
|
||||
nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors"));
|
||||
}
|
||||
int nNonOrthCorr =
|
||||
piso.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
|
||||
|
||||
bool momentumPredictor = true;
|
||||
if (piso.found("momentumPredictor"))
|
||||
{
|
||||
momentumPredictor = Switch(piso.lookup("momentumPredictor"));
|
||||
}
|
||||
bool momentumPredictor =
|
||||
piso.lookupOrDefault<Switch>("momentumPredictor", true);
|
||||
|
||||
bool transonic = false;
|
||||
if (piso.found("transonic"))
|
||||
{
|
||||
transonic = Switch(piso.lookup("transonic"));
|
||||
}
|
||||
bool transonic =
|
||||
piso.lookupOrDefault<Switch>("transonic", false);
|
||||
|
||||
int nOuterCorr = 1;
|
||||
if (piso.found("nOuterCorrectors"))
|
||||
{
|
||||
nOuterCorr = readInt(piso.lookup("nOuterCorrectors"));
|
||||
}
|
||||
int nOuterCorr =
|
||||
piso.lookupOrDefault<int>("nOuterCorrectors", 1);
|
||||
|
||||
bool ddtPhiCorr =
|
||||
piso.lookupOrDefault<Switch>("ddtPhiCorr", false);
|
||||
|
||||
bool ddtPhiCorr = false;
|
||||
if (piso.found("ddtPhiCorr"))
|
||||
{
|
||||
ddtPhiCorr = Switch(piso.lookup("ddtPhiCorr"));
|
||||
}
|
||||
|
||||
@ -1,25 +1,14 @@
|
||||
dictionary simple = mesh.solutionDict().subDict("SIMPLE");
|
||||
|
||||
int nNonOrthCorr = 0;
|
||||
if (simple.found("nNonOrthogonalCorrectors"))
|
||||
{
|
||||
nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors"));
|
||||
}
|
||||
int nNonOrthCorr =
|
||||
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
|
||||
|
||||
bool momentumPredictor = true;
|
||||
if (simple.found("momentumPredictor"))
|
||||
{
|
||||
momentumPredictor = Switch(simple.lookup("momentumPredictor"));
|
||||
}
|
||||
bool momentumPredictor =
|
||||
simple.lookupOrDefault<Switch>("momentumPredictor", true);
|
||||
|
||||
bool fluxGradp = false;
|
||||
if (simple.found("fluxGradp"))
|
||||
{
|
||||
fluxGradp = Switch(simple.lookup("fluxGradp"));
|
||||
}
|
||||
bool fluxGradp =
|
||||
simple.lookupOrDefault<Switch>("fluxGradp", false);
|
||||
|
||||
bool transonic =
|
||||
simple.lookupOrDefault<Switch>("transonic", false);
|
||||
|
||||
bool transonic = false;
|
||||
if (simple.found("transonic"))
|
||||
{
|
||||
transonic = Switch(simple.lookup("transonic"));
|
||||
}
|
||||
|
||||
@ -40,11 +40,7 @@ scalar maxCo
|
||||
readScalar(runTime.controlDict().lookup("maxCo"))
|
||||
);
|
||||
|
||||
scalar maxDeltaT = GREAT;
|
||||
|
||||
if (runTime.controlDict().found("maxDeltaT"))
|
||||
(
|
||||
maxDeltaT = readScalar(runTime.controlDict().lookup("maxDeltaT"))
|
||||
);
|
||||
scalar maxDeltaT =
|
||||
runTime.controlDict().lookupOrDefault<scalar>("maxDeltaT", GREAT);
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -133,18 +133,12 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
|
||||
{
|
||||
vector rotation(dict.lookup("rotation"));
|
||||
|
||||
bool inDegrees = true;
|
||||
if (dict.found("degrees"))
|
||||
{
|
||||
inDegrees = Switch(dict.lookup("degrees"));
|
||||
}
|
||||
|
||||
calcTransform
|
||||
(
|
||||
rotation.component(vector::X),
|
||||
rotation.component(vector::Y),
|
||||
rotation.component(vector::Z),
|
||||
inDegrees
|
||||
dict.lookupOrDefault<Switch>("degrees", true)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -134,18 +134,12 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
|
||||
{
|
||||
vector rotation(dict.lookup("rotation"));
|
||||
|
||||
bool inDegrees = true;
|
||||
if (dict.found("degrees"))
|
||||
{
|
||||
inDegrees = Switch(dict.lookup("degrees"));
|
||||
}
|
||||
|
||||
calcTransform
|
||||
(
|
||||
rotation.component(vector::X),
|
||||
rotation.component(vector::Y),
|
||||
rotation.component(vector::Z),
|
||||
inDegrees
|
||||
dict.lookupOrDefault<Switch>("degrees", true)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user