FreeFOAM The Cross-Platform CFD Toolkit
sprayInject.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 "spray.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
40 {
41  scalar time = runTime_.value();
42  scalar time0 = time0_;
43 
44  // Inject the parcels for each injector sequentially
45  forAll(injectors_, i)
46  {
47  autoPtr<injectorType>& it = injectors()[i].properties();
48  if (!it->pressureIndependentVelocity())
49  {
50  scalar referencePressure = p().average().value();
51  it->correctProfiles(fuels(), referencePressure);
52  }
53 
54  const label nHoles = it->nHoles();
55 
56  // parcels have the same mass during a timestep
57  scalar mass = it->mass(time0, time, twoD_, angleOfWedge_);
58 
59  label Np = it->nParcelsToInject(time0, time);
60 
61  if (mass > 0)
62  {
63  Np = max(1, Np);
64  scalar mp = mass/Np/nHoles;
65 
66  // constT is only larger than zero for the first
67  // part of the injection
68  scalar constT = max(0.0, it->tsoi() - time0);
69 
70  // deltaT is the duration of injection during this timestep
71  scalar deltaT = min
72  (
73  runTime_.deltaT().value(),
74  min
75  (
76  time - it->tsoi(),
77  it->teoi() - time0
78  )
79  );
80 
81  for(label j=0; j<Np; j++)
82  {
83  // calculate the time of injection for parcel 'j'
84  scalar toi = time0 + constT + deltaT*j/scalar(Np);
85 
86  for(label n=0; n<nHoles; n++)
87  {
88 
89  // calculate the velocity of the injected parcel
90  vector injectionPosition = it->position
91  (
92  n,
93  toi,
94  twoD_,
95  angleOfWedge_,
96  axisOfSymmetry_,
97  axisOfWedge_,
98  axisOfWedgeNormal_,
99  rndGen_
100  );
101 
102  scalar diameter = injection().d0(i, toi);
103  vector direction =
104  injection().direction(i, n, toi, diameter);
105  vector U = injection().velocity(i, toi)*direction;
106 
107  scalar symComponent = direction & axisOfSymmetry_;
108  vector normal = direction - symComponent*axisOfSymmetry_;
109  normal /= mag(normal);
110 
111  // should be set from dict or model
112  scalar deviation = breakup().y0();
113  scalar ddev = breakup().yDot0();
114 
115  label injectorCell = mesh_.findCell(injectionPosition);
116 
117 # include "findInjectorCell.H"
118 
119  if (injectorCell >= 0)
120  {
121  scalar liquidCore = 1.0;
122 
123  // construct the parcel that is to be injected
124 
125  parcel* pPtr = new parcel
126  (
127  *this,
128  injectionPosition,
129  injectorCell,
130  normal,
131  diameter,
132  it->T(toi),
133  mp,
134  deviation,
135  ddev,
136  0.0,
137  0.0,
138  0.0,
139  liquidCore,
140  scalar(i),
141  U,
142  vector::zero,
143  it->X(),
144  fuels_->components()
145  );
146 
147  injectedLiquidKE_ += 0.5*pPtr->m()*magSqr(U);
148 
149  scalar dt = time - toi;
150 
151  pPtr->stepFraction() =
152  (runTime_.deltaT().value() - dt)
153  /runTime_.deltaT().value();
154 
155  bool keepParcel = pPtr->move(*this);
156 
157  if (keepParcel)
158  {
159  addParticle(pPtr);
160  }
161  else
162  {
163  delete pPtr;
164  }
165  } // if (injectorCell....
166  } // for(label n=0...
167  } // for(label j=0....
168  } // if (mass>0)...
169  } // forAll(injectors)...
170 
171  time0_ = time;
172 }
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // ************************ vim: set sw=4 sts=4 et: ************************ //