OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

sprayInject.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "spray.H"
00028 #include "breakupModel.H"
00029 #include "collisionModel.H"
00030 #include "dispersionModel.H"
00031 #include "injectorModel.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 void spray::inject()
00041 {
00042     scalar time = runTime_.value();
00043     scalar time0 = time0_;
00044 
00045     // Inject the parcels for each injector sequentially
00046     forAll(injectors_, i)
00047     {
00048         autoPtr<injectorType>& it = injectors()[i].properties();
00049         if (!it->pressureIndependentVelocity())
00050         {
00051             scalar referencePressure = p().average().value();
00052             it->correctProfiles(fuels(), referencePressure);
00053         }
00054 
00055         const label nHoles = it->nHoles();
00056 
00057         // parcels have the same mass during a timestep
00058         scalar mass = it->mass(time0, time, twoD_, angleOfWedge_);
00059 
00060         label Np = it->nParcelsToInject(time0, time);
00061 
00062         if (mass > 0)
00063         {
00064             Np = max(1, Np);
00065             scalar mp = mass/Np/nHoles;
00066 
00067             // constT is only larger than zero for the first
00068             // part of the injection
00069             scalar constT = max(0.0, it->tsoi() - time0);
00070 
00071             // deltaT is the duration of injection during this timestep
00072             scalar deltaT = min
00073             (
00074                 runTime_.deltaT().value(),
00075                 min
00076                 (
00077                     time - it->tsoi(),
00078                     it->teoi() - time0
00079                 )
00080             );
00081 
00082             for(label j=0; j<Np; j++)
00083             {
00084                 // calculate the time of injection for parcel 'j'
00085                 scalar toi = time0 + constT + deltaT*j/scalar(Np);
00086 
00087                 for(label n=0; n<nHoles; n++)
00088                 {
00089 
00090                     // calculate the velocity of the injected parcel
00091                     vector injectionPosition = it->position
00092                     (
00093                         n,
00094                         toi,
00095                         twoD_,
00096                         angleOfWedge_,
00097                         axisOfSymmetry_,
00098                         axisOfWedge_,
00099                         axisOfWedgeNormal_,
00100                         rndGen_
00101                     );
00102 
00103                     scalar diameter = injection().d0(i, toi);
00104                     vector direction =
00105                         injection().direction(i, n, toi, diameter);
00106                     vector U = injection().velocity(i, toi)*direction;
00107 
00108                     scalar symComponent = direction & axisOfSymmetry_;
00109                     vector normal = direction - symComponent*axisOfSymmetry_;
00110                     normal /= mag(normal);
00111 
00112                     // should be set from dict or model
00113                     scalar deviation = breakup().y0();
00114                     scalar ddev = breakup().yDot0();
00115 
00116                     label injectorCell = mesh_.findCell(injectionPosition);
00117 
00118 #                   include "findInjectorCell.H"
00119 
00120                     if (injectorCell >= 0)
00121                     {
00122                         scalar liquidCore = 1.0;
00123 
00124                         // construct the parcel that is to be injected
00125 
00126                         parcel* pPtr = new parcel
00127                         (
00128                             *this,
00129                             injectionPosition,
00130                             injectorCell,
00131                             normal,
00132                             diameter,
00133                             it->T(toi),
00134                             mp,
00135                             deviation,
00136                             ddev,
00137                             0.0,
00138                             0.0,
00139                             0.0,
00140                             liquidCore,
00141                             scalar(i),
00142                             U,
00143                             vector::zero,
00144                             it->X(),
00145                             fuels_->components()
00146                         );
00147 
00148                         injectedLiquidKE_ += 0.5*pPtr->m()*magSqr(U);
00149 
00150                         scalar dt = time - toi;
00151 
00152                         pPtr->stepFraction() =
00153                             (runTime_.deltaT().value() - dt)
00154                            /runTime_.deltaT().value();
00155 
00156                         bool keepParcel = pPtr->move(*this);
00157 
00158                         if (keepParcel)
00159                         {
00160                             addParticle(pPtr);
00161                         }
00162                         else
00163                         {
00164                             delete pPtr;
00165                         }
00166                     } // if (injectorCell....
00167                 } // for(label n=0...
00168             } // for(label j=0....
00169         } // if (mass>0)...
00170     } // forAll(injectors)...
00171 
00172     time0_ = time;
00173 }
00174 
00175 
00176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00177 
00178 } // End namespace Foam
00179 
00180 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd