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 "hollowCone.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(hollowConeInjector, 0);
36 addToRunTimeSelectionTable
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::hollowConeInjector::hollowConeInjector
49 const dictionary& dict,
53 injectorModel(dict, sm),
54 hollowConeDict_(dict.subDict(typeName + "Coeffs")),
57 distributionModels::distributionModel::New
59 hollowConeDict_.subDict("sizeDistribution"),
63 innerAngle_(hollowConeDict_.lookup("innerConeAngle")),
64 outerAngle_(hollowConeDict_.lookup("outerConeAngle"))
67 if (sm.injectors().size() != innerAngle_.size())
71 "hollowConeInjector::hollowConeInjector"
72 "(const dictionary& dict, spray& sm)"
73 ) << "Wrong number of entries in innerAngle"
77 if (sm.injectors().size() != outerAngle_.size())
81 "hollowConeInjector::hollowConeInjector"
82 "(const dictionary& dict, spray& sm)"
83 ) << "Wrong number of entries in outerAngle"
87 scalar referencePressure = sm.ambientPressure();
89 // correct velocityProfile
90 forAll(sm.injectors(), i)
92 sm.injectors()[i].properties()->correctProfiles
101 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
103 Foam::hollowConeInjector::~hollowConeInjector()
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 Foam::scalar Foam::hollowConeInjector::d0
115 return sizeDistribution_->sample();
119 Foam::vector Foam::hollowConeInjector::direction
127 scalar angle = rndGen_.position<scalar>(innerAngle_[n], outerAngle_[n]);
128 scalar alpha = sin(angle*constant::mathematical::pi/360.0);
129 scalar dcorr = cos(angle*constant::mathematical::pi/360.0);
130 scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
132 // randomly distributed vector normal to the injection vector
133 vector normal = vector::zero;
137 scalar reduce = 0.01;
138 // correct beta if this is a 2D run
139 // map it onto the 'angleOfWedge'
144 /(constant::mathematical::twoPi);
145 beta += reduce*sm_.angleOfWedge();
149 sm_.axisOfWedge()*cos(beta)
150 + sm_.axisOfWedgeNormal()*sin(beta)
158 injectors_[n].properties()->tan1(hole)*cos(beta)
159 + injectors_[n].properties()->tan2(hole)*sin(beta)
163 // set the direction of injection by adding the normal vector
165 dcorr*injectors_[n].properties()->direction(hole, time) + normal;
172 Foam::scalar Foam::hollowConeInjector::velocity
178 const injectorType& it = sm_.injectors()[i].properties();
179 if (it.pressureIndependentVelocity())
181 return it.getTableValue(it.velocityProfile(), time);
185 scalar Pref = sm_.ambientPressure();
186 scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
187 scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
188 scalar dp = max(0.0, Pinj - Pref);
189 return sqrt(2.0*dp/rho);
194 Foam::scalar Foam::hollowConeInjector::averageVelocity(const label i) const
196 const injectorType& it = sm_.injectors()[i].properties();
197 scalar dt = it.teoi() - it.tsoi();
198 return it.integrateTable(it.velocityProfile())/dt;
202 // ************************************************************************* //