mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
improved pdfPlot utility
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
-I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude
|
-I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lpdf
|
-lpdf \
|
||||||
|
-lsampling
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
"pdfDictionary",
|
"pdfDict",
|
||||||
runTime.constant(),
|
runTime.constant(),
|
||||||
runTime,
|
runTime,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
@ -10,20 +10,9 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
label nIntervals
|
label nIntervals(readLabel(pdfDictionary.lookup("nIntervals")));
|
||||||
(
|
|
||||||
readLabel(pdfDictionary.lookup("nIntervals"))
|
|
||||||
);
|
|
||||||
|
|
||||||
label nSamples
|
label nSamples(readLabel(pdfDictionary.lookup("nSamples")));
|
||||||
(
|
|
||||||
readLabel(pdfDictionary.lookup("nSamples"))
|
|
||||||
);
|
|
||||||
|
|
||||||
label samples[nIntervals];
|
scalarField samples(nIntervals, 0);
|
||||||
|
|
||||||
for(label i=0;i<nIntervals;i++)
|
|
||||||
{
|
|
||||||
samples[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: 1.6 |
|
||||||
|
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object pdfDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Number of intervals/bins in pdf plot
|
||||||
|
nIntervals 20;
|
||||||
|
|
||||||
|
// Number of samples
|
||||||
|
nSamples 10000;
|
||||||
|
|
||||||
|
// Type of pdf
|
||||||
|
pdfType RosinRammler;
|
||||||
|
|
||||||
|
RosinRammlerPDF
|
||||||
|
{
|
||||||
|
minValue 1e-06;
|
||||||
|
maxValue 200e-06;
|
||||||
|
d (60.0e-06);
|
||||||
|
n (0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -23,50 +23,60 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Generates an .obj file to plot a probability distribution function
|
Generates a graph of a probability distribution function
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "fvCFD.H"
|
#include "fvCFD.H"
|
||||||
#include "pdf.H"
|
#include "pdf.H"
|
||||||
#include "OFstream.H"
|
#include "makeGraph.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
#include "createFields.H"
|
#include "createFields.H"
|
||||||
|
|
||||||
OFstream objFileNew("s.m");
|
fileName pdfPath = runTime.path()/"pdf";
|
||||||
|
mkDir(pdfPath);
|
||||||
|
|
||||||
Random rndGen(label(0));
|
Random rndGen(label(0));
|
||||||
|
|
||||||
autoPtr<pdf> p
|
autoPtr<pdf> p(pdf::New(pdfDictionary, rndGen));
|
||||||
(
|
|
||||||
pdf::New(pdfDictionary, rndGen)
|
|
||||||
);
|
|
||||||
|
|
||||||
scalar xMin = p->minValue();
|
scalar xMin = p->minValue();
|
||||||
|
|
||||||
scalar xMax = p->maxValue();
|
scalar xMax = p->maxValue();
|
||||||
|
|
||||||
for(label i=0;i<nSamples;i++)
|
label iCheck = 100;
|
||||||
|
for (label i=1; i<=nSamples; i++)
|
||||||
{
|
{
|
||||||
scalar ps = p->sample();
|
scalar ps = p->sample();
|
||||||
label n = label((ps - xMin)*nIntervals/(xMax - xMin));
|
label n = label((ps - xMin)*nIntervals/(xMax - xMin));
|
||||||
//Info << "p[" << i << "] = " << ps << ", n = " << n << endl;
|
|
||||||
samples[n]++;
|
samples[n]++;
|
||||||
|
|
||||||
|
if (i % iCheck == 0)
|
||||||
|
{
|
||||||
|
Info<< " processed " << i << " samples" << endl;
|
||||||
|
|
||||||
|
if (i == 10*iCheck)
|
||||||
|
{
|
||||||
|
iCheck *= 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(label i=0;i<nIntervals;i++)
|
scalarField x(nIntervals);
|
||||||
|
|
||||||
|
forAll(x, i)
|
||||||
{
|
{
|
||||||
scalar x = xMin + i*(xMax-xMin)/(nIntervals-1);
|
x[i] = xMin + i*(xMax - xMin)/(nIntervals - 1);
|
||||||
objFileNew << x << " \t" << samples[i] << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
makeGraph(x, samples, p->type(), pdfPath, runTime.graphFormat());
|
||||||
|
|
||||||
Info << "End\n" << endl;
|
Info << "End\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user