1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "definedHollowCone.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(definedHollowConeInjector, 0);
39 addToRunTimeSelectionTable
42 definedHollowConeInjector,
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 // Construct from components
50 definedHollowConeInjector::definedHollowConeInjector
52 const dictionary& dict,
56 injectorModel(dict, sm),
57 definedHollowConeDict_(dict.subDict(typeName + "Coeffs")),
62 definedHollowConeDict_.subDict("dropletPDF"),
66 innerConeAngle_(definedHollowConeDict_.lookup("innerConeAngle")),
67 outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle"))
70 // convert CA to real time - inner cone angle
71 forAll(innerConeAngle_, i)
73 innerConeAngle_[i][0] = sm.runTime().userTimeToTime(innerConeAngle_[i][0]);
75 // convert CA to real time - outer cone angle
76 forAll(outerConeAngle_, i)
78 outerConeAngle_[i][0] = sm.runTime().userTimeToTime(outerConeAngle_[i][0]);
81 // check number of injectors
82 if (sm.injectors().size() != 1)
84 Info << "Warning!!!\n"
85 << "definedHollowConeInjector::definedHollowConeInjector"
86 << "(const dictionary& dict, spray& sm)\n"
87 << "Same inner/outer cone angle profiles applied to each injector"
91 // check number of entries in innerConeAngle list
92 if (innerConeAngle_.empty())
94 FatalError << "definedHollowConeInjector::definedHollowConeInjector"
95 << "(const dictionary& dict, spray& sm)\n"
96 << "Number of entries in innerConeAngle must be greater than zero"
100 // check number of entries in outerConeAngle list
101 if (outerConeAngle_.empty())
103 FatalError << "definedHollowConeInjector::definedHollowConeInjector"
104 << "(const dictionary& dict, spray& sm)\n"
105 << "Number of entries in outerConeAngle must be greater than zero"
106 << abort(FatalError);
109 scalar referencePressure = sm.p().average().value();
110 // correct pressureProfile
111 forAll(sm.injectors(), i)
113 sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
119 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
121 definedHollowConeInjector::~definedHollowConeInjector()
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 scalar definedHollowConeInjector::d0
133 // swallow function arguments - not used
134 // return value sampled from PDF
135 return dropletPDF_->sample();
139 vector definedHollowConeInjector::direction
148 const injectorType& it = injectors_[n].properties();
150 // interpolate to find inner and outer angles at time, t
151 scalar angleInner = it.getTableValue(innerConeAngle_, t);
152 scalar angleOuter = it.getTableValue(outerConeAngle_, t);
154 // use random number to generate angle between inner/outer cone angles
155 scalar angle = angleInner + rndGen_.scalar01()*(angleOuter-angleInner);
157 scalar alpha = sin(angle*mathematicalConstant::pi/360.0);
158 scalar dcorr = cos(angle*mathematicalConstant::pi/360.0);
159 scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
161 // randomly distributed vector normal to the injection vector
162 vector normal = vector::zero;
166 scalar reduce = 0.01;
167 // correct beta if this is a 2D run
168 // map it onto the 'angleOfWedge'
170 beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
171 beta += reduce*sm_.angleOfWedge();
174 sm_.axisOfWedge()*cos(beta) +
175 sm_.axisOfWedgeNormal()*sin(beta)
182 injectors_[n].properties()->tan1(hole)*cos(beta) +
183 injectors_[n].properties()->tan2(hole)*sin(beta)
187 // set the direction of injection by adding the normal vector
188 vector dir = dcorr*injectors_[n].properties()->direction(hole, t) + normal;
189 // normailse direction vector
196 scalar definedHollowConeInjector::velocity
202 const injectorType& it = sm_.injectors()[i].properties();
203 if (it.pressureIndependentVelocity())
205 return it.getTableValue(it.velocityProfile(), time);
209 scalar Pref = sm_.ambientPressure();
210 scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
211 scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
212 scalar dp = max(0.0, Pinj - Pref);
213 return sqrt(2.0*dp/rho);
217 scalar definedHollowConeInjector::averageVelocity
222 const injectorType& it = sm_.injectors()[i].properties();
223 scalar dt = it.teoi() - it.tsoi();
224 return it.integrateTable(it.velocityProfile())/dt;
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 } // End namespace Foam
231 // ************************************************************************* //