1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "definedHollowCone.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(definedHollowConeInjector, 0);
36 addToRunTimeSelectionTable
39 definedHollowConeInjector,
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::definedHollowConeInjector::definedHollowConeInjector
49 const dictionary& dict,
53 injectorModel(dict, sm),
54 definedHollowConeDict_(dict.subDict(typeName + "Coeffs")),
57 distributionModels::distributionModel::New
59 definedHollowConeDict_.subDict("sizeDistribution"),
63 innerConeAngle_(definedHollowConeDict_.lookup("innerConeAngle")),
64 outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle"))
66 // convert CA to real time - inner cone angle
67 forAll(innerConeAngle_, i)
69 innerConeAngle_[i][0] =
70 sm.runTime().userTimeToTime(innerConeAngle_[i][0]);
72 // convert CA to real time - outer cone angle
73 forAll(outerConeAngle_, i)
75 outerConeAngle_[i][0] =
76 sm.runTime().userTimeToTime(outerConeAngle_[i][0]);
79 // check number of injectors
80 if (sm.injectors().size() != 1)
84 "definedHollowConeInjector::definedHollowConeInjector"
85 "(const dictionary& dict, spray& sm)"
86 ) << "Same inner/outer cone angle profiles applied to each injector"
90 // check number of entries in innerConeAngle list
91 if (innerConeAngle_.empty())
95 "definedHollowConeInjector::definedHollowConeInjector"
96 "(const dictionary& dict, spray& sm)"
97 ) << "Number of entries in innerConeAngle must be greater than zero"
101 // check number of entries in outerConeAngle list
102 if (outerConeAngle_.empty())
106 "definedHollowConeInjector::definedHollowConeInjector"
107 "(const dictionary& dict, spray& sm)"
108 ) << "Number of entries in outerConeAngle must be greater than zero"
109 << abort(FatalError);
112 scalar referencePressure = sm.p().average().value();
113 // correct pressureProfile
114 forAll(sm.injectors(), i)
116 sm.injectors()[i].properties()->correctProfiles
125 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
127 Foam::definedHollowConeInjector::~definedHollowConeInjector()
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 Foam::scalar Foam::definedHollowConeInjector::d0
139 // swallow function arguments - not used
140 // return value sampled from distribution model
141 return sizeDistribution_->sample();
145 Foam::vector Foam::definedHollowConeInjector::direction
153 const injectorType& it = injectors_[n].properties();
155 // interpolate to find inner and outer angles at time, t
156 scalar angleInner = it.getTableValue(innerConeAngle_, t);
157 scalar angleOuter = it.getTableValue(outerConeAngle_, t);
159 // use random number to generate angle between inner/outer cone angles
160 scalar angle = rndGen_.position<scalar>(angleInner, angleOuter);
162 scalar alpha = sin(angle*constant::mathematical::pi/360.0);
163 scalar dcorr = cos(angle*constant::mathematical::pi/360.0);
164 scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
166 // randomly distributed vector normal to the injection vector
167 vector normal = vector::zero;
171 scalar reduce = 0.01;
172 // correct beta if this is a 2D run
173 // map it onto the 'angleOfWedge'
178 /(constant::mathematical::twoPi);
179 beta += reduce*sm_.angleOfWedge();
183 sm_.axisOfWedge()*cos(beta)
184 + sm_.axisOfWedgeNormal()*sin(beta)
192 injectors_[n].properties()->tan1(hole)*cos(beta)
193 + injectors_[n].properties()->tan2(hole)*sin(beta)
197 // set the direction of injection by adding the normal vector
198 vector dir = dcorr*injectors_[n].properties()->direction(hole, t) + normal;
199 // normailse direction vector
206 Foam::scalar Foam::definedHollowConeInjector::velocity
212 const injectorType& it = sm_.injectors()[i].properties();
213 if (it.pressureIndependentVelocity())
215 return it.getTableValue(it.velocityProfile(), time);
219 scalar Pref = sm_.ambientPressure();
220 scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
221 scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
222 scalar dp = max(0.0, Pinj - Pref);
223 return sqrt(2.0*dp/rho);
229 Foam::definedHollowConeInjector::averageVelocity(const label i) const
231 const injectorType& it = sm_.injectors()[i].properties();
232 scalar dt = it.teoi() - it.tsoi();
233 return it.integrateTable(it.velocityProfile())/dt;
237 // ************************************************************************* //