BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / hollowCone / hollowCone.C
blob35bf09c98115d877acdb47ffbf927384acf15715
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 "hollowCone.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(hollowConeInjector, 0);
36     addToRunTimeSelectionTable
37     (
38         injectorModel,
39         hollowConeInjector,
40         dictionary
41     );
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::hollowConeInjector::hollowConeInjector
49     const dictionary& dict,
50     spray& sm
53     injectorModel(dict, sm),
54     hollowConeDict_(dict.subDict(typeName + "Coeffs")),
55     sizeDistribution_
56     (
57         distributionModels::distributionModel::New
58         (
59             hollowConeDict_.subDict("sizeDistribution"),
60             sm.rndGen()
61         )
62     ),
63     innerAngle_(hollowConeDict_.lookup("innerConeAngle")),
64     outerAngle_(hollowConeDict_.lookup("outerConeAngle"))
67     if (sm.injectors().size() != innerAngle_.size())
68     {
69         FatalErrorIn
70         (
71             "hollowConeInjector::hollowConeInjector"
72             "(const dictionary& dict, spray& sm)"
73         )   << "Wrong number of entries in innerAngle"
74             << abort(FatalError);
75     }
77     if (sm.injectors().size() != outerAngle_.size())
78     {
79         FatalErrorIn
80         (
81             "hollowConeInjector::hollowConeInjector"
82             "(const dictionary& dict, spray& sm)"
83         )   << "Wrong number of entries in outerAngle"
84             << abort(FatalError);
85     }
87     scalar referencePressure = sm.ambientPressure();
89     // correct velocityProfile
90     forAll(sm.injectors(), i)
91     {
92         sm.injectors()[i].properties()->correctProfiles
93         (
94             sm.fuels(),
95             referencePressure
96         );
97     }
101 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
103 Foam::hollowConeInjector::~hollowConeInjector()
107 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
109 Foam::scalar Foam::hollowConeInjector::d0
111     const label,
112     const scalar
113 ) const
115     return sizeDistribution_->sample();
119 Foam::vector Foam::hollowConeInjector::direction
121     const label n,
122     const label hole,
123     const scalar time,
124     const scalar d
125 ) const
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;
135     if (sm_.twoD())
136     {
137         scalar reduce = 0.01;
138         // correct beta if this is a 2D run
139         // map it onto the 'angleOfWedge'
141         beta *=
142             (1.0 - 2.0*reduce)
143            *sm_.angleOfWedge()
144            /(constant::mathematical::twoPi);
145         beta += reduce*sm_.angleOfWedge();
146         normal =
147             alpha
148            *(
149                 sm_.axisOfWedge()*cos(beta)
150               + sm_.axisOfWedgeNormal()*sin(beta)
151             );
152     }
153     else
154     {
155         normal =
156             alpha
157            *(
158                 injectors_[n].properties()->tan1(hole)*cos(beta)
159               + injectors_[n].properties()->tan2(hole)*sin(beta)
160             );
161     }
163     // set the direction of injection by adding the normal vector
164     vector dir =
165         dcorr*injectors_[n].properties()->direction(hole, time) + normal;
166     dir /= mag(dir);
168     return dir;
172 Foam::scalar Foam::hollowConeInjector::velocity
174     const label i,
175     const scalar time
176 ) const
178     const injectorType& it = sm_.injectors()[i].properties();
179     if (it.pressureIndependentVelocity())
180     {
181         return it.getTableValue(it.velocityProfile(), time);
182     }
183     else
184     {
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);
190     }
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 // ************************************************************************* //