ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / dieselSpray / spray / sprayInject.C
bloba1f5d666f52faf54eabf8212d6b121e8baf12307
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "spray.H"
27 #include "breakupModel.H"
28 #include "collisionModel.H"
29 #include "dispersionModel.H"
30 #include "injectorModel.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 void Foam::spray::inject()
36     scalar time = runTime_.value();
37     scalar time0 = time0_;
39     parcel::trackingData td(*this);
41     // Inject the parcels for each injector sequentially
42     forAll(injectors_, i)
43     {
44         autoPtr<injectorType>& it = injectors()[i].properties();
45         if (!it->pressureIndependentVelocity())
46         {
47             scalar referencePressure = p().average().value();
48             it->correctProfiles(fuels(), referencePressure);
49         }
51         const label nHoles = it->nHoles();
53         // parcels have the same mass during a timestep
54         scalar mass = it->mass(time0, time, twoD_, angleOfWedge_);
56         label Np = it->nParcelsToInject(time0, time);
58         if (mass > 0)
59         {
60             Np = max(1, Np);
61             scalar mp = mass/Np/nHoles;
63             // constT is only larger than zero for the first
64             // part of the injection
65             scalar constT = max(0.0, it->tsoi() - time0);
67             // deltaT is the duration of injection during this timestep
68             scalar deltaT = min
69             (
70                 runTime_.deltaTValue(),
71                 min
72                 (
73                     time - it->tsoi(),
74                     it->teoi() - time0
75                 )
76             );
78             for (label j=0; j<Np; j++)
79             {
80                 // calculate the time of injection for parcel 'j'
81                 scalar toi = time0 + constT + deltaT*j/scalar(Np);
83                 for (label n=0; n<nHoles; n++)
84                 {
86                     // calculate the velocity of the injected parcel
87                     vector injectionPosition = it->position
88                     (
89                         n,
90                         toi,
91                         twoD_,
92                         angleOfWedge_,
93                         axisOfSymmetry_,
94                         axisOfWedge_,
95                         axisOfWedgeNormal_,
96                         rndGen_
97                     );
99                     scalar diameter = injection().d0(i, toi);
100                     vector direction =
101                         injection().direction(i, n, toi, diameter);
102                     vector U = injection().velocity(i, toi)*direction;
104                     scalar symComponent = direction & axisOfSymmetry_;
105                     vector normal = direction - symComponent*axisOfSymmetry_;
106                     normal /= mag(normal);
108                     // should be set from dict or model
109                     scalar deviation = breakup().y0();
110                     scalar ddev = breakup().yDot0();
112                     label injectorCell = -1;
113                     label injectorTetFaceI = -1;
114                     label injectorTetPtI = -1;
116                     mesh_.findCellFacePt
117                     (
118                         injectionPosition,
119                         injectorCell,
120                         injectorTetFaceI,
121                         injectorTetPtI
122                     );
124                     #include "findInjectorCell.H"
126                     if (injectorCell >= 0)
127                     {
128                         scalar liquidCore = 1.0;
130                         // construct the parcel that is to be injected
132                         parcel* pPtr = new parcel
133                         (
134                             mesh_,
135                             injectionPosition,
136                             injectorCell,
137                             injectorTetFaceI,
138                             injectorTetPtI,
139                             normal,
140                             diameter,
141                             it->T(toi),
142                             mp,
143                             deviation,
144                             ddev,
145                             0.0,
146                             0.0,
147                             0.0,
148                             liquidCore,
149                             scalar(i),
150                             U,
151                             vector::zero,
152                             it->X(),
153                             fuels_->components()
154                         );
156                         injectedLiquidKE_ += 0.5*pPtr->m()*magSqr(U);
158                         scalar dt = time - toi;
160                         pPtr->stepFraction() =
161                             (runTime_.deltaTValue() - dt)
162                            /runTime_.deltaTValue();
164                         bool keepParcel =
165                             pPtr->move(td, runTime_.deltaTValue());
167                         if (keepParcel)
168                         {
169                             addParticle(pPtr);
170                         }
171                         else
172                         {
173                             delete pPtr;
174                         }
175                     } // if (injectorCell....
176                 } // for (label n=0...
177             } // for (label j=0....
178         } // if (mass>0)...
179     } // forAll(injectors)...
181     time0_ = time;
185 // ************************************************************************* //