BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / pressureSwirl / pressureSwirlInjector.C
blob3bae836f2cdde14708d001b858c4f118fba82376
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "pressureSwirlInjector.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(pressureSwirlInjector, 0);
36     addToRunTimeSelectionTable
37     (
38         injectorModel,
39         pressureSwirlInjector,
40         dictionary
41     );
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::pressureSwirlInjector::pressureSwirlInjector
49     const dictionary& dict,
50     spray& sm
53     injectorModel(dict, sm),
54     pressureSwirlInjectorDict_(dict.subDict(typeName + "Coeffs")),
56     coneAngle_(pressureSwirlInjectorDict_.lookup("ConeAngle")),
57     coneInterval_(pressureSwirlInjectorDict_.lookup("ConeInterval")),
58     maxKv_(pressureSwirlInjectorDict_.lookup("maxKv")),
60     angle_(0.0)
63     if (sm.injectors().size() != coneAngle_.size())
64     {
65         FatalErrorIn
66         (
67             "pressureSwirlInjector::pressureSwirlInjector"
68             "(const dictionary& dict, spray& sm)"
69         )   << "Wrong number of entries in innerAngle" << nl
70             << abort(FatalError);
71     }
73     scalar referencePressure = sm.p().average().value();
75     // correct velocityProfile
76     forAll(sm.injectors(), i)
77     {
78         sm.injectors()[i].properties()->correctProfiles
79         (
80             sm.fuels(),
81             referencePressure
82         );
83     }
87 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
89 Foam::pressureSwirlInjector::~pressureSwirlInjector()
93 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
95 Foam::scalar Foam::pressureSwirlInjector::d0
97     const label n,
98     const scalar t
99 ) const
101     const injectorType& it = injectors_[n].properties();
103     scalar c = rndGen_.sample01<scalar>();
104     angle_ = coneAngle_[n] + 2.0*coneInterval_[n]*(0.5 - c);
106     angle_ *= constant::mathematical::pi/360.0;
108     scalar injectedMassFlow = it.massFlowRate(t);
110     scalar cosAngle = cos(angle_);
112     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), it.T(t), it.X());
113     scalar injectorDiameter = it.d();
115     scalar deltaPressure = deltaPressureInj(t,n);
116     scalar kV = kv(n, injectedMassFlow, deltaPressure);
117     scalar v = kV*sqrt(2.0*deltaPressure/rhoFuel);
119     u_ = v*cosAngle;
121     scalar A = injectedMassFlow/(constant::mathematical::pi*rhoFuel*u_);
123     return (injectorDiameter-sqrt(pow(injectorDiameter,2)-4.0*A))/2.0;
127 Foam::vector Foam::pressureSwirlInjector::direction
129     const label n,
130     const label hole,
131     const scalar time,
132     const scalar d
133 ) const
135     scalar alpha = sin(angle_);
136     scalar dcorr = cos(angle_);
137     scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
139     // randomly distributed vector normal to the injection vector
140     vector normal = vector::zero;
142     if (sm_.twoD())
143     {
144         scalar reduce = 0.01;
145         // correct beta if this is a 2D run
146         // map it onto the 'angleOfWedge'
148         beta *=
149             (1.0 - 2.0*reduce)
150            *sm_.angleOfWedge()
151           /(constant::mathematical::twoPi);
152         beta += reduce*sm_.angleOfWedge();
153         normal =
154             alpha
155            *(
156                 sm_.axisOfWedge()*cos(beta)
157               + sm_.axisOfWedgeNormal()*sin(beta)
158             );
159     }
160     else
161     {
162         normal =
163             alpha
164            *(
165                 injectors_[n].properties()->tan1(hole)*cos(beta)
166               + injectors_[n].properties()->tan2(hole)*sin(beta)
167             );
168     }
170     // set the direction of injection by adding the normal vector
171     vector dir =
172         dcorr*injectors_[n].properties()->direction(hole, time) + normal;
173     dir /= mag(dir);
175     return dir;
179 Foam::scalar Foam::pressureSwirlInjector::velocity
181     const label i,
182     const scalar time
183 ) const
185     return u_*sqrt(1.0 + pow(tan(angle_),2.0));
189 Foam::scalar Foam::pressureSwirlInjector::averageVelocity(const label i) const
191     const injectorType& it = sm_.injectors()[i].properties();
193     scalar dt = it.teoi() - it.tsoi();
195     scalar injectedMassFlow = it.mass()/(it.teoi()-it.tsoi());
197     scalar injectionPressure = averagePressure(i);
199     scalar Tav = it.integrateTable(it.T())/dt;
200     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
202     scalar kV = kv(i, injectedMassFlow, injectionPressure);
204     return  kV*sqrt(2.0*(injectionPressure-sm_.ambientPressure())/rhoFuel);
208 Foam::scalar Foam::pressureSwirlInjector::kv
210     const label inj,
211     const scalar massFlow,
212     const scalar dPressure
213 ) const
215     const injectorType& it = injectors_[inj].properties();
217     scalar coneAngle = coneAngle_[inj];
219     coneAngle *= constant::mathematical::pi/360.0;
221     scalar cosAngle = cos(coneAngle);
222     scalar Tav = it.integrateTable(it.T())/(it.teoi()-it.tsoi());
224     scalar rhoFuel = sm_.fuels().rho(sm_.ambientPressure(), Tav, it.X());
225     scalar injectorDiameter = it.d();
227     scalar kv = max
228     (
229         maxKv_[inj],
230         4.0*massFlow
231        *sqrt(rhoFuel/2.0/dPressure)
232        /(constant::mathematical::pi*sqr(injectorDiameter)*rhoFuel*cosAngle)
233     );
235     return min(1.0, kv);
239 Foam::scalar Foam::pressureSwirlInjector::deltaPressureInj
241     const scalar time,
242     const label inj
243 ) const
245     return
246         injectors_[inj].properties()->injectionPressure(time)
247       - sm_.ambientPressure();
251 Foam::scalar Foam::pressureSwirlInjector::averagePressure(const label inj) const
254     const injectorType& it = sm_.injectors()[inj].properties();
256     scalar dt = it.teoi() - it.tsoi();
257     return it.integrateTable(it.injectionPressureProfile())/dt;
261 // ************************************************************************* //