55 if ((dictptr =
dict.findDict(
"cache")) !=
nullptr)
61 if ((dictptr =
dict.findDict(
"relaxationFactors")) !=
nullptr)
65 bool needsCompat =
true;
67 if ((dictptr = relaxDict.findDict(
"fields")) !=
nullptr)
70 fieldRelaxDict_ = *dictptr;
71 fieldRelaxCache_.clear();
74 if ((dictptr = relaxDict.findDict(
"equations")) !=
nullptr)
77 eqnRelaxDict_ = *dictptr;
78 eqnRelaxCache_.clear();
84 fieldRelaxDict_.
clear();
85 fieldRelaxCache_.clear();
87 for (
const word&
e : relaxDict.toc())
89 scalar value = relaxDict.get<scalar>(
e);
91 if (
e.starts_with(
'p'))
93 fieldRelaxDict_.
add(
e, value);
95 else if (
e.starts_with(
"rho"))
97 fieldRelaxDict_.
add(
e, value);
101 eqnRelaxDict_ = relaxDict;
102 eqnRelaxCache_.clear();
111 if (!fieldRelaxDefault_)
113 fieldRelaxDefault_.reset
115 new Function1Types::Constant<scalar>(
"default", 0)
124 if (!eqnRelaxDefault_)
126 eqnRelaxDefault_.reset
128 new Function1Types::Constant<scalar>(
"default", 0)
133 <<
"Relaxation factors:" <<
nl 134 <<
"fields: " << fieldRelaxDict_ <<
nl 135 <<
"equations: " << eqnRelaxDict_ <<
endl;
138 if ((dictptr =
dict.findDict(
"solvers")) !=
nullptr)
161 Foam::solution::solution
200 read(selectedDict());
205 Foam::solution::solution
207 const objectRegistry& obr,
209 const dictionary* fallback
237 if (!dEntry.isDict())
254 if (eptr && !eptr->
isDict())
273 Info<<
"// using new solver syntax:\n" 274 << dEntry.keyword() << subdict <<
endl;
278 dict.
set(dEntry.keyword(), subdict);
293 return cache_.found(
name);
314 <<
"Field relaxation factor for " <<
name 315 <<
" is " << (fieldRelaxDict_.found(
name) ?
"set" :
"unset") <<
endl;
317 return fieldRelaxDict_.found(
name) || fieldRelaxDict_.found(
"default");
324 return eqnRelaxDict_.found(
name) || eqnRelaxDict_.found(
"default");
332 if (fieldRelaxDict_.found(
name))
340 )().value(time().timeOutputValue());
344 else if (fieldRelaxDict_.found(
"default") && fieldRelaxDefault_)
346 factor = fieldRelaxDefault_->
value(time().timeOutputValue());
359 if (eqnRelaxDict_.found(
name))
361 factor = Function1<scalar>::New
367 )().value(time().timeOutputValue());
371 else if (eqnRelaxDict_.found(
"default") && eqnRelaxDefault_)
373 factor = eqnRelaxDefault_->value(time().timeOutputValue());
387 if (!relaxField(
name, factor))
390 <<
"Cannot find field relaxation factor for '" <<
name 391 <<
"' or a suitable default value." <<
nl 404 if (!relaxEquation(
name, factor))
407 <<
"Cannot find equation relaxation factor for '" <<
name 408 <<
"' or a suitable default value." 418 return selectedDict();
425 return selectedDict().subDict(
name);
438 return solvers_.subDict(
name);
445 return solvers_.subDict(
name);
453 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.
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.
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 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.
#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)
#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
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)
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.
Registry of regIOobjects.
void clear()
Clear the dictionary.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
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.