FreeFOAM The Cross-Platform CFD Toolkit
definedHollowCone.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "definedHollowCone.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(definedHollowConeInjector, 0);
38 
40 (
41  injectorModel,
42  definedHollowConeInjector,
43  dictionary
44 );
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 // Construct from components
51 (
52  const dictionary& dict,
53  spray& sm
54 )
55 :
56  injectorModel(dict, sm),
57  definedHollowConeDict_(dict.subDict(typeName + "Coeffs")),
58  dropletPDF_
59  (
61  (
62  definedHollowConeDict_.subDict("dropletPDF"),
63  sm.rndGen()
64  )
65  ),
66  innerConeAngle_(definedHollowConeDict_.lookup("innerConeAngle")),
67  outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle"))
68 {
69 
70  // convert CA to real time - inner cone angle
71  forAll(innerConeAngle_, i)
72  {
73  innerConeAngle_[i][0] = sm.runTime().userTimeToTime(innerConeAngle_[i][0]);
74  }
75  // convert CA to real time - outer cone angle
76  forAll(outerConeAngle_, i)
77  {
78  outerConeAngle_[i][0] = sm.runTime().userTimeToTime(outerConeAngle_[i][0]);
79  }
80 
81  // check number of injectors
82  if (sm.injectors().size() != 1)
83  {
84  Info << "Warning!!!\n"
85  << "definedHollowConeInjector::definedHollowConeInjector"
86  << "(const dictionary& dict, spray& sm)\n"
87  << "Same inner/outer cone angle profiles applied to each injector"
88  << endl;
89  }
90 
91  // check number of entries in innerConeAngle list
92  if (innerConeAngle_.empty())
93  {
94  FatalError << "definedHollowConeInjector::definedHollowConeInjector"
95  << "(const dictionary& dict, spray& sm)\n"
96  << "Number of entries in innerConeAngle must be greater than zero"
97  << abort(FatalError);
98  }
99 
100  // check number of entries in outerConeAngle list
101  if (outerConeAngle_.empty())
102  {
103  FatalError << "definedHollowConeInjector::definedHollowConeInjector"
104  << "(const dictionary& dict, spray& sm)\n"
105  << "Number of entries in outerConeAngle must be greater than zero"
106  << abort(FatalError);
107  }
108 
109  scalar referencePressure = sm.p().average().value();
110  // correct pressureProfile
111  forAll(sm.injectors(), i)
112  {
113  sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
114  }
115 
116 }
117 
118 
119 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
120 
122 {}
123 
124 
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 
128 (
129  const label n,
130  const scalar t
131 ) const
132 {
133  // swallow function arguments - not used
134  // return value sampled from PDF
135  return dropletPDF_->sample();
136 }
137 
138 
140 (
141  const label n,
142  const label hole,
143  const scalar t,
144  const scalar d
145 ) const
146 {
147 
148  const injectorType& it = injectors_[n].properties();
149 
150  // interpolate to find inner and outer angles at time, t
151  scalar angleInner = it.getTableValue(innerConeAngle_, t);
152  scalar angleOuter = it.getTableValue(outerConeAngle_, t);
153 
154  // use random number to generate angle between inner/outer cone angles
155  scalar angle = angleInner + rndGen_.scalar01()*(angleOuter-angleInner);
156 
157  scalar alpha = sin(angle*mathematicalConstant::pi/360.0);
158  scalar dcorr = cos(angle*mathematicalConstant::pi/360.0);
159  scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
160 
161  // randomly distributed vector normal to the injection vector
163 
164  if (sm_.twoD())
165  {
166  scalar reduce = 0.01;
167  // correct beta if this is a 2D run
168  // map it onto the 'angleOfWedge'
169 
170  beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
171  beta += reduce*sm_.angleOfWedge();
172  normal = alpha*
173  (
174  sm_.axisOfWedge()*cos(beta) +
175  sm_.axisOfWedgeNormal()*sin(beta)
176  );
177  }
178  else
179  {
180  normal = alpha*
181  (
182  injectors_[n].properties()->tan1(hole)*cos(beta) +
183  injectors_[n].properties()->tan2(hole)*sin(beta)
184  );
185  }
186 
187  // set the direction of injection by adding the normal vector
188  vector dir = dcorr*injectors_[n].properties()->direction(hole, t) + normal;
189  // normailse direction vector
190  dir /= mag(dir);
191 
192  return dir;
193 
194 }
195 
197 (
198  const label i,
199  const scalar time
200 ) const
201 {
202  const injectorType& it = sm_.injectors()[i].properties();
204  {
205  return it.getTableValue(it.velocityProfile(), time);
206  }
207  else
208  {
209  scalar Pref = sm_.ambientPressure();
210  scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
211  scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
212  scalar dp = max(0.0, Pinj - Pref);
213  return sqrt(2.0*dp/rho);
214  }
215 }
216 
218 (
219  const label i
220 ) const
221 {
222  const injectorType& it = sm_.injectors()[i].properties();
223  scalar dt = it.teoi() - it.tsoi();
224  return it.integrateTable(it.velocityProfile())/dt;
225 }
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace Foam
230 
231 // ************************ vim: set sw=4 sts=4 et: ************************ //