initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / hollowCone / hollowCone.C
blob2121a803f11ee6c3ecd9859805069b37e284052f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "hollowCone.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(hollowConeInjector, 0);
40 addToRunTimeSelectionTable
42     injectorModel,
43     hollowConeInjector,
44     dictionary
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 // Construct from components
51 hollowConeInjector::hollowConeInjector
53     const dictionary& dict,
54     spray& sm
57     injectorModel(dict, sm),
58     hollowConeDict_(dict.subDict(typeName + "Coeffs")),
59     dropletPDF_
60     (
61         pdf::New
62         (
63             hollowConeDict_.subDict("dropletPDF"),
64             sm.rndGen()
65         )
66     ),
67     innerAngle_(hollowConeDict_.lookup("innerConeAngle")),
68     outerAngle_(hollowConeDict_.lookup("outerConeAngle")),
69     tan1_(outerAngle_.size()),
70     tan2_(outerAngle_.size())
73     if (sm.injectors().size() != innerAngle_.size())
74     {
75         FatalError << "hollowConeInjector::hollowConeInjector"
76             << "(const dictionary& dict, spray& sm)\n"
77             << "Wrong number of entries in innerAngle"
78             << abort(FatalError);
79     }
81     if (sm.injectors().size() != outerAngle_.size())
82     {
83         FatalError << "hollowConeInjector::hollowConeInjector"
84             << "(const dictionary& dict, spray& sm)\n"
85             << "Wrong number of entries in outerAngle"
86             << abort(FatalError);
87     }
89     forAll(sm.injectors(), i)
90     {
91         Random rndGen(label(0));
92         vector dir = sm.injectors()[i].properties()->direction();
93         scalar magV = 0.0;
94         vector tangent;
95         
96         while (magV < SMALL)
97         {
98             vector testThis = rndGen.vector01();
99             
100             tangent = testThis - (testThis & dir)*dir;
101             magV = mag(tangent);
102         }
103         
104         tan1_[i] = tangent/magV;
105         tan2_[i] = dir ^ tan1_[i];
106     }
108     scalar referencePressure = sm.ambientPressure();
109     // correct velocityProfile
110     forAll(sm.injectors(), i)
111     {
112         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
113     }
118 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
120 hollowConeInjector::~hollowConeInjector()
124 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
126 scalar hollowConeInjector::d0
128     const label, 
129     const scalar
130 ) const
132     return dropletPDF_->sample();
136 vector hollowConeInjector::direction
138     const label n,
139     const scalar,
140     const scalar
141 ) const
143     scalar angle = innerAngle_[n] + rndGen_.scalar01()*(outerAngle_[n]-innerAngle_[n]);
144     scalar alpha = sin(angle*mathematicalConstant::pi/360.0);
145     scalar dcorr = cos(angle*mathematicalConstant::pi/360.0);
146     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
148     // randomly distributed vector normal to the injection vector
149     vector normal = vector::zero;
150     
151     if (sm_.twoD())
152     {
153         scalar reduce = 0.01;
154         // correct beta if this is a 2D run
155         // map it onto the 'angleOfWedge'
157         beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
158         beta += reduce*sm_.angleOfWedge();
159         normal = alpha*
160         (
161             sm_.axisOfWedge()*cos(beta) +
162             sm_.axisOfWedgeNormal()*sin(beta)
163         );
164     }
165     else
166     {
167         normal = alpha*
168         (
169             tan1_[n]*cos(beta) +
170             tan2_[n]*sin(beta)
171         );
172     }
173     
174     // set the direction of injection by adding the normal vector
175     vector dir = dcorr*injectors_[n].properties()->direction() + normal;
176     dir /= mag(dir);
178     return dir;
182 scalar hollowConeInjector::velocity
184     const label i,
185     const scalar time
186 ) const
188     const injectorType& it = sm_.injectors()[i].properties();
189     if (it.pressureIndependentVelocity())
190     {
191         return it.getTableValue(it.velocityProfile(), time);
192     }
193     else
194     {
195         scalar Pref = sm_.ambientPressure();
196         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
197         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
198         scalar dp = max(0.0, Pinj - Pref);
199         return sqrt(2.0*dp/rho);
200     }
204 scalar hollowConeInjector::averageVelocity
206     const label i
207 ) const
208 {    
209     const injectorType& it = sm_.injectors()[i].properties();
210     scalar dt = it.teoi() - it.tsoi();
211     return it.integrateTable(it.velocityProfile())/dt;
214 } // End namespace Foam
216 // ************************************************************************* //