initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / hollowCone / hollowCone.C
blob2613f8584f4fa8d6195ff7a7ccab85525dcaaebc
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 "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"))
71     if (sm.injectors().size() != innerAngle_.size())
72     {
73         FatalError << "hollowConeInjector::hollowConeInjector"
74             << "(const dictionary& dict, spray& sm)\n"
75             << "Wrong number of entries in innerAngle"
76             << abort(FatalError);
77     }
79     if (sm.injectors().size() != outerAngle_.size())
80     {
81         FatalError << "hollowConeInjector::hollowConeInjector"
82             << "(const dictionary& dict, spray& sm)\n"
83             << "Wrong number of entries in outerAngle"
84             << abort(FatalError);
85     }
87     scalar referencePressure = sm.ambientPressure();
89     // correct velocityProfile
90     forAll(sm.injectors(), i)
91     {
92         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
93     }
98 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
100 hollowConeInjector::~hollowConeInjector()
104 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
106 scalar hollowConeInjector::d0
108     const label, 
109     const scalar
110 ) const
112     return dropletPDF_->sample();
116 vector hollowConeInjector::direction
118     const label n,
119     const label hole,
120     const scalar time,
121     const scalar d
122 ) const
124     scalar angle = innerAngle_[n] + rndGen_.scalar01()*(outerAngle_[n]-innerAngle_[n]);
125     scalar alpha = sin(angle*mathematicalConstant::pi/360.0);
126     scalar dcorr = cos(angle*mathematicalConstant::pi/360.0);
127     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
129     // randomly distributed vector normal to the injection vector
130     vector normal = vector::zero;
131     
132     if (sm_.twoD())
133     {
134         scalar reduce = 0.01;
135         // correct beta if this is a 2D run
136         // map it onto the 'angleOfWedge'
138         beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
139         beta += reduce*sm_.angleOfWedge();
140         normal = alpha*
141         (
142             sm_.axisOfWedge()*cos(beta) +
143             sm_.axisOfWedgeNormal()*sin(beta)
144         );
145     }
146     else
147     {
148         normal = alpha*
149         (
150             injectors_[n].properties()->tan1(hole)*cos(beta) +
151             injectors_[n].properties()->tan2(hole)*sin(beta)
152         );
153     }
154     
155     // set the direction of injection by adding the normal vector
156     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
157     dir /= mag(dir);
159     return dir;
163 scalar hollowConeInjector::velocity
165     const label i,
166     const scalar time
167 ) const
169     const injectorType& it = sm_.injectors()[i].properties();
170     if (it.pressureIndependentVelocity())
171     {
172         return it.getTableValue(it.velocityProfile(), time);
173     }
174     else
175     {
176         scalar Pref = sm_.ambientPressure();
177         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
178         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
179         scalar dp = max(0.0, Pinj - Pref);
180         return sqrt(2.0*dp/rho);
181     }
185 scalar hollowConeInjector::averageVelocity
187     const label i
188 ) const
189 {    
190     const injectorType& it = sm_.injectors()[i].properties();
191     scalar dt = it.teoi() - it.tsoi();
192     return it.integrateTable(it.velocityProfile())/dt;
195 } // End namespace Foam
197 // ************************************************************************* //