34 namespace distributions
46 const dictionary&
dict
56 cumSHat[i + 1] = cumSHat[i] + sHat[i];
76 (cumulativeStrengths_[i + 1] - cumulativeStrengths_[i])
77 *distributions_[i].phi(0,
x);
98 (cumulativeStrengths_[i + 1] - cumulativeStrengths_[i])
99 *distributions_[i].Phi(0,
x);
129 cumulativeStrengths_(readCumulativeStrengths(
dict))
133 dict.lookupBackwardsCompatible<scalar>({
"min",
"minValue"},
units)
137 dict.lookupBackwardsCompatible<scalar>({
"max",
"maxValue"},
units)
150 mu.size() != cumulativeStrengths_.
size() - 1
151 ||
sigma.size() != cumulativeStrengths_.
size() - 1
155 <<
type() <<
": Differing numbers of means, standard deviations "
156 <<
"and strengths were given:" <<
nl <<
" mu = " <<
mu
157 <<
", sigma = " <<
sigma <<
", strength = "
161 distributions_.resize(
mu.size());
181 validateBounds(
dict);
182 if (q() != 0) validatePositive(
dict);
194 cumulativeStrengths_(d.cumulativeStrengths_),
195 distributions_(d.distributions_.size())
197 forAll(d.distributions_, i)
208 d.distributions_[i].min_,
209 d.distributions_[i].max_,
210 d.distributions_[i].mu_,
211 d.distributions_[i].sigma_
230 const scalar
S = rndGen_.sample01<scalar>();
232 const label n = cumulativeStrengths_.size() - 1;
234 for (; i <
n && cumulativeStrengths_[i + 1] <
S; ++ i);
237 (
S - cumulativeStrengths_[i])
238 /(cumulativeStrengths_[i + 1] - cumulativeStrengths_[i]);
240 return distributions_[i].sampleForZeroQ(
s);
251 return distributions_[0].min();
257 return distributions_[0].max();
275 mu[i] = distributions_[i].mu();
276 sigma[i] = distributions_[i].sigma();
287 return distributions_[0].x(
n);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keyword definitions, which are a keyword followed by any number of values (e....
Base class for statistical distributions.
Multiple superimposed normal distributions.
virtual scalar min() const
Return the minimum value.
virtual scalar sample() const
Sample the distribution.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
virtual ~multiNormal()
Destructor.
virtual void write(Ostream &os, const unitConversion &units) const
Write stream.
multiNormal(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
virtual scalar max() const
Return the maximum value.
Normal distribution, scaled so that it spans between a specified minimum and maximum value,...
virtual tmp< scalarField > Phi(const label q, const scalarField &x) const
Return values of the un-normalised CDF for the given size exponent.
scalar sample() const
Sample the distribution.
A class for managing temporary objects.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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))
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
const dimensionedScalar mu
Atomic mass unit.
defineTypeNameAndDebug(exponential, 0)
addToRunTimeSelectionTable(distribution, exponential, dictionary)
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
scalar integerPow(const scalar x, const label e)
Compute the power of the number x to the integer e.
List< scalar > scalarList
A List of scalars.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
randomGenerator rndGen(653213)