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 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(ChomiakInjector, 0);
36 addToRunTimeSelectionTable
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::ChomiakInjector::ChomiakInjector
49 const dictionary& dict,
53 injectorModel(dict, sm),
54 ChomiakDict_(dict.subDict(typeName + "Coeffs")),
57 distributionModels::distributionModel::New
59 ChomiakDict_.subDict("sizeDistribution"),
63 maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle"))
66 if (sm.injectors().size() != maxSprayAngle_.size())
69 << "ChomiakInjector::ChomiakInjector"
70 << "(const dictionary& dict, spray& sm)\n"
71 << "Wrong number of entries in maxSprayAngle"
75 scalar referencePressure = sm.p().average().value();
77 // correct velocityProfile
78 forAll(sm.injectors(), i)
80 sm.injectors()[i].properties()->correctProfiles
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 Foam::ChomiakInjector::~ChomiakInjector()
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 Foam::scalar Foam::ChomiakInjector::d0
104 return sizeDistribution_->sample();
108 Foam::vector Foam::ChomiakInjector::direction
116 scalar dMin = sizeDistribution_->minValue();
117 scalar dMax = sizeDistribution_->maxValue();
120 (d - dMax)*maxSprayAngle_[n]
122 *constant::mathematical::pi/360.0;
123 scalar alpha = sin(angle);
124 scalar dcorr = cos(angle);
126 scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
128 // randomly distributed vector normal to the injection vector
129 vector normal = vector::zero;
133 scalar reduce = 0.01;
134 // correct beta if this is a 2D run
135 // map it onto the 'angleOfWedge'
137 (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/constant::mathematical::pi;
138 beta += reduce*sm_.angleOfWedge();
143 sm_.axisOfWedge()*cos(beta)
144 + sm_.axisOfWedgeNormal()*sin(beta)
153 injectors_[n].properties()->tan1(hole)*cos(beta)
154 + injectors_[n].properties()->tan2(hole)*sin(beta)
158 // set the direction of injection by adding the normal vector
160 dcorr*injectors_[n].properties()->direction(hole, time) + normal;
167 Foam::scalar Foam::ChomiakInjector::velocity
173 const injectorType& it = sm_.injectors()[i].properties();
174 if (it.pressureIndependentVelocity())
176 return it.getTableValue(it.velocityProfile(), time);
180 scalar Pref = sm_.ambientPressure();
181 scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
182 scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
183 scalar dp = max(0.0, Pinj - Pref);
184 return sqrt(2.0*dp/rho);
189 Foam::scalar Foam::ChomiakInjector::averageVelocity(const label i) const
191 const injectorType& it = sm_.injectors()[i].properties();
192 scalar dt = it.teoi() - it.tsoi();
193 return it.integrateTable(it.velocityProfile())/dt;
197 // ************************************************************************* //