Go to the documentation of this file.
35 namespace distributionModels
49 void Foam::distributionModels::binned::initialise()
51 const label nSample(xy_.size());
54 for (label bini = 1; bini < nSample; ++bini)
56 xy_[bini][1] += xy_[bini - 1][1];
60 scalar sumProb = xy_.last()[1];
63 xy_[bini][1] /= sumProb;
77 meanValue_ = xy_[bini][1];
90 xy_(distributionModelDict_.lookup(
"distribution")),
96 <<
"Maximum value is smaller than the minimum value:"
109 const scalar binWidth,
125 const label bin0 = floor(
minValue/binWidth);
126 const label bin1 = ceil(
maxValue/binWidth);
127 const label nBin = bin1 - bin0;
132 <<
"Data cannot be binned - zero bins generated" <<
nl
133 <<
" Bin width : " << binWidth <<
nl
134 <<
" Sample data : " << sampleData
144 xy_[bini][0] = (bin0 + bini)*binWidth;
152 label bini = floor(sampleData[i]/binWidth) - bin0;
153 label binii =
min(bini + 1, nBin - 1);
155 scalar d1 =
mag(sampleData[i] - xy_[bini][0]);
156 scalar d2 =
mag(xy_[binii][0] - sampleData[i]);
176 meanValue_(
p.meanValue_)
190 scalar
y = rndGen_.sample01<scalar>();
192 for (label i = 0; i < xy_.size() - 1; ++i)
200 return xy_.last()[0];
206 return xy_.first()[0];
212 return xy_.last()[0];
243 dict.add(
"distribution", xy_);
252 dict.readEntry(
"distribution", xy_);
virtual void readDict(const dictionary &dict)
Read data from dictionary.
virtual scalar maxValue() const
Return the maximum value.
virtual void writeData(Ostream &os) const
Write data to stream.
A class for handling words, derived from Foam::string.
virtual void readData(Istream &os)
Read data from stream.
addToRunTimeSelectionTable(distributionModel, binned, dictionary)
const word dictName("blockMeshDict")
A binned distribution model where the random sample is taken from a discrete set of bins.
Istream & operator>>(Istream &, directionInfo &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A library of runtime-selectable distribution models.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
#define forAll(list, i)
Loop across all elements in list.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
virtual scalar meanValue() const
Return the mean value.
virtual scalar sample() const
Sample the distributionModel.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
virtual scalar minValue() const
Return the minimum value.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual ~binned()
Destructor.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
static const char * header
errorManipArg< error, int > exit(error &err, const int errNo=1)
binned(const dictionary &dict, Random &rndGen)
Construct from dictionary.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
defineTypeNameAndDebug(binned, 0)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
virtual dictionary writeDict(const word &dictName) const
Write data in dictionary format.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
#define WarningInFunction
Report a warning using Foam::Warning.