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

spray.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 
00029 #include "atomizationModel.H"
00030 #include "breakupModel.H"
00031 #include "collisionModel.H"
00032 #include "dispersionModel.H"
00033 #include "dragModel.H"
00034 #include "evaporationModel.H"
00035 #include "heatTransferModel.H"
00036 #include "injectorModel.H"
00037 #include "wallModel.H"
00038 
00039 #include "basicMultiComponentMixture.H"
00040 
00041 #include "symmetryPolyPatch.H"
00042 #include "wedgePolyPatch.H"
00043 
00044 #include "mathematicalConstants.H"
00045 
00046 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00047 
00048 defineTemplateTypeNameAndDebug(IOPtrList<injector>, 0);
00049 
00050 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00051 
00052 // Construct from components
00053 Foam::spray::spray
00054 (
00055     const volVectorField& U,
00056     const volScalarField& rho,
00057     const volScalarField& p,
00058     const volScalarField& T,
00059     const basicMultiComponentMixture& composition,
00060     const PtrList<gasThermoPhysics>& gasProperties,
00061     const dictionary&,
00062     const dimensionedVector& g
00063 )
00064 :
00065     Cloud<parcel>(U.mesh(), false), // suppress className checking on positions
00066     runTime_(U.time()),
00067     time0_(runTime_.value()),
00068     mesh_(U.mesh()),
00069     rndGen_(label(0)),
00070     g_(g.value()),
00071 
00072     U_(U),
00073     rho_(rho),
00074     p_(p),
00075     T_(T),
00076 
00077     sprayProperties_
00078     (
00079         IOobject
00080         (
00081             "sprayProperties",
00082             U.time().constant(),
00083             U.db(),
00084             IOobject::MUST_READ,
00085             IOobject::NO_WRITE
00086         )
00087     ),
00088 
00089     ambientPressure_(p_.average().value()),
00090     ambientTemperature_(T_.average().value()),
00091 
00092     injectors_
00093     (
00094         IOobject
00095         (
00096             "injectorProperties",
00097             U.time().constant(),
00098             U.db(),
00099             IOobject::MUST_READ,
00100             IOobject::NO_WRITE
00101         ),
00102         injector::iNew(U.time())
00103     ),
00104     atomization_
00105     (
00106         atomizationModel::New
00107         (
00108             sprayProperties_,
00109             *this
00110         )
00111     ),
00112     drag_
00113     (
00114         dragModel::New
00115         (
00116             sprayProperties_
00117         )
00118     ),
00119     evaporation_
00120     (
00121         evaporationModel::New
00122         (
00123             sprayProperties_
00124         )
00125     ),
00126     heatTransfer_
00127     (
00128         heatTransferModel::New
00129         (
00130             sprayProperties_
00131         )
00132     ),
00133     wall_
00134     (
00135         wallModel::New
00136         (
00137             sprayProperties_,
00138             U,
00139             *this
00140         )
00141     ),
00142     breakupModel_
00143     (
00144         breakupModel::New
00145         (
00146             sprayProperties_,
00147             *this
00148         )
00149     ),
00150     collisionModel_
00151     (
00152         collisionModel::New
00153         (
00154             sprayProperties_,
00155             *this,
00156             rndGen_
00157         )
00158     ),
00159     dispersionModel_
00160     (
00161         dispersionModel::New
00162         (
00163             sprayProperties_,
00164             *this
00165         )
00166     ),
00167 
00168     fuels_
00169     (
00170         liquidMixture::New
00171         (
00172             mesh_.lookupObject<dictionary>("thermophysicalProperties")
00173         )
00174     ),
00175     injectorModel_
00176     (
00177         injectorModel::New
00178         (
00179             sprayProperties_,
00180             *this
00181         )
00182     ),
00183 
00184     subCycles_(readLabel(sprayProperties_.lookup("subCycles"))),
00185 
00186     gasProperties_(gasProperties),
00187     composition_(composition),
00188 
00189     liquidToGasIndex_(fuels_->components().size(), -1),
00190     gasToLiquidIndex_(composition.Y().size(), -1),
00191     isLiquidFuel_(composition.Y().size(), false),
00192 
00193     twoD_(0),
00194     axisOfSymmetry_(vector::zero),
00195     axisOfWedge_(vector(0,0,0)),
00196     axisOfWedgeNormal_(vector(0,0,0)),
00197     angleOfWedge_(0.0),
00198 
00199     interpolationSchemes_(sprayProperties_.subDict("interpolationSchemes")),
00200     UInterpolator_(NULL),
00201     rhoInterpolator_(NULL),
00202     pInterpolator_(NULL),
00203     TInterpolator_(NULL),
00204 
00205     sms_(mesh_.nCells(), vector::zero),
00206     shs_(mesh_.nCells(), 0.0),
00207     srhos_(fuels_->components().size()),
00208 
00209     totalInjectedLiquidMass_(0.0),
00210     injectedLiquidKE_(0.0)
00211 
00212 {
00213     // create the evaporation source fields
00214     forAll(srhos_, i)
00215     {
00216         srhos_.set(i, new scalarField(mesh_.nCells(), 0.0));
00217     }
00218 
00219     // Write some information about injection parameters
00220     forAll(injectors_, i)
00221     {
00222         const injectorType& it = injectors_[i].properties();
00223 
00224         scalar v = injection().averageVelocity(i);
00225 
00226         scalar ip = it.integrateTable(it.injectionPressureProfile());
00227         scalar dt = it.teoi() - it.tsoi();
00228         Info<< "Average Velocity for injector " << i << ": " << v << " m/s"
00229             << ", injection pressure = "
00230             << 1.0e-5*ip/dt << " bar"
00231             << endl;
00232     }
00233 
00234     // Check if the case is 2D wedge
00235     const polyBoundaryMesh& bMesh = mesh().boundaryMesh();
00236     bool symPlaneExist = false;
00237     bool wedgeExist = false;
00238     label patches[2];
00239     label n=0;
00240 
00241     // check for the type of boundary condition
00242     forAll(bMesh, patchi)
00243     {
00244         if (isType<symmetryPolyPatch>(bMesh[patchi]))
00245         {
00246             symPlaneExist = true;
00247         }
00248         else if (isType<wedgePolyPatch>(bMesh[patchi]))
00249         {
00250             wedgeExist = true;
00251             patches[n++] = patchi;
00252         }
00253     }
00254 
00255     // if wedge exist we assume that this is a 2D run.
00256     twoD_ = wedgeExist;
00257 
00258     if (twoD_)
00259     {
00260         if (n<2)
00261         {
00262             FatalErrorIn
00263             (
00264                 "spray::spray(const volVectorField& U, "
00265                 "const volScalarField& rho, const volScalarField& p, "
00266                 "const volScalarField& T, const combustionMixture& composition,"
00267                 "const PtrList<gasThermoPhsyics>& gaseousFuelProperties, "
00268                 "const dictionary& thermophysicalProperties, "
00269                 "const dimensionedScalar& g)"
00270             )   << "spray::(...) only one wedgePolyPatch found. "
00271                    "Please check you BC-setup."
00272                 << abort(FatalError);
00273         }
00274 
00275         Info<< "Constructing two dimensional spray injection.";
00276 
00277         vector v1 = bMesh[patches[0]].faceAreas()[0];
00278         vector v2 = bMesh[patches[1]].faceAreas()[0];
00279         v1 /= mag(v1);
00280         v2 /= mag(v2);
00281         axisOfSymmetry_ = v1 ^ v2;
00282         axisOfSymmetry_ /= mag(axisOfSymmetry_);
00283 
00284         // assuming that 'v2' is the 'front' face
00285         axisOfWedge_ = axisOfSymmetry_ ^ v2;
00286         axisOfWedge_ /= mag(axisOfWedge_);
00287 
00288         axisOfWedgeNormal_ = axisOfSymmetry_ ^ axisOfWedge_;
00289         axisOfWedgeNormal_ /= mag(axisOfWedgeNormal_);
00290 
00291         scalar arcCos = (v1 & v2)/mag(v1);
00292         angleOfWedge_ = mathematicalConstant::pi - acos(arcCos);
00293 
00294         Info<< "Calculated angle of wedge is "
00295             << angleOfWedge_*180/mathematicalConstant::pi << " deg."
00296             << endl;
00297     }
00298     else
00299     {
00300         if (symPlaneExist)
00301         {
00302             angleOfWedge_ = mathematicalConstant::pi;
00303             Info<< "Constructing 180 deg three dimensional spray injection."
00304                 << endl;
00305         }
00306         else
00307         {
00308             Info<< "Constructing three dimensional spray injection." << endl;
00309         }
00310 
00311     }
00312 
00313     // find index mapping between liquid indeces and gas indeces
00314     label Ns = composition_.Y().size();
00315 
00316     forAll(fuels_->components(), i)
00317     {
00318         word liquidName(fuels_->components()[i]);
00319 
00320         for (label j=0; j<Ns; j++)
00321         {
00322             word specieName(composition_.Y()[j].name());
00323 
00324             if (specieName == liquidName)
00325             {
00326                 liquidToGasIndex_[i] = j;
00327                 gasToLiquidIndex_[j] = i;
00328                 isLiquidFuel_[j] = true;
00329             }
00330         }
00331         if (liquidToGasIndex_[i] == -1)
00332         {
00333             Info << "In composition:" << endl;
00334             for (label k=0; k<Ns; k++)
00335             {
00336                 word specieName(composition_.Y()[k].name());
00337                 Info << specieName << endl;
00338             }
00339 
00340             FatalError<<
00341                 "The liquid component " << liquidName
00342                 << " does not exist in the species composition.Y() list.\n"
00343                 << "(Probably not defined in <chem.inp>)"
00344                 << abort(FatalError);
00345         }
00346     }
00347 
00348     parcel::readFields(*this);
00349 }
00350 
00351 
00352 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
00353 
00354 Foam::spray::~spray()
00355 {}
00356 
00357 
00358 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00359 
00360 void Foam::spray::writeFields() const
00361 {
00362     parcel::writeFields(*this);
00363 }
00364 
00365 
00366 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd