1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "RosinRammler.H"
29 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(RosinRammler, 0);
38 addToRunTimeSelectionTable
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 // Construct from components
49 RosinRammler::RosinRammler
51 const dictionary& dict,
56 pdfDict_(dict.subDict(typeName + "PDF")),
57 minValue_(readScalar(pdfDict_.lookup("minValue"))),
58 maxValue_(readScalar(pdfDict_.lookup("maxValue"))),
59 d_(pdfDict_.lookup("d")),
60 n_(pdfDict_.lookup("n")),
62 range_(maxValue_-minValue_)
68 "RosinRammler::RosinRammler(const dictionary& dict)"
69 ) << " minValue = " << minValue_ << ", it must be >0." << abort(FatalError);
72 if (maxValue_<minValue_)
76 "RosinRammler::RosinRammler(const dictionary& dict)"
77 ) << " maxValue is smaller than minValue." << abort(FatalError);
80 // find max value so that it can be normalized to 1.0
83 for(label i=0; i<n; i++)
86 for(label j=0; j<n; j++)
90 scalar xx = pow(d_[j]/d_[i], n_[j]);
91 scalar y = xx*exp(-xx);
99 for(label i=0; i<n; i++)
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 Foam::RosinRammler::~RosinRammler()
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 scalar RosinRammler::sample() const
120 bool success = false;
124 x = minValue_ + range_*rndGen_.scalar01();
125 y = rndGen_.scalar01();
128 for(label i=0; i<n; i++)
130 scalar xx = pow(x/d_[i], n_[i]);
131 p += ls_[i]*xx*exp(-xx);
143 scalar RosinRammler::minValue() const
148 scalar RosinRammler::maxValue() const
153 // ************************************************************************* //