35#define SetResidual(Type) \
36 setResidual<Type>(mesh, solverDict, fieldName, component, canSet, residual);
63 ::equationInitialResidualCondition
70 { operatingMode::omMax,
"maximum" },
82 stateFunctionObject& state
85 runTimeCondition(
name, obr,
dict, state),
86 fieldSelection_(obr, true),
87 value_(
dict.get<scalar>(
"value")),
88 timeStart_(
dict.getOrDefault(
"timeStart", -GREAT)),
89 mode_(operatingModeNames.get(
"mode",
dict))
95 timeStart_ = obr.time().userTimeToTime(timeStart_);
100 <<
"No fields supplied: deactivating" << endl;
112 fieldSelection_.updateSelection();
114 bool satisfied =
false;
121 if ((obr_.time().timeIndex() < 3) || (obr_.time().value() < timeStart_))
128 const dictionary& solverDict =
mesh.data().solverPerformanceDict();
130 const auto& selection = fieldSelection_.selection();
135 const auto& fieldInfo = selection[fieldi];
136 const word& fieldName = fieldInfo.name();
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...
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
Find an entry (const access) with the given keyword.
wordList sortedToc() const
Return the sorted table of contents.
Helper class to store a wordRe and label used by Foam::functionObjects::fieldSelection.
label component() const noexcept
Return the component.
const wordRe & name() const noexcept
Return the selector pattern for the field name(s).
virtual bool read(const dictionary &dict)
Read the fieldSelection data from dictionary.
Minimum or maximum initial residual run time condition.
solverFieldSelection fieldSelection_
Field names.
operatingMode mode_
Operating mode.
virtual bool apply()
Apply the condition.
const scalar value_
Value to compare.
scalar timeStart_
Start checking from time - always skips first iteration.
static const Enum< operatingMode > operatingModeNames
virtual void write()
Write.
virtual void reset()
Reset.
equationInitialResidualCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
Base class for run time conditions.
bool active_
On/off switch.
const objectRegistry & obr_
Reference to the object registry.
word name_
Condition name.
runTimeCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
virtual const word & name() const
Return the condition name.
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.
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.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
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.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.