BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / definedHollowCone / definedHollowCone.C
blob64cf6ce0ae3fb93184623560176b41946df22ecd
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 "definedHollowCone.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(definedHollowConeInjector, 0);
36     addToRunTimeSelectionTable
37     (
38         injectorModel,
39         definedHollowConeInjector,
40         dictionary
41     );
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::definedHollowConeInjector::definedHollowConeInjector
49     const dictionary& dict,
50     spray& sm
53     injectorModel(dict, sm),
54     definedHollowConeDict_(dict.subDict(typeName + "Coeffs")),
55     sizeDistribution_
56     (
57         distributionModels::distributionModel::New
58         (
59             definedHollowConeDict_.subDict("sizeDistribution"),
60             sm.rndGen()
61         )
62     ),
63     innerConeAngle_(definedHollowConeDict_.lookup("innerConeAngle")),
64     outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle"))
66     // convert CA to real time - inner cone angle
67     forAll(innerConeAngle_, i)
68     {
69         innerConeAngle_[i][0] =
70             sm.runTime().userTimeToTime(innerConeAngle_[i][0]);
71     }
72     // convert CA to real time - outer cone angle
73     forAll(outerConeAngle_, i)
74     {
75         outerConeAngle_[i][0] =
76             sm.runTime().userTimeToTime(outerConeAngle_[i][0]);
77     }
79     // check number of injectors
80     if (sm.injectors().size() != 1)
81     {
82         WarningIn
83         (
84             "definedHollowConeInjector::definedHollowConeInjector"
85             "(const dictionary& dict, spray& sm)"
86         )   << "Same inner/outer cone angle profiles applied to each injector"
87             << endl;
88     }
90     // check number of entries in innerConeAngle list
91     if (innerConeAngle_.empty())
92     {
93         FatalErrorIn
94         (
95             "definedHollowConeInjector::definedHollowConeInjector"
96             "(const dictionary& dict, spray& sm)"
97         )   << "Number of entries in innerConeAngle must be greater than zero"
98             << abort(FatalError);
99     }
101     // check number of entries in outerConeAngle list
102     if (outerConeAngle_.empty())
103     {
104         FatalErrorIn
105         (
106             "definedHollowConeInjector::definedHollowConeInjector"
107             "(const dictionary& dict, spray& sm)"
108         )   << "Number of entries in outerConeAngle must be greater than zero"
109             << abort(FatalError);
110     }
112     scalar referencePressure = sm.p().average().value();
113     // correct pressureProfile
114     forAll(sm.injectors(), i)
115     {
116         sm.injectors()[i].properties()->correctProfiles
117         (
118             sm.fuels(),
119             referencePressure
120         );
121     }
125 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
127 Foam::definedHollowConeInjector::~definedHollowConeInjector()
131 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
133 Foam::scalar Foam::definedHollowConeInjector::d0
135     const label n,
136     const scalar t
137 ) const
139     // swallow function arguments - not used
140     // return value sampled from distribution model
141     return sizeDistribution_->sample();
145 Foam::vector Foam::definedHollowConeInjector::direction
147     const label n,
148     const label hole,
149     const scalar t,
150     const scalar d
151 ) const
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;
169     if (sm_.twoD())
170     {
171         scalar reduce = 0.01;
172         // correct beta if this is a 2D run
173         // map it onto the 'angleOfWedge'
175         beta *=
176             (1.0 - 2.0*reduce)
177            *sm_.angleOfWedge()
178           /(constant::mathematical::twoPi);
179         beta += reduce*sm_.angleOfWedge();
180         normal =
181             alpha
182            *(
183                 sm_.axisOfWedge()*cos(beta)
184               + sm_.axisOfWedgeNormal()*sin(beta)
185             );
186     }
187     else
188     {
189         normal =
190             alpha
191            *(
192                 injectors_[n].properties()->tan1(hole)*cos(beta)
193               + injectors_[n].properties()->tan2(hole)*sin(beta)
194             );
195     }
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
200     dir /= mag(dir);
202     return dir;
206 Foam::scalar Foam::definedHollowConeInjector::velocity
208     const label i,
209     const scalar time
210 ) const
212     const injectorType& it = sm_.injectors()[i].properties();
213     if (it.pressureIndependentVelocity())
214     {
215         return it.getTableValue(it.velocityProfile(), time);
216     }
217     else
218     {
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);
224     }
228 Foam::scalar
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 // ************************************************************************* //