59 #ifndef distribution_H
60 #define distribution_H
114 #define VIRTUAL_SAMPLE_TYPE(Type, nullArg) \
115 virtual Type CAT(sample, CAPITALIZE(Type))() const = 0;
117 #undef VIRTUAL_SAMPLE_TYPE
184 const bool report =
true
194 const bool global =
false,
195 const bool report =
true
220 virtual scalar
sample()
const = 0;
230 virtual scalar
min()
const = 0;
233 virtual scalar
max()
const = 0;
236 virtual scalar
mean()
const = 0;
252 const bool consistent =
false
269 #define DISTRIBUTION_TEMPLATED_SAMPLE_TYPE(Type, nullArg) \
271 inline Type Foam::distribution::sample<Type>() const \
273 return CAT(sample, CAPITALIZE(Type))(); \
276 #undef DISTRIBUTION_TEMPLATED_SAMPLE_TYPE
282 const word&entryName,
285 const bool write =
true,
286 const bool writeState =
true
294 template<
class Base,
class Derived>
304 #define VIRTUAL_SAMPLE_TYPE(Type, nullArg) \
305 virtual Type CAT(sample, CAPITALIZE(Type))() const \
307 return sample<Type>(); \
310 #undef VIRTUAL_SAMPLE_TYPE
Type sample() const
Sample the distribution into components of a primitive type.
FOR_ALL_FIELD_TYPES(VIRTUAL_SAMPLE_TYPE)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Base class for statistical distributions.
declareRunTimeSelectionTable(autoPtr, distribution, dictionary,(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen),(units, dict, sampleQ, std::move(rndGen)))
Declare runtime constructor selection table.
virtual scalar max() const =0
Return the maximum value.
autoPtr< distribution > clone() const
Construct and return a clone.
virtual tmp< scalarField > integralPDFxPow(const scalarField &x, const label e, const bool consistent=false) const =0
Return the integral of the PDF multiplied by an integer power of x.
label sampleQ() const
Access the sample size exponent.
virtual void writeState(Ostream &os) const
Write the state to a stream.
virtual void validatePositive(const dictionary &dict) const
Validate that the lower bound is positive.
tmp< scalarField > clipPDF(const scalarField &x, const tmp< scalarField > &pdf) const
Clip the PDF values to zero outside the bounds.
virtual scalar sample() const =0
Sample the distribution.
const label Q_
Distribution size exponent.
label q() const
Return the effective distribution size exponent.
virtual ~distribution()
Destructor.
virtual tmp< scalarField > plotPDF(const scalarField &x) const =0
Return values to plot the probability density function.
const label sampleQ_
Sample size exponent.
distribution(const word &name, const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from dictionary.
virtual tmp< scalarField > CDF(const scalarField &x) const
Return the cumulative density function at the given coordinates.
virtual void validateBounds(const dictionary &dict) const
Validate that the bounds are monotonic.
FOR_ALL_FIELD_TYPES(VIRTUAL_SAMPLE_TYPE)
TypeName("distribution")
Runtime type information.
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
virtual scalar mean() const =0
Return the mean value.
virtual scalar min() const =0
Return the minimum value.
void start(const bool repeat) const
Start a sequence of samples. Either a new sequence, or a.
restartableRandomGenerator rndGen_
Random number generator.
virtual tmp< scalarField > plotX(const label n) const
Return coordinates to plot across the range of the distribution.
static autoPtr< distribution > New(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen, const bool report=true)
Select from dictionary and a random generator.
Random number generator with the additional ability to go back to an earlier stored state....
A class for managing temporary objects.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
A class for handling words, derived from string.
#define VIRTUAL_SAMPLE_TYPE(Type, nullArg)
Sample the distribution into components of a primitive type.
#define DISTRIBUTION_TEMPLATED_SAMPLE_TYPE(Type, nullArg)
Include the header files for all the primitive types that Fields are instantiated for.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
List< Type > repeat(const UList< Type > &a, const UList< Type > &b)
randomGenerator rndGen(653213)