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