Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / Chomiak / Chomiak.C
blobee91adccaeaf042c9c968105735d807ae882420a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
27 #include "Chomiak.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(ChomiakInjector, 0);
40 addToRunTimeSelectionTable
42     injectorModel,
43     ChomiakInjector,
44     dictionary
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 // Construct from components
51 ChomiakInjector::ChomiakInjector
53     const dictionary& dict,
54     spray& sm
57     injectorModel(dict, sm),
58     ChomiakDict_(dict.subDict(typeName + "Coeffs")),
59     dropletPDF_
60     (
61         pdf::New
62         (
63             ChomiakDict_.subDict("dropletPDF"),
64             sm.rndGen()
65         )
66     ),
67     maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle"))
70     if (sm.injectors().size() != maxSprayAngle_.size())
71     {
72         FatalError << "ChomiakInjector::ChomiakInjector"
73             << "(const dictionary& dict, spray& sm)\n"
74             << "Wrong number of entries in maxSprayAngle"
75             << abort(FatalError);
76     }
78     scalar referencePressure = sm.p().average().value();
80     // correct velocityProfile
81     forAll(sm.injectors(), i)
82     {
83         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
84     }
89 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
91 ChomiakInjector::~ChomiakInjector()
95 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
97 scalar ChomiakInjector::d0
99     const label, 
100     const scalar
101 ) const
103     return dropletPDF_->sample();
107 vector ChomiakInjector::direction
109     const label n,
110     const label hole,
111     const scalar time,
112     const scalar d
113 ) const
115     scalar dMin = dropletPDF_->minValue();
116     scalar dMax = dropletPDF_->maxValue();
118     scalar angle = (d-dMax)*maxSprayAngle_[n]/(dMin-dMax)*mathematicalConstant::pi/360.0;
119     scalar alpha = sin(angle);
120     scalar dcorr = cos(angle);
122     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
124     // randomly distributed vector normal to the injection vector
125     vector normal = vector::zero;
126     
127     if (sm_.twoD())
128     {
129         scalar reduce = 0.01;
130         // correct beta if this is a 2D run
131         // map it onto the 'angleOfWedge'
132         beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
133         beta += reduce*sm_.angleOfWedge();
135         normal = alpha*
136         (
137             sm_.axisOfWedge()*cos(beta) +
138             sm_.axisOfWedgeNormal()*sin(beta)
139         );
141     }
142     else
143     {
144         normal = alpha*
145         (
146             injectors_[n].properties()->tan1(hole)*cos(beta) +
147             injectors_[n].properties()->tan2(hole)*sin(beta)
148         );
149     }
150     
151     // set the direction of injection by adding the normal vector
152     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
153     dir /= mag(dir);
155     return dir;
159 scalar ChomiakInjector::velocity
161     const label i,
162     const scalar time
163 ) const
165     const injectorType& it = sm_.injectors()[i].properties();
166     if (it.pressureIndependentVelocity())
167     {
168         return it.getTableValue(it.velocityProfile(), time);
169     }
170     else
171     {
172         scalar Pref = sm_.ambientPressure();
173         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
174         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
175         scalar dp = max(0.0, Pinj - Pref);
176         return sqrt(2.0*dp/rho);
177     }
180 scalar ChomiakInjector::averageVelocity
182     const label i
183 ) const
184 {    
185     const injectorType& it = sm_.injectors()[i].properties();
186     scalar dt = it.teoi() - it.tsoi();
187     return it.integrateTable(it.velocityProfile())/dt;
190 } // End namespace Foam
192 // ************************************************************************* //