BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spraySubModels / injectorModel / Chomiak / Chomiak.C
blobf315ee5bd0fc5f0ae7147499a2e0f02e10cb529b
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 "Chomiak.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(ChomiakInjector, 0);
36     addToRunTimeSelectionTable
37     (
38         injectorModel,
39         ChomiakInjector,
40         dictionary
41     );
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::ChomiakInjector::ChomiakInjector
49     const dictionary& dict,
50     spray& sm
53     injectorModel(dict, sm),
54     ChomiakDict_(dict.subDict(typeName + "Coeffs")),
55     sizeDistribution_
56     (
57         distributionModels::distributionModel::New
58         (
59             ChomiakDict_.subDict("sizeDistribution"),
60             sm.rndGen()
61         )
62     ),
63     maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle"))
66     if (sm.injectors().size() != maxSprayAngle_.size())
67     {
68         FatalError
69             << "ChomiakInjector::ChomiakInjector"
70             << "(const dictionary& dict, spray& sm)\n"
71             << "Wrong number of entries in maxSprayAngle"
72             << abort(FatalError);
73     }
75     scalar referencePressure = sm.p().average().value();
77     // correct velocityProfile
78     forAll(sm.injectors(), i)
79     {
80         sm.injectors()[i].properties()->correctProfiles
81         (
82             sm.fuels(),
83             referencePressure
84         );
85     }
90 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
92 Foam::ChomiakInjector::~ChomiakInjector()
96 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
98 Foam::scalar Foam::ChomiakInjector::d0
100     const label,
101     const scalar
102 ) const
104     return sizeDistribution_->sample();
108 Foam::vector Foam::ChomiakInjector::direction
110     const label n,
111     const label hole,
112     const scalar time,
113     const scalar d
114 ) const
116     scalar dMin = sizeDistribution_->minValue();
117     scalar dMax = sizeDistribution_->maxValue();
119     scalar angle =
120         (d - dMax)*maxSprayAngle_[n]
121        /(dMin - dMax)
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;
131     if (sm_.twoD())
132     {
133         scalar reduce = 0.01;
134         // correct beta if this is a 2D run
135         // map it onto the 'angleOfWedge'
136         beta *=
137             (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/constant::mathematical::pi;
138         beta += reduce*sm_.angleOfWedge();
140         normal =
141             alpha
142            *(
143                 sm_.axisOfWedge()*cos(beta)
144               + sm_.axisOfWedgeNormal()*sin(beta)
145             );
147     }
148     else
149     {
150         normal =
151             alpha
152            *(
153                 injectors_[n].properties()->tan1(hole)*cos(beta)
154               + injectors_[n].properties()->tan2(hole)*sin(beta)
155             );
156     }
158     // set the direction of injection by adding the normal vector
159     vector dir =
160         dcorr*injectors_[n].properties()->direction(hole, time) + normal;
161     dir /= mag(dir);
163     return dir;
167 Foam::scalar Foam::ChomiakInjector::velocity
169     const label i,
170     const scalar time
171 ) const
173     const injectorType& it = sm_.injectors()[i].properties();
174     if (it.pressureIndependentVelocity())
175     {
176         return it.getTableValue(it.velocityProfile(), time);
177     }
178     else
179     {
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);
185     }
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 // ************************************************************************* //