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 \*---------------------------------------------------------------------------*/
27 #include "hollowCone.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(hollowConeInjector, 0);
40 addToRunTimeSelectionTable
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 // Construct from components
51 hollowConeInjector::hollowConeInjector
53 const dictionary& dict,
57 injectorModel(dict, sm),
58 hollowConeDict_(dict.subDict(typeName + "Coeffs")),
63 hollowConeDict_.subDict("dropletPDF"),
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())
75 FatalError << "hollowConeInjector::hollowConeInjector"
76 << "(const dictionary& dict, spray& sm)\n"
77 << "Wrong number of entries in innerAngle"
81 if (sm.injectors().size() != outerAngle_.size())
83 FatalError << "hollowConeInjector::hollowConeInjector"
84 << "(const dictionary& dict, spray& sm)\n"
85 << "Wrong number of entries in outerAngle"
89 forAll(sm.injectors(), i)
91 Random rndGen(label(0));
92 vector dir = sm.injectors()[i].properties()->direction();
98 vector testThis = rndGen.vector01();
100 tangent = testThis - (testThis & dir)*dir;
104 tan1_[i] = tangent/magV;
105 tan2_[i] = dir ^ tan1_[i];
108 scalar referencePressure = sm.ambientPressure();
109 // correct velocityProfile
110 forAll(sm.injectors(), i)
112 sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
118 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
120 hollowConeInjector::~hollowConeInjector()
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 scalar hollowConeInjector::d0
132 return dropletPDF_->sample();
136 vector hollowConeInjector::direction
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;
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();
161 sm_.axisOfWedge()*cos(beta) +
162 sm_.axisOfWedgeNormal()*sin(beta)
174 // set the direction of injection by adding the normal vector
175 vector dir = dcorr*injectors_[n].properties()->direction() + normal;
182 scalar hollowConeInjector::velocity
188 const injectorType& it = sm_.injectors()[i].properties();
189 if (it.pressureIndependentVelocity())
191 return it.getTableValue(it.velocityProfile(), time);
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);
204 scalar hollowConeInjector::averageVelocity
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 // ************************************************************************* //