38namespace functionObjects
49bool Foam::functionObjects::randomise::calcTemplate()
51 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
53 const auto* fieldPtr = cfindObject<VolFieldType>(
fieldName_);
57 const auto&
field = *fieldPtr;
62 auto& rfield = trfield.ref();
66 auto applyPerturbation = [&](Type& cellval)
69 rng.randomise01(rndPert);
70 rndPert = 2.0*rndPert - pTraits<Type>::one;
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.
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
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....
word resultName_
Name of result field.
word fieldName_
Name of field to process.
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 randomise data.
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.
bool update()
Update the cached values as required.
const labelList & cellIDs() const
Return the local list of cell IDs.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.