56 if ((dictptr =
dict.findDict(
"cache")) !=
nullptr)
62 if ((dictptr =
dict.findDict(
"relaxationFactors")) !=
nullptr)
66 bool needsCompat =
true;
68 if ((dictptr = relaxDict.findDict(
"fields")) !=
nullptr)
71 fieldRelaxDict_ = *dictptr;
72 fieldRelaxCache_.clear();
75 if ((dictptr = relaxDict.findDict(
"equations")) !=
nullptr)
78 eqnRelaxDict_ = *dictptr;
79 eqnRelaxCache_.clear();
85 fieldRelaxDict_.
clear();
86 fieldRelaxCache_.clear();
88 for (
const word&
e : relaxDict.toc())
90 scalar value = relaxDict.get<scalar>(
e);
92 if (
e.starts_with(
'p'))
94 fieldRelaxDict_.
add(
e, value);
96 else if (
e.starts_with(
"rho"))
98 fieldRelaxDict_.
add(
e, value);
102 eqnRelaxDict_ = relaxDict;
103 eqnRelaxCache_.clear();
113 if (!fieldRelaxDefault_)
115 fieldRelaxDefault_.reset
117 new Function1Types::Constant<scalar>(
"default", 0, &
db())
127 if (!eqnRelaxDefault_)
129 eqnRelaxDefault_.reset
131 new Function1Types::Constant<scalar>(
"default", 0, &
db())
136 <<
"Relaxation factors:" <<
nl 137 <<
"fields: " << fieldRelaxDict_ <<
nl 138 <<
"equations: " << eqnRelaxDict_ <<
endl;
141 if ((dictptr =
dict.findDict(
"solvers")) !=
nullptr)
164 Foam::solution::solution
205 || !dictionary::empty()
208 read(selectedDict());
213 Foam::solution::solution
215 const objectRegistry& obr,
217 const dictionary* fallback
245 if (dEntry.isStream())
265 auto& is = *streamPtr;
282 Info<<
"// using new solver syntax:\n" 283 << dEntry.keyword() << subdict <<
endl;
287 dict.
set(dEntry.keyword(), subdict);
302 return cache_.found(
name);
323 <<
"Field relaxation factor for " <<
name 324 <<
" is " << (fieldRelaxDict_.found(
name) ?
"set" :
"unset") <<
endl;
326 return fieldRelaxDict_.found(
name) || fieldRelaxDict_.found(
"default");
333 return eqnRelaxDict_.found(
name) || eqnRelaxDict_.found(
"default");
341 if (fieldRelaxDict_.found(
name))
350 )().value(time().timeOutputValue());
353 <<
"Field relaxation factor for " <<
name 355 <<
" (from Function1)" <<
endl;
359 else if (fieldRelaxDict_.found(
"default") && fieldRelaxDefault_)
361 factor = fieldRelaxDefault_->value(time().timeOutputValue());
364 <<
"Field relaxation factor for " <<
name 366 <<
" (from default " << eqnRelaxDefault_->type() <<
')' <<
endl;
383 if (eqnRelaxDict_.found(
name))
392 )().value(time().timeOutputValue());
395 <<
"Equation relaxation factor for " <<
name 397 <<
" (from Function1)" <<
endl;
401 else if (eqnRelaxDict_.found(
"default") && eqnRelaxDefault_)
403 factor = eqnRelaxDefault_->value(time().timeOutputValue());
406 <<
"Equation relaxation factor for " <<
name 408 <<
" (from default " << eqnRelaxDefault_->type() <<
')' <<
endl;
426 if (!relaxField(
name, factor))
429 <<
"Cannot find field relaxation factor for '" <<
name 430 <<
"' or a suitable default value." <<
nl 443 if (!relaxEquation(
name, factor))
446 <<
"Cannot find equation relaxation factor for '" <<
name 447 <<
"' or a suitable default value." 457 return selectedDict();
464 return selectedDict().subDict(
name);
477 return solvers_.subDict(
name);
484 return solvers_.subDict(
name);
492 read(selectedDict());
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
scalar equationRelaxationFactor(const word &name) const
Get the relaxation factor for the given equation. Fatal if not found.
A class for handling file names.
readOption readOpt() const noexcept
Get the read option.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool read()
Read object.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
defineDebugSwitchWithName(pointMVCWeight, "pointMVCWeight", 0)
bool read()
Read the solution dictionary.
ITstream * findStream(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry stream if present (and it is a stream) otherwise return nullptr.
static const Foam::List< Foam::word > subDictNames({ "preconditioner", "smoother" })
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
constexpr char nl
The newline '\n' character (0x0a)
const dictionary & solver(const word &name) const
The solver controls dictionary for the given field. Same as solverDict(...)
const word dictName("faMeshDefinition")
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool headerOk()
Read and check header info. Does not check the headerClassName.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
bool relaxField(const word &name) const
True if the relaxation factor is given for the field.
const dictionary & solverDict(const word &name) const
The solver controls dictionary for the given field. Same as solversDict().subDict(...)
bool isReadOptional() const noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
bool relaxEquation(const word &name) const
True if the relaxation factor is given for the equation.
bool read(const char *buf, int32_t &val)
Same as readInt32.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
dictionary()
Default construct, a top-level empty dictionary.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
const dictionary & solutionDict() const
The entire dictionary or the optional "select" sub-dictionary.
bool cache(const word &name) const
True if the given field should be cached.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
#define DebugInfo
Report an information message using Foam::Info.
static autoPtr< Function1< Type > > NewIfPresent(const word &entryName, const dictionary &dict, const word &redirectType, const objectRegistry *obrPtr=nullptr)
An optional selector, with fallback redirection.
virtual void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
const dictionary & solversDict() const
The solver controls dictionary (all fields)
registerDebugSwitchWithName(solution, solution, "solution")
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
scalar fieldRelaxationFactor(const word &name) const
Get the relaxation factor for the given field. Fatal if not found.
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
virtual ~solution()
Destructor. Non-default in header (incomplete types)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Selector class for relaxation factors, solver type and solution.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
Registry of regIOobjects.
void clear()
Clear the dictionary.
Defines the attributes of an object for which implicit objectRegistry management is supported...
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
bool eof() const noexcept
True if end of input seen.
An input stream of tokens.
A keyword and a list of tokens is an 'entry'.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
readOption
Enumeration defining read preferences.