FreeFOAM The Cross-Platform CFD Toolkit
spray.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 <dieselSpray/spray.H>
27 
32 #include <dieselSpray/dragModel.H>
36 #include <dieselSpray/wallModel.H>
37 
39 
42 
44 
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
46 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 // Construct from components
52 Foam::spray::spray
53 (
54  const volVectorField& U,
55  const volScalarField& rho,
56  const volScalarField& p,
57  const volScalarField& T,
60  const dictionary&,
61  const dimensionedVector& g,
62  bool readFields
63 )
64 :
65  Cloud<parcel>(U.mesh(), false), // suppress className checking on positions
66  runTime_(U.time()),
67  time0_(runTime_.value()),
68  mesh_(U.mesh()),
69  rndGen_(label(0)),
70  g_(g.value()),
71 
72  U_(U),
73  rho_(rho),
74  p_(p),
75  T_(T),
76 
77  sprayProperties_
78  (
79  IOobject
80  (
81  "sprayProperties",
82  U.time().constant(),
83  U.db(),
84  IOobject::MUST_READ,
85  IOobject::NO_WRITE
86  )
87  ),
88 
89  ambientPressure_(p_.average().value()),
90  ambientTemperature_(T_.average().value()),
91 
92  injectors_
93  (
94  IOobject
95  (
96  "injectorProperties",
97  U.time().constant(),
98  U.db(),
99  IOobject::MUST_READ,
100  IOobject::NO_WRITE
101  ),
102  injector::iNew(U.time())
103  ),
104  atomization_
105  (
106  atomizationModel::New
107  (
108  sprayProperties_,
109  *this
110  )
111  ),
112  drag_
113  (
114  dragModel::New
115  (
116  sprayProperties_
117  )
118  ),
119  evaporation_
120  (
121  evaporationModel::New
122  (
123  sprayProperties_
124  )
125  ),
126  heatTransfer_
127  (
128  heatTransferModel::New
129  (
130  sprayProperties_
131  )
132  ),
133  wall_
134  (
135  wallModel::New
136  (
137  sprayProperties_,
138  U,
139  *this
140  )
141  ),
142  breakupModel_
143  (
144  breakupModel::New
145  (
146  sprayProperties_,
147  *this
148  )
149  ),
150  collisionModel_
151  (
152  collisionModel::New
153  (
154  sprayProperties_,
155  *this,
156  rndGen_
157  )
158  ),
159  dispersionModel_
160  (
161  dispersionModel::New
162  (
163  sprayProperties_,
164  *this
165  )
166  ),
167 
168  fuels_
169  (
170  liquidMixture::New
171  (
172  mesh_.lookupObject<dictionary>("thermophysicalProperties")
173  )
174  ),
175  injectorModel_
176  (
177  injectorModel::New
178  (
179  sprayProperties_,
180  *this
181  )
182  ),
183 
184  subCycles_(readLabel(sprayProperties_.lookup("subCycles"))),
185 
186  gasProperties_(gasProperties),
187  composition_(composition),
188 
189  liquidToGasIndex_(fuels_->components().size(), -1),
190  gasToLiquidIndex_(composition.Y().size(), -1),
191  isLiquidFuel_(composition.Y().size(), false),
192 
193  twoD_(0),
194  axisOfSymmetry_(vector::zero),
195  axisOfWedge_(vector(0,0,0)),
196  axisOfWedgeNormal_(vector(0,0,0)),
197  angleOfWedge_(0.0),
198 
199  interpolationSchemes_(sprayProperties_.subDict("interpolationSchemes")),
200  UInterpolator_(NULL),
201  rhoInterpolator_(NULL),
202  pInterpolator_(NULL),
203  TInterpolator_(NULL),
204 
205  sms_(mesh_.nCells(), vector::zero),
206  shs_(mesh_.nCells(), 0.0),
207  srhos_(fuels_->components().size()),
208 
209  totalInjectedLiquidMass_(0.0),
210  injectedLiquidKE_(0.0)
211 
212 {
213  // create the evaporation source fields
214  forAll(srhos_, i)
215  {
216  srhos_.set(i, new scalarField(mesh_.nCells(), 0.0));
217  }
218 
219  // Write some information about injection parameters
220  forAll(injectors_, i)
221  {
222  const injectorType& it = injectors_[i].properties();
223 
224  scalar v = injection().averageVelocity(i);
225 
226  scalar ip = it.integrateTable(it.injectionPressureProfile());
227  scalar dt = it.teoi() - it.tsoi();
228  Info<< "Average Velocity for injector " << i << ": " << v << " m/s"
229  << ", injection pressure = "
230  << 1.0e-5*ip/dt << " bar"
231  << endl;
232  }
233 
234  // Check if the case is 2D wedge
236  bool symPlaneExist = false;
237  bool wedgeExist = false;
238  label patches[2];
239  label n=0;
240 
241  // check for the type of boundary condition
242  forAll(bMesh, patchi)
243  {
244  if (isA<symmetryPolyPatch>(bMesh[patchi]))
245  {
246  symPlaneExist = true;
247  }
248  else if (isA<wedgePolyPatch>(bMesh[patchi]))
249  {
250  wedgeExist = true;
251  patches[n++] = patchi;
252  }
253  }
254 
255  // if wedge exist we assume that this is a 2D run.
256  twoD_ = wedgeExist;
257 
258  if (twoD_)
259  {
260  if (n<2)
261  {
263  (
264  "spray::spray(const volVectorField& U, "
265  "const volScalarField& rho, const volScalarField& p, "
266  "const volScalarField& T, const combustionMixture& composition,"
267  "const PtrList<gasThermoPhsyics>& gaseousFuelProperties, "
268  "const dictionary& thermophysicalProperties, "
269  "const dimensionedScalar& g)"
270  ) << "spray::(...) only one wedgePolyPatch found. "
271  "Please check you BC-setup."
272  << abort(FatalError);
273  }
274 
275  Info<< "Constructing two dimensional spray injection.";
276 
277  vector v1 = bMesh[patches[0]].faceAreas()[0];
278  vector v2 = bMesh[patches[1]].faceAreas()[0];
279  v1 /= mag(v1);
280  v2 /= mag(v2);
281  axisOfSymmetry_ = v1 ^ v2;
282  axisOfSymmetry_ /= mag(axisOfSymmetry_);
283 
284  // assuming that 'v2' is the 'front' face
285  axisOfWedge_ = axisOfSymmetry_ ^ v2;
286  axisOfWedge_ /= mag(axisOfWedge_);
287 
288  axisOfWedgeNormal_ = axisOfSymmetry_ ^ axisOfWedge_;
289  axisOfWedgeNormal_ /= mag(axisOfWedgeNormal_);
290 
291  scalar arcCos = (v1 & v2)/mag(v1);
292  angleOfWedge_ = mathematicalConstant::pi - acos(arcCos);
293 
294  Info<< "Calculated angle of wedge is "
295  << angleOfWedge_*180/mathematicalConstant::pi << " deg."
296  << endl;
297  }
298  else
299  {
300  if (symPlaneExist)
301  {
302  angleOfWedge_ = mathematicalConstant::pi;
303  Info<< "Constructing 180 deg three dimensional spray injection."
304  << endl;
305  }
306  else
307  {
308  Info<< "Constructing three dimensional spray injection." << endl;
309  }
310 
311  }
312 
313  // find index mapping between liquid indeces and gas indeces
314  label Ns = composition_.Y().size();
315 
316  forAll(fuels_->components(), i)
317  {
318  word liquidName(fuels_->components()[i]);
319 
320  for (label j=0; j<Ns; j++)
321  {
322  word specieName(composition_.Y()[j].name());
323 
324  if (specieName == liquidName)
325  {
326  liquidToGasIndex_[i] = j;
327  gasToLiquidIndex_[j] = i;
328  isLiquidFuel_[j] = true;
329  }
330  }
331  if (liquidToGasIndex_[i] == -1)
332  {
333  Info << "In composition:" << endl;
334  for (label k=0; k<Ns; k++)
335  {
336  word specieName(composition_.Y()[k].name());
337  Info << specieName << endl;
338  }
339 
340  FatalError<<
341  "The liquid component " << liquidName
342  << " does not exist in the species composition.Y() list.\n"
343  << "(Probably not defined in <chem.inp>)"
344  << abort(FatalError);
345  }
346  }
347 
348  if (readFields)
349  {
350  parcel::readFields(*this);
351  }
352 }
353 
354 
355 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
356 
358 {}
359 
360 
361 // ************************ vim: set sw=4 sts=4 et: ************************ //