49bool Foam::functionObjects::randomise::calcTemplate()
57 const auto&
field = *fieldPtr;
62 auto& rfield = trfield.ref();
66 auto applyPerturbation = [&](Type& cellval)
69 rng.randomise01(rndPert);
71 rndPert /=
mag(rndPert);
73 cellval += magPerturbation_*rndPert;
78 for (Type& cellval : rfield)
80 applyPerturbation(cellval);
85 for (
const label celli :
cellIDs())
87 applyPerturbation(rfield[celli]);
108 calcTemplate<scalar>()
109 || calcTemplate<vector>()
110 || calcTemplate<sphericalTensor>()
111 || calcTemplate<symmTensor>()
112 || calcTemplate<tensor>()
140 dict.readEntry(
"magPerturbation", magPerturbation_);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base-class for Time/database function objects.
word scopedName(const word &name) const
Return a scoped (prefixed) name.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
word resultName_
Name of result field.
word fieldName_
Name of field to process.
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
const fvMesh & mesh_
Reference to the fvMesh.
Adds a random component to an input field, with a specified perturbation magnitude.
virtual bool calc()
Calculate the randomised field and return true if successful.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
randomise(const randomise &)=delete
No copy construct.
const ObjectType * cfindObject(const word &fieldName) const
Return const pointer to the object (eg, a field) in the (sub) objectRegistry.
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
Volume (cell) region selection class.
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
volRegion(const fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
virtual bool read(const dictionary &dict)
Read from dictionary.
bool update()
Update the cached values as required.
const labelList & cellIDs() const
Return the local list of cell IDs.
A traits class, which is primarily used for primitives and vector-space.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
bool read(const char *buf, int32_t &val)
Same as readInt32.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.