FreeFOAM The Cross-Platform CFD Toolkit
constInjector.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 "constInjector.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(constInjector, 0);
38 
40 (
41  injectorModel,
42  constInjector,
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  specDict_(dict.subDict(typeName + "Coeffs")),
58  dropletNozzleDiameterRatio_(specDict_.lookup("dropletNozzleDiameterRatio")),
59  sprayAngle_(specDict_.lookup("sprayAngle"))
60 {
61  if (sm.injectors().size() != dropletNozzleDiameterRatio_.size())
62  {
63  FatalError << "constInjector::constInjector"
64  << "(const dictionary& dict, spray& sm)\n"
65  << "Wrong number of entries in dropletNozzleDiameterRatio"
66  << abort(FatalError);
67  }
68 
69  if (sm.injectors().size() != sprayAngle_.size())
70  {
71  FatalError << "constInjector::constInjector"
72  << "(const dictionary& dict, spray& sm)\n"
73  << "Wrong number of entries in sprayAngle"
74  << abort(FatalError);
75  }
76 
77  scalar referencePressure = sm.p().average().value();
78 
79  // correct velocity and pressure profiles
80  forAll(sm.injectors(), i)
81  {
82  sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
83  }
84 
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 scalar constInjector::d0
97 (
98  const label n,
99  const scalar
100 ) const
101 {
102  return injectors_[n].properties()->d()*dropletNozzleDiameterRatio_[n];
103 }
104 
105 
107 (
108  const label n,
109  const label hole,
110  const scalar time,
111  const scalar d
112 ) const
113 {
114 
115  /*
116  randomly distribute parcels in a solid cone
117  with angle = sprayAngle,
118  alpha = radius of the two normal vectors,
119  = maximum sin(sprayAngle/2)
120  beta = angle in the normal plane
121 
122  o / (beta)
123  |\ /
124  | \ /)
125  | \ o-----------> (x-axis)
126  | \
127  v (alpha)
128  */
129 
130  scalar angle = rndGen_.scalar01()*sprayAngle_[n]*mathematicalConstant::pi/360.0;
131  scalar alpha = sin(angle);
132  scalar dcorr = cos(angle);
133 
134  scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
135 
136  // randomly distributed vector normal to the injection vector
138 
139  if (sm_.twoD())
140  {
141  scalar reduce = 0.01;
142  // correct beta if this is a 2D run
143  // map it onto the 'angleOfWedge'
144  beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
145  beta += reduce*sm_.angleOfWedge();
146 
147  normal = alpha*
148  (
149  sm_.axisOfWedge()*cos(beta) +
150  sm_.axisOfWedgeNormal()*sin(beta)
151  );
152 
153  }
154  else
155  {
156  normal = alpha*
157  (
158  injectors_[n].properties()->tan1(hole)*cos(beta) +
159  injectors_[n].properties()->tan2(hole)*sin(beta)
160  );
161  }
162 
163  // set the direction of injection by adding the normal vector
164  vector dir = dcorr*injectors_[n].properties()->direction(n, time) + normal;
165  dir /= mag(dir);
166 
167  return dir;
168 }
169 
171 (
172  const label i,
173  const scalar time
174 ) const
175 {
176  const injectorType& it = sm_.injectors()[i].properties();
178  {
179  return it.getTableValue(it.velocityProfile(), time);
180  }
181  else
182  {
183  scalar Pref = sm_.ambientPressure();
184  scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
185  scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
186  scalar dp = max(0.0, Pinj - Pref);
187  return sqrt(2.0*dp/rho);
188  }
189 }
190 
192 (
193  const label i
194 ) const
195 {
196  const injectorType& it = sm_.injectors()[i].properties();
197  scalar dt = it.teoi() - it.tsoi();
198 
199  return it.integrateTable(it.velocityProfile())/dt;
200 }
201 
202 } // End namespace Foam
203 
204 // ************************ vim: set sw=4 sts=4 et: ************************ //