56 if ((dictptr =
dict.findDict(
"cache")) !=
nullptr)
59 caching_ = cache_.getOrDefault(
"active",
true);
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)
149const Foam::dictionary& Foam::solution::selectedDict()
const
155 return subDict(select);
164Foam::solution::solution
208 read(selectedDict());
213Foam::solution::solution
215 const objectRegistry& obr,
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))
343 factor = Function1<scalar>::New
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))
385 factor = Function1<scalar>::New
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());
propsDict readIfPresent("fields", acceptFields)
bool empty() const noexcept
True if the list is empty.
static autoPtr< Function1< Type > > NewIfPresent(const word &entryName, const dictionary &dict, const word &redirectType, const objectRegistry *obrPtr=nullptr)
An optional selector, with fallback redirection.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
bool isReadOptional() const noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
readOption readOpt() const noexcept
Get the read option.
readOption
Enumeration defining read preferences.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
bool eof() const noexcept
True if end of input seen.
An input stream of tokens.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
dictionary()
Default construct, a top-level empty 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.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
word dictName() const
The local dictionary name (final part of scoped name).
A keyword and a list of tokens is an 'entry'.
A class for handling file names.
@ REGEX
Regular expression.
Registry of regIOobjects.
bool headerOk()
Read and check header info. Does not check the headerClassName.
virtual void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED).
virtual bool read()
Read object.
Selector class for relaxation factors, solver type and solution.
bool cache(const word &name) const
True if the given field should be cached.
virtual ~solution()
Destructor. Non-default in header (incomplete types).
const dictionary & solver(const word &name) const
The solver controls dictionary for the given field. Same as solverDict(...).
const dictionary & solversDict() const
The solver controls dictionary (all fields).
bool relaxField(const word &name) const
True if the relaxation factor is given for the field.
scalar fieldRelaxationFactor(const word &name) const
Get the relaxation factor for the given field. Fatal if not found.
const dictionary & solverDict(const word &name) const
The solver controls dictionary for the given field. Same as solversDict().subDict(....
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
scalar equationRelaxationFactor(const word &name) const
Get the relaxation factor for the given equation. Fatal if not found.
bool relaxEquation(const word &name) const
True if the relaxation factor is given for the equation.
const dictionary & solutionDict() const
The entire dictionary or the optional "select" sub-dictionary.
bool read()
Read the solution dictionary.
A class for handling words, derived from Foam::string.
#define registerDebugSwitchWithName(Type, Tag, Name)
Define the debug information, lookup as Name.
#define defineDebugSwitchWithName(Type, Name, Value)
Define the debug information, lookup as Name.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const word dictName("faMeshDefinition")
#define DebugInfo
Report an information message using Foam::Info.
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...
bool read(const char *buf, int32_t &val)
Same as readInt32.
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
static const Foam::List< Foam::word > subDictNames({ "preconditioner", "smoother" })