38 namespace functionObjects
49 bool 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_);
defineTypeNameAndDebug(ObukhovLength, 0)
word resultName_
Name of result field.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
word fieldName_
Name of field to process.
virtual bool read(const dictionary &dict)
Read from dictionary.
virtual bool read(const dictionary &dict)
Read the fieldExpression data.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
Macros for easy insertion into run-time selection tables.
bool read(const char *buf, int32_t &val)
Same as readInt32.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Volume (cell) region selection class.
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
virtual bool calc()
Calculate the randomised field and return true if successful.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc...
const labelList & cellIDs() const
Return the local list of cell IDs.
bool update()
Update the cached values as required.
virtual bool read(const dictionary &dict)
Read the randomise data.
word scopedName(const word &name) const
Return a scoped (prefixed) name.
randomise(const randomise &)=delete
No copy construct.