initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / constant / constInjector.C
blob1a49bbef21ab9b3ef4f306cce4bdb118ebc80043
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "constInjector.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(constInjector, 0);
40 addToRunTimeSelectionTable
42     injectorModel,
43     constInjector,
44     dictionary
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 // Construct from components
51 constInjector::constInjector
53     const dictionary& dict,
54     spray& sm
57     injectorModel(dict, sm),
58     specDict_(dict.subDict(typeName + "Coeffs")),
59     dropletNozzleDiameterRatio_(specDict_.lookup("dropletNozzleDiameterRatio")),
60     sprayAngle_(specDict_.lookup("sprayAngle"))
62     if (sm.injectors().size() != dropletNozzleDiameterRatio_.size())
63     {
64         FatalError << "constInjector::constInjector"
65             << "(const dictionary& dict, spray& sm)\n"
66             << "Wrong number of entries in dropletNozzleDiameterRatio"
67             << abort(FatalError);
68     }
70     if (sm.injectors().size() != sprayAngle_.size())
71     {
72         FatalError << "constInjector::constInjector"
73             << "(const dictionary& dict, spray& sm)\n"
74             << "Wrong number of entries in sprayAngle"
75             << abort(FatalError);
76     }
78     scalar referencePressure = sm.p().average().value();
80     // correct velocity and pressure profiles
81     forAll(sm.injectors(), i)
82     {
83         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
84     }
89 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
91 constInjector::~constInjector()
95 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
97 scalar constInjector::d0
99     const label n, 
100     const scalar
101 ) const
103     return injectors_[n].properties()->d()*dropletNozzleDiameterRatio_[n];
107 vector constInjector::direction
109     const label n,
110     const label hole,
111     const scalar time,
112     const scalar d
113 ) const
116     /*
117         randomly distribute parcels in a solid cone
118         with angle = sprayAngle,
119         alpha = radius of the two normal vectors,
120         = maximum sin(sprayAngle/2)
121         beta = angle in the normal plane
122         
123                         o                    / (beta)
124                         |\                  /
125                         | \                /)
126                         |  \              o-----------> (x-axis)
127                         |   \
128                         v  (alpha)
129         */
131     scalar angle = rndGen_.scalar01()*sprayAngle_[n]*mathematicalConstant::pi/360.0;
132     scalar alpha = sin(angle);
133     scalar dcorr = cos(angle);
135     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
137     // randomly distributed vector normal to the injection vector
138     vector normal = vector::zero;
139     
140     if (sm_.twoD())
141     {
142         scalar reduce = 0.01;
143         // correct beta if this is a 2D run
144         // map it onto the 'angleOfWedge'
145         beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
146         beta += reduce*sm_.angleOfWedge();
148         normal = alpha*
149         (
150             sm_.axisOfWedge()*cos(beta) +
151             sm_.axisOfWedgeNormal()*sin(beta)
152         );
154     }
155     else
156     {
157         normal = alpha*
158         (
159             injectors_[n].properties()->tan1(hole)*cos(beta) +
160             injectors_[n].properties()->tan2(hole)*sin(beta)
161         );
162     }
163     
164     // set the direction of injection by adding the normal vector
165     vector dir = dcorr*injectors_[n].properties()->direction(n, time) + normal;
166     dir /= mag(dir);
168     return dir;
171 scalar constInjector::velocity
173     const label i,
174     const scalar time
175 ) const
177     const injectorType& it = sm_.injectors()[i].properties();
178     if (it.pressureIndependentVelocity())
179     {
180         return it.getTableValue(it.velocityProfile(), time);
181     }
182     else
183     {
184         scalar Pref = sm_.ambientPressure();
185         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
186         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
187         scalar dp = max(0.0, Pinj - Pref);
188         return sqrt(2.0*dp/rho);
189     }
192 scalar constInjector::averageVelocity
194     const label i
195 ) const
196 {    
197     const injectorType& it = sm_.injectors()[i].properties();
198     scalar dt = it.teoi() - it.tsoi();
200     return it.integrateTable(it.velocityProfile())/dt;
203 } // End namespace Foam
205 // ************************************************************************* //