Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

View File

@ -0,0 +1,3 @@
pdfPlot.C
EXE = $(FOAM_APPBIN)/pdfPlot

View File

@ -0,0 +1,8 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-ldistributionModels \
-lsampling

View File

@ -0,0 +1,48 @@
IOdictionary pdfDictionary
(
IOobject
(
"pdfDict",
runTime.constant(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
const label nIntervals(readLabel(pdfDictionary.lookup("nIntervals")));
const label nSamples(readLabel(pdfDictionary.lookup("nSamples")));
const bool writeData(readBool(pdfDictionary.lookup("writeData")));
const fileName pdfPath = runTime.path()/"pdf";
mkDir(pdfPath);
cachedRandom rndGen(label(0), -1);
autoPtr<distributionModels::distributionModel> p
(
distributionModels::distributionModel::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);

View File

@ -0,0 +1,38 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: 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
type RosinRammler;
// Write data flag
writeData true;
// PDF model coefficients
RosinRammlerDistribution
{
minValue 1e-06;
maxValue 200e-06;
d 60.0e-06;
n 0.8;
}
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "fvCFD.H"
#include "distributionModel.H"
#include "makeGraph.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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);
}
makeGraph(x, samples, p->type(), pdfPath, runTime.graphFormat());
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //