mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Added a 'default' entry to the 'relaxationFactors'. When it is set to 0 it is
equivalent to the 'none' entry in fvSchemes and relaxation factors must be provided for all fields which might require one. If it is set to a value between 0 and 1 this value is used as the default relaxation factor.
This commit is contained in:
@ -27,7 +27,7 @@ License
|
|||||||
#include "solution.H"
|
#include "solution.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
|
||||||
// these are for old syntax compatibility:
|
// These are for old syntax compatibility:
|
||||||
#include "BICCG.H"
|
#include "BICCG.H"
|
||||||
#include "ICCG.H"
|
#include "ICCG.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
@ -36,7 +36,7 @@ License
|
|||||||
|
|
||||||
int Foam::solution::debug(::Foam::debug::debugSwitch("solution", 0));
|
int Foam::solution::debug(::Foam::debug::debugSwitch("solution", 0));
|
||||||
|
|
||||||
// list of sub-dictionaries to rewrite
|
// List of sub-dictionaries to rewrite
|
||||||
//! @cond localScope
|
//! @cond localScope
|
||||||
static const Foam::List<Foam::word> subDictNames
|
static const Foam::List<Foam::word> subDictNames
|
||||||
(
|
(
|
||||||
@ -59,7 +59,12 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
|
|||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
relaxationFactors_(ITstream("relaxationFactors", tokenList())()),
|
relaxationFactors_
|
||||||
|
(
|
||||||
|
ITstream("relaxationFactors",
|
||||||
|
tokenList())()
|
||||||
|
),
|
||||||
|
defaultRelaxationFactor_(0),
|
||||||
solvers_(ITstream("solvers", tokenList())())
|
solvers_(ITstream("solvers", tokenList())())
|
||||||
{
|
{
|
||||||
read();
|
read();
|
||||||
@ -156,6 +161,15 @@ bool Foam::solution::read()
|
|||||||
{
|
{
|
||||||
relaxationFactors_ = dict.subDict("relaxationFactors");
|
relaxationFactors_ = dict.subDict("relaxationFactors");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relaxationFactors_.add("default", "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relaxationFactors_.found("default"))
|
||||||
|
{
|
||||||
|
relaxationFactors_.lookup("default") >> defaultRelaxationFactor_;
|
||||||
|
}
|
||||||
|
|
||||||
if (dict.found("solvers"))
|
if (dict.found("solvers"))
|
||||||
{
|
{
|
||||||
@ -192,7 +206,9 @@ bool Foam::solution::relax(const word& name) const
|
|||||||
Info<< "Find relax for " << name << endl;
|
Info<< "Find relax for " << name << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return relaxationFactors_.found(name);
|
return
|
||||||
|
relaxationFactors_.found(name)
|
||||||
|
|| relaxationFactors_.found("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,7 +219,26 @@ Foam::scalar Foam::solution::relaxationFactor(const word& name) const
|
|||||||
Info<< "Lookup relaxationFactor for " << name << endl;
|
Info<< "Lookup relaxationFactor for " << name << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (relaxationFactors_.found(name))
|
||||||
|
{
|
||||||
return readScalar(relaxationFactors_.lookup(name));
|
return readScalar(relaxationFactors_.lookup(name));
|
||||||
|
}
|
||||||
|
else if (defaultRelaxationFactor_ > SMALL)
|
||||||
|
{
|
||||||
|
return defaultRelaxationFactor_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"Foam::solution::relaxationFactor(const word& name)",
|
||||||
|
relaxationFactors_
|
||||||
|
) << "Cannot find relaxationFactor for '" << name
|
||||||
|
<< "' or a suitable default value."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,9 @@ class solution
|
|||||||
//- Dictionary of relaxation factors for all the fields
|
//- Dictionary of relaxation factors for all the fields
|
||||||
dictionary relaxationFactors_;
|
dictionary relaxationFactors_;
|
||||||
|
|
||||||
|
//- Optional default relaxation factor for all the fields
|
||||||
|
scalar defaultRelaxationFactor_;
|
||||||
|
|
||||||
//- Dictionary of solver parameters for all the fields
|
//- Dictionary of solver parameters for all the fields
|
||||||
dictionary solvers_;
|
dictionary solvers_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user