1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 "constInjector.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(constInjector, 0);
40 addToRunTimeSelectionTable
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 // Construct from components
51 constInjector::constInjector
53 const dictionary& dict,
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())
64 FatalError << "constInjector::constInjector"
65 << "(const dictionary& dict, spray& sm)\n"
66 << "Wrong number of entries in dropletNozzleDiameterRatio"
70 if (sm.injectors().size() != sprayAngle_.size())
72 FatalError << "constInjector::constInjector"
73 << "(const dictionary& dict, spray& sm)\n"
74 << "Wrong number of entries in sprayAngle"
78 scalar referencePressure = sm.p().average().value();
80 // correct velocity and pressure profiles
81 forAll(sm.injectors(), i)
83 sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
89 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 constInjector::~constInjector()
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 scalar constInjector::d0
103 return injectors_[n].properties()->d()*dropletNozzleDiameterRatio_[n];
107 vector constInjector::direction
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
126 | \ o-----------> (x-axis)
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;
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();
150 sm_.axisOfWedge()*cos(beta) +
151 sm_.axisOfWedgeNormal()*sin(beta)
159 injectors_[n].properties()->tan1(hole)*cos(beta) +
160 injectors_[n].properties()->tan2(hole)*sin(beta)
164 // set the direction of injection by adding the normal vector
165 vector dir = dcorr*injectors_[n].properties()->direction(n, time) + normal;
171 scalar constInjector::velocity
177 const injectorType& it = sm_.injectors()[i].properties();
178 if (it.pressureIndependentVelocity())
180 return it.getTableValue(it.velocityProfile(), time);
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);
192 scalar constInjector::averageVelocity
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 // ************************************************************************* //