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-------------------------------------------------------------------------------
10License
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
26Application
27 pdfPlot
28
29Group
30 grpPostProcessingUtilitie
31
32Description
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
44int 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// ************************************************************************* //
label n
makeGraph(y, UMeanXvalues, "Uf", path, gFormat)
volScalarField & p
engineTime & runTime
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
const label nIntervals(pdfDictionary.get< label >("nIntervals"))
const label nSamples(pdfDictionary.get< label >("nSamples"))
const scalar xMin
Definition: createFields.H:34
const fileName pdfPath
Definition: createFields.H:20
scalarField samples(nIntervals, Zero)
const scalar xMax
Definition: createFields.H:35
const bool writeData(pdfDictionary.get< bool >("writeData"))
autoPtr< OFstream > filePtr
Definition: createFields.H:37