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
213 virtual scalar
sample()
const = 0;
223 virtual scalar
min()
const = 0;
226 virtual scalar
max()
const = 0;
229 virtual scalar
mean()
const = 0;
245 #define DISTRIBUTION_TEMPLATED_SAMPLE_TYPE(Type, nullArg) \
247 inline Type Foam::distribution::sample<Type>() const \
249 return CAT(sample, CAPITALIZE(Type))(); \
252 #undef DISTRIBUTION_TEMPLATED_SAMPLE_TYPE
260 const bool write =
true,
261 const bool writeState =
true
269 template<
class Base,
class Derived>
279 #define VIRTUAL_SAMPLE_TYPE(Type, nullArg) \
280 virtual Type CAT(sample, CAPITALIZE(Type))() const \
282 return sample<Type>(); \
285 #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 keyword definitions, which are a keyword followed by any number of values (e....
Base class for statistical distributions.
virtual tmp< scalarField > PDF(const scalarField &x) const =0
Return the distribution probability density function.
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 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 > x(const label n) const
Return coordinates to plot across the range of the distribution.
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 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.
randomGenerator rndGen_
Random number generator.
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.
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(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), 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.
word name(const bool)
Return a word representation of a bool.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
randomGenerator rndGen(653213)