ENH: add default control values to ease SIMPLE->PIMPLE transition

- add const-ness for control variables

- drop unused fluxGradp variable

- use lookupOrDefault instead of found/lookup combination
This commit is contained in:
Mark Olesen
2010-05-20 08:24:55 +02:00
parent 0abf9b4529
commit 80b8071e75
18 changed files with 93 additions and 134 deletions

View File

@ -1,3 +1,4 @@
const dictionary& Bpiso = mesh.solutionDict().subDict("BPISO"); const dictionary& Bpiso = mesh.solutionDict().subDict("BPISO");
const int nBcorr = Bpiso.lookupOrDefault<int>("nCorrectors", 1);
int nBcorr(readInt(Bpiso.lookup("nCorrectors")));

View File

@ -1,25 +1,11 @@
dictionary simple = fluidRegions[i].solutionDict().subDict("SIMPLE"); const dictionary& simple = fluidRegions[i].solutionDict().subDict("SIMPLE");
int nNonOrthCorr = 0; const int nNonOrthCorr =
if (simple.found("nNonOrthogonalCorrectors")) simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
{
nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors"));
}
bool momentumPredictor = true; const bool momentumPredictor =
if (simple.found("momentumPredictor")) simple.lookupOrDefault<bool>("momentumPredictor", true);
{
momentumPredictor = Switch(simple.lookup("momentumPredictor"));
}
bool fluxGradp = false; const bool transonic =
if (simple.found("fluxGradp")) simple.lookupOrDefault<bool>("transonic", false);
{
fluxGradp = Switch(simple.lookup("fluxGradp"));
}
bool transonic = false;
if (simple.found("transonic"))
{
transonic = Switch(simple.lookup("transonic"));
}

View File

@ -1,7 +1,5 @@
dictionary simple = solidRegions[i].solutionDict().subDict("SIMPLE"); const dictionary& simple = solidRegions[i].solutionDict().subDict("SIMPLE");
const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
int nNonOrthCorr = 0;
if (simple.found("nNonOrthogonalCorrectors"))
{
nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors"));
}

View File

@ -1,9 +1,11 @@
const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE"); const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE");
int nCorr(readInt(pimple.lookup("nCorrectors"))); const int nCorr =
pimple.lookupOrDefault<int>("nCorrectors", 1);
int nNonOrthCorr = const int nNonOrthCorr =
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0); pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
bool momentumPredictor = const bool momentumPredictor =
pimple.lookupOrDefault<Switch>("momentumPredictor", true); pimple.lookupOrDefault<bool>("momentumPredictor", true);

View File

@ -1,27 +1,17 @@
dictionary piso = fluidRegions[i].solutionDict().subDict("PISO"); const dictionary& piso = fluidRegions[i].solutionDict().subDict("PISO");
int nCorr(readInt(piso.lookup("nCorrectors"))); const int nOuterCorr =
piso.lookupOrDefault<int>("nOuterCorrectors", 1);
int nNonOrthCorr = 0; const int nCorr =
if (piso.found("nNonOrthogonalCorrectors")) piso.lookupOrDefault<int>("nCorrectors", 1);
{
nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors"));
}
bool momentumPredictor = true; const int nNonOrthCorr =
if (piso.found("momentumPredictor")) piso.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
{
momentumPredictor = Switch(piso.lookup("momentumPredictor"));
}
bool transonic = false; const bool momentumPredictor =
if (piso.found("transonic")) piso.lookupOrDefault<bool>("momentumPredictor", true);
{
transonic = Switch(piso.lookup("transonic")); const bool transonic =
} piso.lookupOrDefault<bool>("transonic", false);
int nOuterCorr = 1;
if (piso.found("nOuterCorrectors"))
{
nOuterCorr = readInt(piso.lookup("nOuterCorrectors"));
}

View File

@ -4,4 +4,6 @@
const dictionary& pimple = solutionDict.subDict("PIMPLE"); const dictionary& pimple = solutionDict.subDict("PIMPLE");
int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors"))); const int nOuterCorr =
pimple.lookupOrDefault<int>("nOuterCorrectors", 1);

View File

@ -1,7 +1,5 @@
const dictionary& piso = solidRegions[i].solutionDict().subDict("PISO"); const dictionary& piso = solidRegions[i].solutionDict().subDict("PISO");
int nNonOrthCorr = 0; const int nNonOrthCorr =
if (piso.found("nNonOrthogonalCorrectors")) piso.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
{
nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors"));
}

View File

@ -1,14 +1,9 @@
# include "readTimeControls.H" #include "readTimeControls.H"
# include "readPIMPLEControls.H" #include "readPIMPLEControls.H"
bool correctPhi = false; const bool correctPhi =
if (pimple.found("correctPhi")) pimple.lookupOrDefault<bool>("correctPhi", false);
{
correctPhi = Switch(pimple.lookup("correctPhi")); const bool checkMeshCourantNo =
} pimple.lookupOrDefault<bool>("checkMeshCourantNo", false);
bool checkMeshCourantNo = false;
if (pimple.found("checkMeshCourantNo"))
{
checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo"));
}

View File

@ -1,5 +1,5 @@
#include "readPISOControls.H" #include "readPISOControls.H"
#include "readTimeControls.H" #include "readTimeControls.H"
label nAlphaCorr label nAlphaCorr
( (
@ -19,14 +19,9 @@
<< exit(FatalError); << exit(FatalError);
} }
bool correctPhi = true; const bool correctPhi =
if (piso.found("correctPhi")) piso.lookupOrDefault<bool>("correctPhi", true);
{
correctPhi = Switch(piso.lookup("correctPhi")); const bool checkMeshCourantNo =
} piso.lookupOrDefault<bool>("checkMeshCourantNo", false);
bool checkMeshCourantNo = false;
if (piso.found("checkMeshCourantNo"))
{
checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo"));
}

