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];
65 <<
type() <<
"distribution: " 66 <<
"The sum of elements in the second column cannot be zero." <<
nl 67 <<
"sum = " << sumProb
73 xy_[bini][1] /= sumProb;
87 meanValue_ = xy_[bini][1];
100 xy_(distributionModelDict_.
lookup(
"distribution")),
115 const scalar binWidth,
131 const label bin0 = floor(
minValue_/binWidth);
132 const label bin1 = ceil(
maxValue_/binWidth);
133 const label nBin = bin1 - bin0;
138 <<
"Data cannot be binned - zero bins generated" <<
nl 139 <<
" Bin width : " << binWidth <<
nl 140 <<
" Sample data : " << sampleData
150 xy_[bini][0] = (bin0 + bini)*binWidth;
158 label bini = floor(sampleData[i]/binWidth) - bin0;
159 label binii =
min(bini + 1, nBin - 1);
161 scalar d1 =
mag(sampleData[i] - xy_[bini][0]);
162 scalar d2 =
mag(xy_[binii][0] - sampleData[i]);
180 distributionModel(
p),
182 meanValue_(
p.meanValue_)
190 const scalar u = rndGen_.sample01<scalar>();
192 for (label i = 0; i < xy_.size() - 1; ++i)
231 dict.add(
"distribution", xy_);
240 dict.readEntry(
"distribution", xy_);
247 const distributionModels::binned&
b
scalar maxValue_
Maximum of the distribution.
virtual void readData(Istream &os)
Read data from stream.
virtual scalar meanValue() const
Return the arithmetic mean of the distribution data.
Particle-size distribution model wherein random samples are drawn from a given discrete set of (bin...
binned(const dictionary &dict, Random &rndGen)
Construct from dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
const word dictName("faMeshDefinition")
Ostream & endl(Ostream &os)
Add newline and flush stream.
addToRunTimeSelectionTable(distributionModel, binned, dictionary)
Lookup type of boundary radiation properties.
virtual void writeData(Ostream &os) const
Write data to stream.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
static const char * header
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
defineTypeNameAndDebug(binned, 0)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
A class for handling words, derived from Foam::string.
virtual void check() const
Check that the distribution model is valid.
Istream & operator>>(Istream &, directionInfo &)
scalar minValue_
Minimum of the distribution.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual scalar sample() const
Sample the distribution.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual dictionary writeDict(const word &dictName) const
Write data in dictionary format.
OBJstream os(runTime.globalPath()/outputName)
virtual void readDict(const dictionary &dict)
Read data from dictionary.
#define WarningInFunction
Report a warning using Foam::Warning.
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...