44 "preconditioner",
"smoother" 54 if ((dictptr =
dict.findDict(
"cache")) !=
nullptr)
60 if ((dictptr =
dict.findDict(
"relaxationFactors")) !=
nullptr)
64 bool needsCompat =
true;
66 if ((dictptr = relaxDict.findDict(
"fields")) !=
nullptr)
69 fieldRelaxDict_ = *dictptr;
70 fieldRelaxCache_.clear();
73 if ((dictptr = relaxDict.findDict(
"equations")) !=
nullptr)
76 eqnRelaxDict_ = *dictptr;
77 eqnRelaxCache_.clear();
83 fieldRelaxDict_.
clear();
84 fieldRelaxCache_.clear();
86 for (
const word&
e : relaxDict.toc())
88 scalar value = relaxDict.get<scalar>(
e);
90 if (
e.starts_with(
'p'))
92 fieldRelaxDict_.
add(
e, value);
94 else if (
e.starts_with(
"rho"))
96 fieldRelaxDict_.
add(
e, value);
100 eqnRelaxDict_ = relaxDict;
101 eqnRelaxCache_.clear();
110 if (!fieldRelaxDefault_)
112 fieldRelaxDefault_.reset
114 new Function1Types::Constant<scalar>(
"default", 0)
123 if (!eqnRelaxDefault_)
125 eqnRelaxDefault_.reset
127 new Function1Types::Constant<scalar>(
"default", 0)
132 <<
"Relaxation factors:" <<
nl 133 <<
"fields: " << fieldRelaxDict_ <<
nl 134 <<
"equations: " << eqnRelaxDict_ <<
endl;
137 if ((dictptr =
dict.findDict(
"solvers")) !=
nullptr)
147 Foam::solution::solution
149 const objectRegistry& obr,
152 const dictionary* fallback
191 Foam::solution::solution
193 const objectRegistry& obr,
195 const dictionary* fallback
223 if (!dEntry.isDict())
240 if (eptr && !eptr->
isDict())
259 Info<<
"// using new solver syntax:\n" 260 << dEntry.keyword() << subdict <<
endl;
264 dict.
set(dEntry.keyword(), subdict);
289 <<
"Field relaxation factor for " <<
name 290 <<
" is " << (fieldRelaxDict_.found(
name) ?
"set" :
"unset") <<
endl;
292 return fieldRelaxDict_.found(
name) || fieldRelaxDict_.found(
"default");
299 return eqnRelaxDict_.found(
name) || eqnRelaxDict_.found(
"default");
307 if (fieldRelaxDict_.found(
name))
315 )().value(time().timeOutputValue());
317 else if (fieldRelaxDefault_)
319 return fieldRelaxDefault_().
value(time().timeOutputValue());
323 <<
"Cannot find variable relaxation factor for '" <<
name 324 <<
"' or a suitable default value." <<
nl 335 if (eqnRelaxDict_.found(
name))
343 )().value(time().timeOutputValue());
345 else if (eqnRelaxDefault_)
347 return eqnRelaxDefault_().
value(time().timeOutputValue());
351 <<
"Cannot find equation relaxation factor for '" <<
name 352 <<
"' or a suitable default value." 363 return subDict(get<word>(
"select"));
373 return solvers_.subDict(
name);
380 return solvers_.subDict(
name);
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
Return the relaxation factor for the given equation.
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.
static const Foam::List< Foam::word > subDictNames({ "preconditioner", "smoother" })
constexpr char nl
The newline '\n' character (0x0a)
fvSolution solutionDict(runTime)
const dictionary & solver(const word &name) const
Return the solver controls dictionary for the given field.
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
Return true if the relaxation factor is given for the field.
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
bool isReadOptional() const noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
bool read(const char *buf, int32_t &val)
Same as readInt32.
dictionary()
Default construct, a top-level empty dictionary.
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
const dictionary & solutionDict() const
Return the selected sub-dictionary of solvers if the "select" keyword is given, otherwise return the ...
bool cache(const word &name) const
Return true if the given field should be cached.
#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)
#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.
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
virtual ~solution()
Destructor.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
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.
void clear()
Clear the dictionary.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
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.