FreeFOAM The Cross-Platform CFD Toolkit
hollowCone.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 "hollowCone.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(hollowConeInjector, 0);
38 
40 (
41  injectorModel,
42  hollowConeInjector,
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  hollowConeDict_(dict.subDict(typeName + "Coeffs")),
58  dropletPDF_
59  (
61  (
62  hollowConeDict_.subDict("dropletPDF"),
63  sm.rndGen()
64  )
65  ),
66  innerAngle_(hollowConeDict_.lookup("innerConeAngle")),
67  outerAngle_(hollowConeDict_.lookup("outerConeAngle"))
68 {
69 
70  if (sm.injectors().size() != innerAngle_.size())
71  {
72  FatalError << "hollowConeInjector::hollowConeInjector"
73  << "(const dictionary& dict, spray& sm)\n"
74  << "Wrong number of entries in innerAngle"
75  << abort(FatalError);
76  }
77 
78  if (sm.injectors().size() != outerAngle_.size())
79  {
80  FatalError << "hollowConeInjector::hollowConeInjector"
81  << "(const dictionary& dict, spray& sm)\n"
82  << "Wrong number of entries in outerAngle"
83  << abort(FatalError);
84  }
85 
86  scalar referencePressure = sm.ambientPressure();
87 
88  // correct velocityProfile
89  forAll(sm.injectors(), i)
90  {
91  sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
92  }
93 
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
98 
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 (
107  const label,
108  const scalar
109 ) const
110 {
111  return dropletPDF_->sample();
112 }
113 
114 
116 (
117  const label n,
118  const label hole,
119  const scalar time,
120  const scalar d
121 ) const
122 {
123  scalar angle = innerAngle_[n] + rndGen_.scalar01()*(outerAngle_[n]-innerAngle_[n]);
124  scalar alpha = sin(angle*mathematicalConstant::pi/360.0);
125  scalar dcorr = cos(angle*mathematicalConstant::pi/360.0);
126  scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
127 
128  // randomly distributed vector normal to the injection vector
130 
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 
137  beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
138  beta += reduce*sm_.angleOfWedge();
139  normal = alpha*
140  (
141  sm_.axisOfWedge()*cos(beta) +
142  sm_.axisOfWedgeNormal()*sin(beta)
143  );
144  }
145  else
146  {
147  normal = alpha*
148  (
149  injectors_[n].properties()->tan1(hole)*cos(beta) +
150  injectors_[n].properties()->tan2(hole)*sin(beta)
151  );
152  }
153 
154  // set the direction of injection by adding the normal vector
155  vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal;
156  dir /= mag(dir);
157 
158  return dir;
159 
160 }
161 
163 (
164  const label i,
165  const scalar time
166 ) const
167 {
168  const injectorType& it = sm_.injectors()[i].properties();
170  {
171  return it.getTableValue(it.velocityProfile(), time);
172  }
173  else
174  {
175  scalar Pref = sm_.ambientPressure();
176  scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
177  scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
178  scalar dp = max(0.0, Pinj - Pref);
179  return sqrt(2.0*dp/rho);
180  }
181 
182 }
183 
185 (
186  const label i
187 ) const
188 {
189  const injectorType& it = sm_.injectors()[i].properties();
190  scalar dt = it.teoi() - it.tsoi();
191  return it.integrateTable(it.velocityProfile())/dt;
192 }
193 
194 } // End namespace Foam
195 
196 // ************************ vim: set sw=4 sts=4 et: ************************ //