Skip to content
Snippets Groups Projects
Commit 99628401 authored by Mark Olesen's avatar Mark Olesen
Browse files

use dictionary::lookupOrDefault to simplify some code

parent 14a392fe
No related branches found
No related tags found
No related merge requests found
...@@ -77,13 +77,13 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ...@@ -77,13 +77,13 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))), accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
Twall_("Twall", dict, p.size()) Twall_("Twall", dict, p.size()),
gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4))
{ {
if if
( (
mag(accommodationCoeff_) < SMALL mag(accommodationCoeff_) < SMALL
|| || mag(accommodationCoeff_) > 2.0
mag(accommodationCoeff_) > 2.0
) )
{ {
FatalIOErrorIn FatalIOErrorIn
...@@ -96,8 +96,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ...@@ -96,8 +96,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
" const dictionary&" " const dictionary&"
")", ")",
dict dict
) << "unphysical accommodationCoeff_ specified" ) << "unphysical accommodationCoeff specified"
<< "(0 < accommodationCoeff_ <= 1)" << endl << "(0 < accommodationCoeff <= 1)" << endl
<< exit(FatalError); << exit(FatalError);
} }
...@@ -113,15 +113,6 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ...@@ -113,15 +113,6 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
fvPatchField<scalar>::operator=(patchInternalField()); fvPatchField<scalar>::operator=(patchInternalField());
} }
if (dict.found("gamma"))
{
gamma_ = readScalar(dict.lookup("gamma"));
}
else
{
gamma_ = 1.4;
}
refValue() = *this; refValue() = *this;
refGrad() = 0.0; refGrad() = 0.0;
valueFraction() = 0.0; valueFraction() = 0.0;
......
...@@ -3,20 +3,11 @@ ...@@ -3,20 +3,11 @@
int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors"))); int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors")));
int nCorr(readInt(pimple.lookup("nCorrectors"))); int nCorr(readInt(pimple.lookup("nCorrectors")));
int nNonOrthCorr = 0; int nNonOrthCorr =
if (pimple.found("nNonOrthogonalCorrectors")) pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
{
nNonOrthCorr = readInt(pimple.lookup("nNonOrthogonalCorrectors"));
}
bool momentumPredictor = true; bool momentumPredictor =
if (pimple.found("momentumPredictor")) pimple.lookupOrDefault<Switch>("momentumPredictor", true);
{
momentumPredictor = Switch(pimple.lookup("momentumPredictor"));
}
bool transonic = false; bool transonic =
if (pimple.found("transonic")) pimple.lookupOrDefault<Switch>("transonic", false);
{
transonic = Switch(pimple.lookup("transonic"));
}
...@@ -2,32 +2,18 @@ ...@@ -2,32 +2,18 @@
int nCorr(readInt(piso.lookup("nCorrectors"))); int nCorr(readInt(piso.lookup("nCorrectors")));
int nNonOrthCorr = 0; int nNonOrthCorr =
if (piso.found("nNonOrthogonalCorrectors")) piso.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
{
nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors"));
}
bool momentumPredictor = true; bool momentumPredictor =
if (piso.found("momentumPredictor")) piso.lookupOrDefault<Switch>("momentumPredictor", true);
{
momentumPredictor = Switch(piso.lookup("momentumPredictor"));
}
bool transonic = false; bool transonic =
if (piso.found("transonic")) piso.lookupOrDefault<Switch>("transonic", false);
{
transonic = Switch(piso.lookup("transonic"));
}
int nOuterCorr = 1; int nOuterCorr =
if (piso.found("nOuterCorrectors")) piso.lookupOrDefault<int>("nOuterCorrectors", 1);
{
nOuterCorr = readInt(piso.lookup("nOuterCorrectors")); bool ddtPhiCorr =
} piso.lookupOrDefault<Switch>("ddtPhiCorr", false);
bool ddtPhiCorr = false;
if (piso.found("ddtPhiCorr"))
{
ddtPhiCorr = Switch(piso.lookup("ddtPhiCorr"));
}
dictionary simple = mesh.solutionDict().subDict("SIMPLE"); dictionary simple = mesh.solutionDict().subDict("SIMPLE");
int nNonOrthCorr = 0; int nNonOrthCorr =
if (simple.found("nNonOrthogonalCorrectors")) simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
{
nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors"));
}
bool momentumPredictor = true; bool momentumPredictor =
if (simple.found("momentumPredictor")) simple.lookupOrDefault<Switch>("momentumPredictor", true);
{
momentumPredictor = Switch(simple.lookup("momentumPredictor"));
}
bool fluxGradp = false; bool fluxGradp =
if (simple.found("fluxGradp")) simple.lookupOrDefault<Switch>("fluxGradp", false);
{
fluxGradp = Switch(simple.lookup("fluxGradp")); 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 ...@@ -40,11 +40,7 @@ scalar maxCo
readScalar(runTime.controlDict().lookup("maxCo")) readScalar(runTime.controlDict().lookup("maxCo"))
); );
scalar maxDeltaT = GREAT; scalar maxDeltaT =
runTime.controlDict().lookupOrDefault<scalar>("maxDeltaT", GREAT);
if (runTime.controlDict().found("maxDeltaT"))
(
maxDeltaT = readScalar(runTime.controlDict().lookup("maxDeltaT"))
);
// ************************************************************************* // // ************************************************************************* //
...@@ -133,18 +133,12 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation ...@@ -133,18 +133,12 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
{ {
vector rotation(dict.lookup("rotation")); vector rotation(dict.lookup("rotation"));
bool inDegrees = true;
if (dict.found("degrees"))
{
inDegrees = Switch(dict.lookup("degrees"));
}
calcTransform calcTransform
( (
rotation.component(vector::X), rotation.component(vector::X),
rotation.component(vector::Y), rotation.component(vector::Y),
rotation.component(vector::Z), rotation.component(vector::Z),
inDegrees dict.lookupOrDefault<Switch>("degrees", true)
); );
} }
......
...@@ -134,18 +134,12 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation ...@@ -134,18 +134,12 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
{ {
vector rotation(dict.lookup("rotation")); vector rotation(dict.lookup("rotation"));
bool inDegrees = true;
if (dict.found("degrees"))
{
inDegrees = Switch(dict.lookup("degrees"));
}
calcTransform calcTransform
( (
rotation.component(vector::X), rotation.component(vector::X),
rotation.component(vector::Y), rotation.component(vector::Y),
rotation.component(vector::Z), rotation.component(vector::Z),
inDegrees dict.lookupOrDefault<Switch>("degrees", true)
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment