Merge /u/wyldckat/foam-extend32/ branch master into master
[foam-extend-3.2.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / Chomiak / Chomiak.C
blob1008b82c7dccdf72f0cc9a7e0a3ad4132709130f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "Chomiak.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(ChomiakInjector, 0);
39 addToRunTimeSelectionTable
41     injectorModel,
42     ChomiakInjector,
43     dictionary
47 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
49 // Construct from components
50 ChomiakInjector::ChomiakInjector
52     const dictionary& dict,
53     spray& sm
56     injectorModel(dict, sm),
57     ChomiakDict_(dict.subDict(typeName + "Coeffs")),
58     dropletPDF_
59     (
60         pdf::New
61         (
62             ChomiakDict_.subDict("dropletPDF"),
63             sm.rndGen()
64         )
65     ),
66     maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle"))
69     if (sm.injectors().size() != maxSprayAngle_.size())
70     {
71         FatalError << "ChomiakInjector::ChomiakInjector"
72             << "(const dictionary& dict, spray& sm)\n"
73             << "Wrong number of entries in maxSprayAngle"
74             << abort(FatalError);
75     }
77     scalar referencePressure = sm.p().average().value();
79     // correct velocityProfile
80     forAll(sm.injectors(), i)
81     {
82         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
83     }
88 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
90 ChomiakInjector::~ChomiakInjector()
94 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
96 scalar ChomiakInjector::d0
98     const label,
99     const scalar
100 ) const
102     return dropletPDF_->sample();
106 vector ChomiakInjector::direction
108     const label n,
109     const label hole,
110     const scalar time,
111     const scalar d
112 ) const
114     scalar dMin = dropletPDF_->minValue();
115     scalar dMax = dropletPDF_->maxValue();
117     scalar angle = (d-dMax)*maxSprayAngle_[n]/(dMin-dMax)*mathematicalConstant::pi/360.0;
118     scalar alpha = sin(angle);
119     scalar dcorr = cos(angle);
121     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
123     // randomly distributed vector normal to the injection vector
124     vector normal = vector::zero;
126     if (sm_.twoD())
127     {
128         scalar reduce = 0.01;
129         // correct beta if this is a 2D run
130         // map it onto the 'angleOfWedge'
131         beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
132         beta += reduce*sm_.angleOfWedge();
134         normal = alpha*
135         (
136             sm_.axisOfWedge()*cos(beta) +
137             sm_.axisOfWedgeNormal()*sin(beta)
138         );
140     }
141     else
142     {
143         normal = alpha*
144         (
145             injectors_[n].properties()->tan1(hole)*cos(beta) +
146             injectors_[n].properties()->tan2(hole)*sin(beta)
147         );
148     }
150     // set the direction of injection by adding the normal vector
151     vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
152     dir /= mag(dir);
154     return dir;
158 scalar ChomiakInjector::velocity
160     const label i,
161     const scalar time
162 ) const
164     const injectorType& it = sm_.injectors()[i].properties();
165     if (it.pressureIndependentVelocity())
166     {
167         return it.getTableValue(it.velocityProfile(), time);
168     }
169     else
170     {
171         scalar Pref = sm_.ambientPressure();
172         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
173         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
174         scalar dp = max(0.0, Pinj - Pref);
175         return sqrt(2.0*dp/rho);
176     }
179 scalar ChomiakInjector::averageVelocity
181     const label i
182 ) const
184     const injectorType& it = sm_.injectors()[i].properties();
185     scalar dt = it.teoi() - it.tsoi();
186     return it.integrateTable(it.velocityProfile())/dt;
189 } // End namespace Foam
191 // ************************************************************************* //