View File

@ -1,14 +1,9 @@
# include "readTimeControls.H" # include "readTimeControls.H"
# include "readPISOControls.H" # include "readPISOControls.H"
bool correctPhi = true; const bool correctPhi =
if (piso.found("correctPhi")) piso.lookupOrDefault<bool>("correctPhi", true);
{
correctPhi = Switch(piso.lookup("correctPhi")); const bool checkMeshCourantNo =
} piso.lookupOrDefault<bool>("checkMeshCourantNo", false);
bool checkMeshCourantNo = false;
if (piso.found("checkMeshCourantNo"))
{
checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo"));
}

View File

@ -1,5 +1,6 @@
const dictionary& stressControl = mesh.solutionDict().subDict("stressAnalysis"); const dictionary& stressControl = mesh.solutionDict().subDict("stressAnalysis");
int nCorr(readInt(stressControl.lookup("nCorrectors"))); const int nCorr = stressControl.lookupOrDefault<int>("nCorrectors", 1);
scalar convergenceTolerance(readScalar(stressControl.lookup("D"))); scalar convergenceTolerance(readScalar(stressControl.lookup("D")));
Switch compactNormalStress(stressControl.lookup("compactNormalStress")); Switch compactNormalStress(stressControl.lookup("compactNormalStress"));

View File

@ -1,13 +1,17 @@
dictionary pimple = mesh.solutionDict().subDict("PIMPLE"); const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE");
int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors"))); const int nOuterCorr =
int nCorr(readInt(pimple.lookup("nCorrectors"))); pimple.lookupOrDefault<int>("nOuterCorrectors", 1);
int nNonOrthCorr = const int nCorr =
pimple.lookupOrDefault<int>("nCorrectors", 1);
const int nNonOrthCorr =
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0); pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
bool momentumPredictor = const bool momentumPredictor =
pimple.lookupOrDefault<Switch>("momentumPredictor", true); pimple.lookupOrDefault<bool>("momentumPredictor", true);
const bool transonic =
pimple.lookupOrDefault<bool>("transonic", false);
bool transonic =
pimple.lookupOrDefault<Switch>("transonic", false);

View File

@ -1,15 +1,17 @@
dictionary piso = mesh.solutionDict().subDict("PISO"); const dictionary& piso = mesh.solutionDict().subDict("PISO");
int nCorr(readInt(piso.lookup("nCorrectors"))); const int nOuterCorr =
piso.lookupOrDefault<int>("nOuterCorrectors", 1);
int nNonOrthCorr = const int nCorr =
piso.lookupOrDefault<int>("nCorrectors", 1);
const int nNonOrthCorr =
piso.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0); piso.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
bool momentumPredictor = const bool momentumPredictor =
piso.lookupOrDefault<Switch>("momentumPredictor", true); piso.lookupOrDefault<bool>("momentumPredictor", true);
bool transonic = const bool transonic =
piso.lookupOrDefault<Switch>("transonic", false); piso.lookupOrDefault<bool>("transonic", false);
int nOuterCorr =
piso.lookupOrDefault<int>("nOuterCorrectors", 1);

View File

@ -1,14 +1,11 @@
dictionary simple = mesh.solutionDict().subDict("SIMPLE"); const dictionary& simple = mesh.solutionDict().subDict("SIMPLE");
int nNonOrthCorr = const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0); simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
bool momentumPredictor = const bool momentumPredictor =
simple.lookupOrDefault<Switch>("momentumPredictor", true); simple.lookupOrDefault<bool>("momentumPredictor", true);
bool fluxGradp = const bool transonic =
simple.lookupOrDefault<Switch>("fluxGradp", false); simple.lookupOrDefault<bool>("transonic", false);
bool transonic =
simple.lookupOrDefault<Switch>("transonic", false);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,15 +29,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
Switch adjustTimeStep const bool adjustTimeStep =
( runTime.controlDict().lookupOrDefault<bool>("adjustTimeStep", false);
runTime.controlDict().lookup("adjustTimeStep")
);
scalar maxCo scalar maxCo =
( runTime.controlDict().lookupOrDefault<scalar>("maxCo", 1.0);
readScalar(runTime.controlDict().lookup("maxCo"))
);
scalar maxDeltaT = scalar maxDeltaT =
runTime.controlDict().lookupOrDefault<scalar>("maxDeltaT", GREAT); runTime.controlDict().lookupOrDefault<scalar>("maxDeltaT", GREAT);

View File

@ -46,7 +46,6 @@ PISO
nCorrectors 2; nCorrectors 2;
nNonOrthogonalCorrectors 1; nNonOrthogonalCorrectors 1;
momentumPredictor yes; momentumPredictor yes;
fluxGradp no;
} }

View File

@ -63,7 +63,6 @@ PISO
nCorrectors 2; nCorrectors 2;
nNonOrthogonalCorrectors 0; nNonOrthogonalCorrectors 0;
momentumPredictor yes; momentumPredictor yes;
fluxGradp no;
} }
relaxationFactors relaxationFactors

View File

@ -71,7 +71,6 @@ PISO
nCorrectors 2; nCorrectors 2;
nNonOrthogonalCorrectors 0; nNonOrthogonalCorrectors 0;
momentumPredictor yes; momentumPredictor yes;
fluxGradp no;
} }
relaxationFactors relaxationFactors