1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "constInjector.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(constInjector, 0);
36 addToRunTimeSelectionTable
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::constInjector::constInjector
49 const dictionary& dict,
53 injectorModel(dict, sm),
54 specDict_(dict.subDict(typeName + "Coeffs")),
55 dropletNozzleDiameterRatio_(specDict_.lookup("dropletNozzleDiameterRatio")),
56 sprayAngle_(specDict_.lookup("sprayAngle"))
58 if (sm.injectors().size() != dropletNozzleDiameterRatio_.size())
62 "constInjector::constInjector(const dictionary& dict, spray& sm)"
63 ) << "Wrong number of entries in dropletNozzleDiameterRatio" << nl
67 if (sm.injectors().size() != sprayAngle_.size())
71 "constInjector::constInjector(const dictionary& dict, spray& sm)"
72 ) << "Wrong number of entries in sprayAngle" << nl
76 scalar referencePressure = sm.p().average().value();
78 // correct velocity and pressure profiles
79 forAll(sm.injectors(), i)
81 sm.injectors()[i].properties()->correctProfiles
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 Foam::constInjector::~constInjector()
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 Foam::scalar Foam::constInjector::d0
104 return injectors_[n].properties()->d()*dropletNozzleDiameterRatio_[n];
108 Foam::vector Foam::constInjector::direction
118 randomly distribute parcels in a solid cone
119 with angle = sprayAngle,
120 alpha = radius of the two normal vectors,
121 = maximum sin(sprayAngle/2)
122 beta = angle in the normal plane
127 | \ o-----------> (x-axis)
133 rndGen_.sample01<scalar>()*sprayAngle_[n]
134 *constant::mathematical::pi/360.0;
135 scalar alpha = sin(angle);
136 scalar dcorr = cos(angle);
138 scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
140 // randomly distributed vector normal to the injection vector
141 vector normal = vector::zero;
145 scalar reduce = 0.01;
146 // correct beta if this is a 2D run
147 // map it onto the 'angleOfWedge'
150 *0.5*sm_.angleOfWedge()
151 /constant::mathematical::pi;
152 beta += reduce*sm_.angleOfWedge();
157 sm_.axisOfWedge()*cos(beta)
158 + sm_.axisOfWedgeNormal()*sin(beta)
167 injectors_[n].properties()->tan1(hole)*cos(beta)
168 + injectors_[n].properties()->tan2(hole)*sin(beta)
172 // set the direction of injection by adding the normal vector
173 vector dir = dcorr*injectors_[n].properties()->direction(n, time) + normal;
180 Foam::scalar Foam::constInjector::velocity
186 const injectorType& it = sm_.injectors()[i].properties();
187 if (it.pressureIndependentVelocity())
189 return it.getTableValue(it.velocityProfile(), time);
193 scalar Pref = sm_.ambientPressure();
194 scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
195 scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
196 scalar dp = max(0.0, Pinj - Pref);
197 return sqrt(2.0*dp/rho);
202 Foam::scalar Foam::constInjector::averageVelocity(const label i) const
204 const injectorType& it = sm_.injectors()[i].properties();
205 scalar dt = it.teoi() - it.tsoi();
207 return it.integrateTable(it.velocityProfile())/dt;
211 // ************************************************************************* //