37 namespace functionObjects
52 void Foam::functionObjects::LagrangianDistribution::readCoeffs
54 const dictionary&
dict
58 const bool haveFields =
dict.found(
"fields");
59 const bool haveField =
dict.found(
"field");
60 if (haveFields == haveField)
63 <<
"keywords fields and field both "
64 << (haveFields ?
"" :
"un") <<
"defined in "
65 <<
"dictionary " <<
dict.name()
70 dict.lookup(
"fields") >> fields_;
79 const bool haveWeightFields =
dict.found(
"weightFields");
80 const bool haveWeightField =
dict.found(
"weightField");
81 if (haveWeightFields && haveWeightField)
84 <<
"keywords weightFields and weightField both "
85 <<
"defined in dictionary " <<
dict.name()
88 else if (haveWeightFields)
90 dict.lookup(
"weightFields") >> weightFields_;
92 else if (haveWeightField)
95 dict.lookup(
"weightField") >> weightFields_.
first();
100 weightFields_.
clear();
104 dict.lookup(
"nBins") >> nBins_;
111 template<
template<
class>
class GeoField>
112 bool Foam::functionObjects::LagrangianDistribution::multiplyWeight
114 const word& weightFieldName,
118 if (!
mesh().foundObject<GeoField<scalar>>(weightFieldName))
return false;
120 const GeoField<scalar>& w =
129 void Foam::functionObjects::LagrangianDistribution::writeDistribution
131 const word& fieldName,
132 const word& componentName,
140 const fileName outputPath =
153 const word fieldComponentName =
155 + (componentName.empty() ?
"" :
"_")
162 coordSet(
true, fieldComponentName,
x),
169 void Foam::functionObjects::LagrangianDistribution::writeDistribution
172 const word& fieldName,
173 const word& componentName,
196 for (
label nodei = 0; nodei <= nBins_; ++ nodei)
198 const scalar
f = scalar(nodei)/nBins_;
206 const scalar
x = field[i];
210 const label bini =
min(
max(floor(
f*nBins_), 0), nBins_ - 1);
211 const scalar g =
f*nBins_ - scalar(bini);
212 PDF[bini] += weight[i]*(1 - g);
213 PDF[bini + 1] += weight[i]*g;
238 template<
template<
class>
class GeoField,
class Type>
239 bool Foam::functionObjects::LagrangianDistribution::writeDistribution
242 const word& fieldName
245 if (!
mesh().foundObject<GeoField<Type>>(fieldName))
return false;
247 const typename GeoField<Type>::FieldType& field =
250 for (
direction d = 0; d < pTraits<Type>::nComponents; ++ d)
256 pTraits<Type>::componentNames[d],
309 result.
append(weightFields_);
327 forAll(weightFields_, weightFieldi)
329 const word& weightFieldName = weightFields_[weightFieldi];
333 !multiplyWeight<LagrangianField>(weightFieldName, weight)
334 && !multiplyWeight<LagrangianDynamicField>(weightFieldName, weight)
335 && !multiplyWeight<LagrangianInternalField>(weightFieldName, weight)
339 <<
"Weight field " << weightFieldName <<
" was not found"
347 const word& fieldName = fields_[fieldi];
349 #define WRITE_FIELD_VALUE(Type, GeoField) \
350 && !writeDistribution<GeoField, Type>(weight, fieldName)
360 cannotFindObject(fields_[fieldi]);
363 #undef WRITE_COLUMN_VALUE
#define WRITE_FIELD_VALUE(Type, GeoField)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
const word & name() const
Return name.
void append(const T &)
Append an element at the end of the list.
void resize(const label)
Alias for setSize(const label)
void clear()
Clear the list, i.e. set size to zero.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
T & first()
Return the first element of the list.
static bool master(const label communicator=0)
Am I the master process.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
static tmp< scalarField > integrate(const scalarField &x, const scalarField &y)
Integrate the values y with respect to the coordinates x.
Abstract base-class for Time/database functionObjects.
Function to generate a plot of the distribution of the values in a Lagrangian field.
virtual wordList fields() const
Return the list of fields required.
LagrangianDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual ~LagrangianDistribution()
Destructor.
virtual bool execute()
Execute. Does nothing.
virtual bool write()
Write the sum.
virtual bool read(const dictionary &)
Read parameters.
Base class for function objects relating to a Lagrangian mesh.
virtual bool read(const dictionary &)
Read optional controls.
static const word outputPrefix
Directory prefix.
const polyMesh & mesh() const
Return reference to polyMesh.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
static word defaultRegion
Return the default region name.
static autoPtr< setWriter > New(const word &writeType, const IOstream::streamFormat writeFormat=IOstream::ASCII, const IOstream::compressionType writeCompression=IOstream::UNCOMPRESSED)
Select given write options.
A class for handling words, derived from string.
static const word null
An empty word.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
Type gMin(const FieldField< Field, Type > &f)
Type gMax(const FieldField< Field, Type > &f)