32 bool Foam::functionObjects::randomise::calcRandomised()
34 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
38 const VolFieldType& field = lookupObject<VolFieldType>(
fieldName_);
42 tmp<VolFieldType> rfieldt(
new VolFieldType(field));
43 VolFieldType& rfield = rfieldt.ref();
49 Type rndPert = rand.sample01<Type>();
50 rndPert = 2.0*rndPert - pTraits<Type>::one;
51 rndPert /=
mag(rndPert);
52 rfield[celli] += magPerturbation_*rndPert;
55 return store(resultName_, rfieldt);
#define forAll(list, i)
Loop across all elements in list.
word fieldName_
Name of field to process.
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the given field in the objectRegistry under the given name.
dimensioned< scalar > mag(const dimensioned< Type > &)