pdfPlot.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2013 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  pdfPlot
28 
29 Group
30  grpPostProcessingUtilitie
31 
32 Description
33  Generate a graph of a probability distribution function.
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #include "fvCFD.H"
38 #include "distributionModel.H"
39 #include "makeGraph.H"
40 #include "OFstream.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 int main(int argc, char *argv[])
45 {
46  argList::addNote
47  (
48  "Generate a graph of a probability distribution function"
49  );
50 
51  #include "setRootCase.H"
52  #include "createTime.H"
53  #include "createFields.H"
54 
55  label iCheck = 100;
56  for (label i=1; i<=nSamples; i++)
57  {
58  scalar ps = p->sample();
59  label n = label((ps - xMin)*nIntervals/(xMax - xMin));
60  samples[n]++;
61 
62  if (writeData)
63  {
64  filePtr() << ps << nl;
65  }
66 
67  if (i % iCheck == 0)
68  {
69  Info<< " processed " << i << " samples" << endl;
70 
71  if (i == 10*iCheck)
72  {
73  iCheck *= 10;
74  }
75  }
76  }
77 
79 
80  forAll(x, i)
81  {
82  x[i] = xMin + i*(xMax - xMin)/(nIntervals - 1);
83  }
84 
85  makeGraph(x, samples, p->type(), pdfPath, runTime.graphFormat());
86 
87  Info<< "End\n" << endl;
88 
89  return 0;
90 }
91 
92 
93 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
writeData
const bool writeData(pdfDictionary.get< bool >("writeData"))
filePtr
autoPtr< OFstream > filePtr
Definition: createFields.H:37
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
pdfPath
const fileName pdfPath
Definition: createFields.H:20
OFstream.H
n
label n
Definition: TABSMDCalcMethod2.H:31
xMin
const scalar xMin
Definition: createFields.H:34
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
makeGraph.H
Foam::makeGraph
void makeGraph(const scalarField &x, const volScalarField &vsf, const word &graphFormat)
Definition: makeGraph.C:41
samples
scalarField samples(nIntervals, Zero)
nIntervals
const label nIntervals(pdfDictionary.get< label >("nIntervals"))
nSamples
const label nSamples(pdfDictionary.get< label >("nSamples"))
setRootCase.H
Foam::nl
constexpr char nl
Definition: Ostream.H:404
xMax
const scalar xMax
Definition: createFields.H:35
createTime.H
x
x
Definition: LISASMDCalcMethod2.H:52
fvCFD.H
distributionModel.H