35 #define SetResidual(Type) \ 36 setResidual<Type>(mesh, solverDict, fieldName, component, canSet, residual); 42 namespace functionObjects
44 namespace runTimeControls
50 equationInitialResidualCondition,
63 ::equationInitialResidualCondition
69 { operatingMode::omMin,
"minimum" },
70 { operatingMode::omMax,
"maximum" },
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_);
128 const dictionary& solverDict =
mesh.data().solverPerformanceDict();
130 const auto& selection = fieldSelection_.selection();
131 List<scalar> result(selection.size(), -VGREAT);
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;
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
void size(const label n)
Older name for setAddressableSize.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
equationInitialResidualCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void write()
Write.
solverFieldSelection fieldSelection_
Field names.
#define SetResidual(Type)
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
A class for handling words, derived from Foam::string.
const Time & time() const noexcept
Return time registry.
Base class for run time conditions.
errorManip< error > abort(error &err)
defineTypeNameAndDebug(averageCondition, 0)
static const Enum< operatingMode > operatingModeNames
virtual bool read(const dictionary &dict)
Read the fieldSelection data from dictionary.
virtual bool apply()
Apply the condition.
virtual void reset()
Reset.
addToRunTimeSelectionTable(runTimeCondition, averageCondition, dictionary)
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
bool active_
On/off switch.
Base class for function objects, adding functionality to read/write state information (data required ...
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Registry of regIOobjects.
scalar timeStart_
Start checking from time - always skips first iteration.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)