This new class hierarchy replaces the distributions previously provided by the Lagrangian library. All distributions (except fixedValue) now require a "size exponent", Q, to be specified along with their other coefficients. If a distribution's CDF(x) (cumulative distribution function) represents what proportion of the distribution takes a value below x, then Q determines what is meant by "proportion": - If Q=0, then "proportion" means the number of sampled values expected to be below x divided by the total number of sampled values. - If Q=3, then "proportion" means the expected sum of sampled values cubed for values below x divided by the total sum of values cubed. If x is a length, then this can be interpreted as a proportion of the total volume of sampled objects. - If Q=2, and x is a length, then the distribution might represent the proportion of surface area, and so on... In addition to the user-specification of Q defining what size the given distribution relates to, an implementation that uses a distribution can also programmatically define a samplingQ to determine what sort of sample is being constructed; whether the samples should have an equal number (sampleQ=0), volume (sampleQ=3), area (sampleQ=2), etc... A number of fixes to the distributions have been made, including fixing some fundamental bugs in the returned distribution of samples, incorrect calculation of the distribution means, renaming misleadingly named parameters, and correcting some inconsistencies in the way in which tabulated PDF and CDF data was processed. Distributions no longer require their parameters to be defined in a sub-dictionary, but a sub-dictionary is still supported for backwards compatibility. The distributions can now generate their PDF-s as well as samples, and a test application has been added (replacing two previous applications), which thoroughly checks consistency between the PDF and the samples for a variety of combinations of values of Q and sampleQ. Backwards incompatible changes are as follows: - The standard deviation keyword for the normal (and multi-normal) distribution is now called 'sigma'. Previously this was 'variance', which was misleading, as the value is a standard deviation. - The 'massRosinRammler' distribution has been removed. This functionality is now provided by the standard 'RosinRammler' distributon with a Q equal to 0, and a sampleQ of 3. - The 'general' distribution has been split into separate distributions based on whether PDF or CDF data is provided. These distributions are called 'tabulatedDensity' and 'tabulatedCumulative', respectively.
94 lines
2.5 KiB
C++
94 lines
2.5 KiB
C++
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration | Website: https://openfoam.org
|
|
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
Application
|
|
pdfPlot
|
|
|
|
Description
|
|
Generates a graph of a probability distribution function.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "argList.H"
|
|
#include "Time.H"
|
|
#include "distribution.H"
|
|
#include "setWriter.H"
|
|
#include "writeFile.H"
|
|
#include "OFstream.H"
|
|
|
|
using namespace Foam;
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
#include "setRootCase.H"
|
|
#include "createTime.H"
|
|
#include "createFields.H"
|
|
|
|
label iCheck = 100;
|
|
for (label i=1; i<=nSamples; i++)
|
|
{
|
|
scalar ps = p->sample();
|
|
label n = label((ps - xMin)*nIntervals/(xMax - xMin));
|
|
samples[n]++;
|
|
|
|
if (writeData)
|
|
{
|
|
filePtr() << ps << nl;
|
|
}
|
|
|
|
if (i % iCheck == 0)
|
|
{
|
|
Info<< " processed " << i << " samples" << endl;
|
|
|
|
if (i == 10*iCheck)
|
|
{
|
|
iCheck *= 10;
|
|
}
|
|
}
|
|
}
|
|
|
|
scalarField x(nIntervals);
|
|
forAll(x, i)
|
|
{
|
|
x[i] = xMin + i*(xMax - xMin)/(nIntervals - 1);
|
|
}
|
|
|
|
setWriter::New(runTime.graphFormat())->write
|
|
(
|
|
pdfPath,
|
|
args.executable(),
|
|
coordSet(true, "x", x),
|
|
p->type(),
|
|
samples
|
|
);
|
|
|
|
Info<< "End\n" << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|