35#define SetResidual(Type) \
36 setResidual<Type>(mesh, solverDict, fieldName, component, canSet, residual);
42namespace functionObjects
44namespace runTimeControls
63 ::equationInitialResidualCondition
69 { operatingMode::omMin,
"minimum" },
70 { operatingMode::omMax,
"maximum" },
76Foam::functionObjects::runTimeControls::
77equationInitialResidualCondition::equationInitialResidualCondition
86 fieldSelection_(obr, true),
87 value_(
dict.get<scalar>(
"value")),
88 timeStart_(
dict.getOrDefault(
"timeStart", -GREAT)),
89 mode_(operatingModeNames.get(
"mode",
dict))
100 <<
"No fields supplied: deactivating" <<
endl;
112 fieldSelection_.updateSelection();
114 bool satisfied =
false;
121 if ((obr_.time().timeIndex() < 3) || (obr_.time().value() < timeStart_))
127 const fvMesh&
mesh = refCast<const fvMesh>(obr_);
130 const auto& selection = fieldSelection_.selection();
135 const auto&
fieldInfo = selection[fieldi];
138 if (solverDict.
found(fieldName))
141 scalar residual = VGREAT;
149 result[fieldi] = residual;
155 if (residual < value_)
163 if (residual > value_)
172 <<
"Unhandled enumeration "
173 << operatingModeNames[mode_]
186 <<
"Initial residual data not found for field "
187 << selection[i].name()
188 <<
". Solver dictionary contains " << solverDict.
sortedToc()
200 <<
"Initial residual data not found for any fields: "
201 <<
"deactivating" <<
endl;
206 if (satisfied && valid)
209 <<
": satisfied using threshold value: " << value_ <<
nl;
213 if (result[resulti] > 0)
215 Log <<
" field: " << selection[resulti].name()
216 <<
", residual: " << result[resulti] <<
nl;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
wordList sortedToc() const
Return the sorted table of contents.
Watches for presence of the named trigger file in the case directory and signals a simulation stop (o...
Helper class to store a wordRe and label used by Foam::functionObjects::fieldSelection.
const wordRe & name() const
virtual bool read(const dictionary &dict)
Read the fieldSelection data from dictionary.
Minimum or maximum initial residual run time condition.
solverFieldSelection fieldSelection_
Field names.
virtual bool apply()
Apply the condition.
scalar timeStart_
Start checking from time - always skips first iteration.
static const Enum< operatingMode > operatingModeNames
virtual void write()
Write.
virtual void reset()
Reset.
Base class for run time conditions.
bool active_
On/off switch.
Base class for function objects, adding functionality to read/write state information (data required ...
Mesh data needed to do the Finite Volume discretisation.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define SetResidual(Type)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.