intersection with triangle plane for miss
[OpenFOAM-1.5.x.git] / src / lagrangian / dieselSpray / spray / sprayInject.C
bloba42acebf58e49297ca457755a180a27d78576e97
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "spray.H"
28 #include "breakupModel.H"
29 #include "collisionModel.H"
30 #include "dispersionModel.H"
31 #include "injectorModel.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 void spray::inject()
42     scalar time = runTime_.value();
43     scalar time0 = time0_;
45     // Inject the parcels for each injector sequentially
46     forAll(injectors_, i)
47     {
48         autoPtr<injectorType>& it = injectors()[i].properties();
49         if (!it->pressureIndependentVelocity())
50         {
51             scalar referencePressure = p().average().value();
52             it->correctProfiles(fuels(), referencePressure);
53         }
55         const label nHoles = it->nHoles();
57         // parcels have the same mass during a timestep
58         scalar mass = it->mass(time0, time, twoD_, angleOfWedge_);
60         label Np = it->nParcelsToInject(time0, time);
62         if (mass > 0)
63         {
64             Np = max(1, Np);
65             scalar mp = mass/Np/nHoles;
66         
67             // constT is only larger than zero for the first 
68             // part of the injection
69             scalar constT = max
70             (
71                 0.0,
72                 it->tsoi() - time0
73             );
75             // deltaT is the duration of injection during this timestep
76             scalar deltaT = min
77             (
78                 runTime_.deltaT().value(),
79                 min
80                 (
81                     time - it->tsoi(),
82                     it->teoi() - time0
83                 )
84             );
86             for(label j=0; j<Np; j++)
87             {
88                 // calculate the time of injection for parcel 'j'
89                 scalar toi = time0 + constT + deltaT*j/scalar(Np);
91                 for(label n=0; n<nHoles; n++)
92                 {
94                     // calculate the velocity of the injected parcel
95                     vector injectionPosition = it->position
96                     (
97                         n,
98                         toi,
99                         twoD_,
100                         angleOfWedge_,
101                         axisOfSymmetry_,
102                         axisOfWedge_,
103                         axisOfWedgeNormal_,
104                         rndGen_
105                     );
106                 
107                     scalar diameter = injection().d0(i, toi);
108                     vector direction = injection().direction(i, n, toi, diameter);
109                     vector U = injection().velocity(i, toi)*direction;
111                     scalar symComponent = direction & axisOfSymmetry_;
112                     vector normal = direction - symComponent*axisOfSymmetry_;
113                     normal /= mag(normal);
115                     // should be set from dict or model
116                     scalar deviation = breakup().y0();
117                     scalar ddev = breakup().yDot0();
119                     label injectorCell = mesh_.findCell(injectionPosition);
120                 
121 #                   include "findInjectorCell.H"
122    
123                     if (injectorCell >= 0)
124                     {
125                         scalar liquidCore = 1.0;
126                 
127                         // construct the parcel that is to be injected
129                         parcel* pPtr = new parcel
130                         (
131                             *this,
132                             injectionPosition,
133                             injectorCell,
134                             normal,
135                             diameter,
136                             it->T(toi),
137                             mp,
138                             deviation,
139                             ddev,
140                             0.0,
141                             0.0,
142                             0.0,
143                             liquidCore,
144                             scalar(i),
145                             U,
146                             vector::zero,
147                             it->X(),
148                             fuels_->components()
149                         );
151                         injectedLiquidKE_ += 0.5*pPtr->m()*pow(mag(U), 2.0);
152                     
153                         scalar dt = time - toi;
155                         pPtr->stepFraction() =
156                             (runTime_.deltaT().value() - dt)
157                            /runTime_.deltaT().value();
159                         bool keepParcel = pPtr->move
160                         (
161                             *this
162                         );
163   
164                         if (keepParcel)
165                         {
166                             addParticle(pPtr);
167                         }
168                         else
169                         {
170                             delete pPtr;
171                         }
172                     } // if (injectorCell....
173                 } // for(label n=0...
174             } // for(label j=0....
175         } // if (mass>0)...
176     } // forAll(injectors)...
178     time0_ = time;
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace Foam
186 // ************************************************************************* //