mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Updated pdfPlot utility
- pdf updated - needs to be inside pdfs namespace - added writeData option - write individual data/samples to file
This commit is contained in:
@ -10,9 +10,32 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
label nIntervals(readLabel(pdfDictionary.lookup("nIntervals")));
|
const label nIntervals(readLabel(pdfDictionary.lookup("nIntervals")));
|
||||||
|
|
||||||
label nSamples(readLabel(pdfDictionary.lookup("nSamples")));
|
const label nSamples(readLabel(pdfDictionary.lookup("nSamples")));
|
||||||
|
|
||||||
|
const bool writeData(readBool(pdfDictionary.lookup("writeData")));
|
||||||
|
|
||||||
|
|
||||||
|
const fileName pdfPath = runTime.path()/"pdf";
|
||||||
|
mkDir(pdfPath);
|
||||||
|
|
||||||
|
Random rndGen(label(0));
|
||||||
|
|
||||||
|
autoPtr<pdfs::pdf> p(pdfs::pdf::New(pdfDictionary, rndGen));
|
||||||
|
|
||||||
|
const scalar xMin = p->minValue();
|
||||||
|
const scalar xMax = p->maxValue();
|
||||||
|
|
||||||
|
autoPtr<OFstream> filePtr(NULL);
|
||||||
|
if (writeData)
|
||||||
|
{
|
||||||
|
fileName fName = pdfPath/(p->type() + ".data");
|
||||||
|
Info<< "Writing " << p->type() << " data samples to file:" << nl
|
||||||
|
<< fName << nl << endl;
|
||||||
|
|
||||||
|
filePtr.reset(new OFstream(fName));
|
||||||
|
}
|
||||||
|
|
||||||
scalarField samples(nIntervals, 0);
|
scalarField samples(nIntervals, 0);
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,10 @@ nSamples 10000;
|
|||||||
// Type of pdf
|
// Type of pdf
|
||||||
pdfType RosinRammler;
|
pdfType RosinRammler;
|
||||||
|
|
||||||
|
// Write data flag
|
||||||
|
writeData true;
|
||||||
|
|
||||||
|
// PDF model coefficients
|
||||||
RosinRammlerPDF
|
RosinRammlerPDF
|
||||||
{
|
{
|
||||||
minValue 1e-06;
|
minValue 1e-06;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -30,6 +30,7 @@ Description
|
|||||||
#include "fvCFD.H"
|
#include "fvCFD.H"
|
||||||
#include "pdf.H"
|
#include "pdf.H"
|
||||||
#include "makeGraph.H"
|
#include "makeGraph.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
@ -40,16 +41,6 @@ int main(int argc, char *argv[])
|
|||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
#include "createFields.H"
|
#include "createFields.H"
|
||||||
|
|
||||||
fileName pdfPath = runTime.path()/"pdf";
|
|
||||||
mkDir(pdfPath);
|
|
||||||
|
|
||||||
Random rndGen(label(0));
|
|
||||||
|
|
||||||
autoPtr<pdf> p(pdf::New(pdfDictionary, rndGen));
|
|
||||||
|
|
||||||
scalar xMin = p->minValue();
|
|
||||||
scalar xMax = p->maxValue();
|
|
||||||
|
|
||||||
label iCheck = 100;
|
label iCheck = 100;
|
||||||
for (label i=1; i<=nSamples; i++)
|
for (label i=1; i<=nSamples; i++)
|
||||||
{
|
{
|
||||||
@ -57,6 +48,11 @@ int main(int argc, char *argv[])
|
|||||||
label n = label((ps - xMin)*nIntervals/(xMax - xMin));
|
label n = label((ps - xMin)*nIntervals/(xMax - xMin));
|
||||||
samples[n]++;
|
samples[n]++;
|
||||||
|
|
||||||
|
if (writeData)
|
||||||
|
{
|
||||||
|
filePtr() << ps << nl;
|
||||||
|
}
|
||||||
|
|
||||||
if (i % iCheck == 0)
|
if (i % iCheck == 0)
|
||||||
{
|
{
|
||||||
Info<< " processed " << i << " samples" << endl;
|
Info<< " processed " << i << " samples" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user