mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
solutionControl: Rationalized, simplified and registered to the database
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,18 +36,23 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::pimpleControl::read()
|
||||
bool Foam::pimpleControl::read()
|
||||
{
|
||||
solutionControl::read(false);
|
||||
bool ok = solutionControl::read();
|
||||
|
||||
const dictionary& pimpleDict = dict();
|
||||
if (ok)
|
||||
{
|
||||
const dictionary& pimpleDict = dict();
|
||||
|
||||
solveFlow_ = pimpleDict.lookupOrDefault<Switch>("solveFlow", true);
|
||||
nCorrPIMPLE_ = pimpleDict.lookupOrDefault<label>("nOuterCorrectors", 1);
|
||||
nCorrPISO_ = pimpleDict.lookupOrDefault<label>("nCorrectors", 1);
|
||||
SIMPLErho_ = pimpleDict.lookupOrDefault<Switch>("SIMPLErho", false);
|
||||
turbOnFinalIterOnly_ =
|
||||
pimpleDict.lookupOrDefault<Switch>("turbOnFinalIterOnly", true);
|
||||
solveFlow_ = pimpleDict.lookupOrDefault<Switch>("solveFlow", true);
|
||||
nCorrPIMPLE_ = pimpleDict.lookupOrDefault<label>("nOuterCorrectors", 1);
|
||||
nCorrPISO_ = pimpleDict.lookupOrDefault<label>("nCorrectors", 1);
|
||||
SIMPLErho_ = pimpleDict.lookupOrDefault<Switch>("SIMPLErho", false);
|
||||
turbOnFinalIterOnly_ =
|
||||
pimpleDict.lookupOrDefault<Switch>("turbOnFinalIterOnly", true);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -95,7 +95,7 @@ protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read controls from fvSolution dictionary
|
||||
virtual void read();
|
||||
virtual bool read();
|
||||
|
||||
//- Return true if all convergence checks are satisfied
|
||||
virtual bool criteriaSatisfied();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,9 +36,55 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::simpleControl::read()
|
||||
bool Foam::simpleControl::readResidualControl()
|
||||
{
|
||||
solutionControl::read(true);
|
||||
const dictionary& solutionDict = this->dict();
|
||||
|
||||
// Read residual information
|
||||
const dictionary residualDict
|
||||
(
|
||||
solutionDict.subOrEmptyDict("residualControl")
|
||||
);
|
||||
|
||||
DynamicList<fieldData> data(residualControl_);
|
||||
|
||||
forAllConstIter(dictionary, residualDict, iter)
|
||||
{
|
||||
const word& fName = iter().keyword();
|
||||
const label fieldi = applyToField(fName, false);
|
||||
|
||||
if (fieldi == -1)
|
||||
{
|
||||
fieldData fd;
|
||||
fd.name = fName.c_str();
|
||||
|
||||
fd.absTol = readScalar(residualDict.lookup(fName));
|
||||
fd.relTol = -1;
|
||||
fd.initialResidual = -1;
|
||||
|
||||
data.append(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldData& fd = data[fieldi];
|
||||
fd.absTol = readScalar(residualDict.lookup(fName));
|
||||
}
|
||||
}
|
||||
|
||||
residualControl_.transfer(data);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
forAll(residualControl_, i)
|
||||
{
|
||||
const fieldData& fd = residualControl_[i];
|
||||
Info<< "residualControl[" << i << "]:" << nl
|
||||
<< " name : " << fd.name << nl
|
||||
<< " absTol : " << fd.absTol << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,8 +62,8 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read controls from fvSolution dictionary
|
||||
void read();
|
||||
//- Read absolute residual controls from fvSolution dictionary
|
||||
virtual bool readResidualControl();
|
||||
|
||||
//- Return true if all convergence checks are satisfied
|
||||
bool criteriaSatisfied();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -35,18 +35,10 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::solutionControl::read(const bool absTolOnly)
|
||||
bool Foam::solutionControl::readResidualControl()
|
||||
{
|
||||
const dictionary& solutionDict = this->dict();
|
||||
|
||||
// Read solution controls
|
||||
nNonOrthCorr_ =
|
||||
solutionDict.lookupOrDefault<label>("nNonOrthogonalCorrectors", 0);
|
||||
momentumPredictor_ =
|
||||
solutionDict.lookupOrDefault("momentumPredictor", true);
|
||||
transonic_ = solutionDict.lookupOrDefault("transonic", false);
|
||||
consistent_ = solutionDict.lookupOrDefault("consistent", false);
|
||||
|
||||
// Read residual information
|
||||
const dictionary residualDict
|
||||
(
|
||||
@ -64,28 +56,19 @@ void Foam::solutionControl::read(const bool absTolOnly)
|
||||
fieldData fd;
|
||||
fd.name = fName.c_str();
|
||||
|
||||
if (absTolOnly)
|
||||
if (iter().isDict())
|
||||
{
|
||||
fd.absTol = readScalar(residualDict.lookup(fName));
|
||||
fd.relTol = -1;
|
||||
fd.initialResidual = -1;
|
||||
const dictionary& fieldDict(iter().dict());
|
||||
fd.absTol = readScalar(fieldDict.lookup("tolerance"));
|
||||
fd.relTol = readScalar(fieldDict.lookup("relTol"));
|
||||
fd.initialResidual = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iter().isDict())
|
||||
{
|
||||
const dictionary& fieldDict(iter().dict());
|
||||
fd.absTol = readScalar(fieldDict.lookup("tolerance"));
|
||||
fd.relTol = readScalar(fieldDict.lookup("relTol"));
|
||||
fd.initialResidual = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Residual data for " << iter().keyword()
|
||||
<< " must be specified as a dictionary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
FatalErrorInFunction
|
||||
<< "Residual data for " << iter().keyword()
|
||||
<< " must be specified as a dictionary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
data.append(fd);
|
||||
@ -93,25 +76,19 @@ void Foam::solutionControl::read(const bool absTolOnly)
|
||||
else
|
||||
{
|
||||
fieldData& fd = data[fieldi];
|
||||
if (absTolOnly)
|
||||
|
||||
if (iter().isDict())
|
||||
{
|
||||
fd.absTol = readScalar(residualDict.lookup(fName));
|
||||
const dictionary& fieldDict(iter().dict());
|
||||
fd.absTol = readScalar(fieldDict.lookup("tolerance"));
|
||||
fd.relTol = readScalar(fieldDict.lookup("relTol"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iter().isDict())
|
||||
{
|
||||
const dictionary& fieldDict(iter().dict());
|
||||
fd.absTol = readScalar(fieldDict.lookup("tolerance"));
|
||||
fd.relTol = readScalar(fieldDict.lookup("relTol"));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Residual data for " << iter().keyword()
|
||||
<< " must be specified as a dictionary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
FatalErrorInFunction
|
||||
<< "Residual data for " << iter().keyword()
|
||||
<< " must be specified as a dictionary"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,16 +103,36 @@ void Foam::solutionControl::read(const bool absTolOnly)
|
||||
Info<< "residualControl[" << i << "]:" << nl
|
||||
<< " name : " << fd.name << nl
|
||||
<< " absTol : " << fd.absTol << nl
|
||||
<< " relTol : " << fd.relTol << nl
|
||||
<< " iniResid : " << fd.initialResidual << endl;
|
||||
<< " relTol : " << fd.relTol << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::solutionControl::read()
|
||||
bool Foam::solutionControl::read()
|
||||
{
|
||||
read(false);
|
||||
const dictionary& solutionDict = this->dict();
|
||||
|
||||
// Read solution controls
|
||||
nNonOrthCorr_ =
|
||||
solutionDict.lookupOrDefault<label>("nNonOrthogonalCorrectors", 0);
|
||||
momentumPredictor_ =
|
||||
solutionDict.lookupOrDefault("momentumPredictor", true);
|
||||
transonic_ = solutionDict.lookupOrDefault("transonic", false);
|
||||
consistent_ = solutionDict.lookupOrDefault("consistent", false);
|
||||
|
||||
readResidualControl();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::solutionControl::writeData(Ostream&) const
|
||||
{
|
||||
NotImplemented;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -215,11 +212,16 @@ Foam::scalar Foam::solutionControl::maxResidual
|
||||
|
||||
Foam::solutionControl::solutionControl(fvMesh& mesh, const word& algorithmName)
|
||||
:
|
||||
IOobject
|
||||
regIOobject
|
||||
(
|
||||
"solutionControl",
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
IOobject
|
||||
(
|
||||
typeName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
mesh_(mesh),
|
||||
residualControl_(),
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,7 +45,7 @@ namespace Foam
|
||||
|
||||
class solutionControl
|
||||
:
|
||||
public IOobject
|
||||
public regIOobject
|
||||
{
|
||||
public:
|
||||
|
||||
@ -99,11 +99,13 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Read controls from fvSolution dictionary
|
||||
virtual void read(const bool absTolOnly);
|
||||
//- Read residual controls from fvSolution dictionary
|
||||
virtual bool readResidualControl();
|
||||
|
||||
//- Read controls from fvSolution dictionary
|
||||
virtual void read();
|
||||
virtual bool read();
|
||||
|
||||
virtual bool writeData(Ostream&) const;
|
||||
|
||||
//- Return index of field in residualControl_ if present
|
||||
virtual label applyToField
|
||||
@ -150,7 +152,6 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// Static Data Members
|
||||
|
||||
//- Run-time type information
|
||||
|
||||
Reference in New Issue
Block a user