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

constInjector.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 "constInjector.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "mathematicalConstants.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00037 
00038 defineTypeNameAndDebug(constInjector, 0);
00039 
00040 addToRunTimeSelectionTable
00041 (
00042     injectorModel,
00043     constInjector,
00044     dictionary
00045 );
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 // Construct from components
00051 constInjector::constInjector
00052 (
00053     const dictionary& dict,
00054     spray& sm
00055 )
00056 :
00057     injectorModel(dict, sm),
00058     specDict_(dict.subDict(typeName + "Coeffs")),
00059     dropletNozzleDiameterRatio_(specDict_.lookup("dropletNozzleDiameterRatio")),
00060     sprayAngle_(specDict_.lookup("sprayAngle"))
00061 {
00062     if (sm.injectors().size() != dropletNozzleDiameterRatio_.size())
00063     {
00064         FatalError << "constInjector::constInjector"
00065             << "(const dictionary& dict, spray& sm)\n"
00066             << "Wrong number of entries in dropletNozzleDiameterRatio"
00067             << abort(FatalError);
00068     }
00069 
00070     if (sm.injectors().size() != sprayAngle_.size())
00071     {
00072         FatalError << "constInjector::constInjector"
00073             << "(const dictionary& dict, spray& sm)\n"
00074             << "Wrong number of entries in sprayAngle"
00075             << abort(FatalError);
00076     }
00077 
00078     scalar referencePressure = sm.p().average().value();
00079 
00080     // correct velocity and pressure profiles
00081     forAll(sm.injectors(), i)
00082     {
00083         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
00084     }
00085 
00086 }
00087 
00088 
00089 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00090 
00091 constInjector::~constInjector()
00092 {}
00093 
00094 
00095 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00096 
00097 scalar constInjector::d0
00098 (
00099     const label n, 
00100     const scalar
00101 ) const
00102 {
00103     return injectors_[n].properties()->d()*dropletNozzleDiameterRatio_[n];
00104 }
00105 
00106 
00107 vector constInjector::direction
00108 (
00109     const label n,
00110     const label hole,
00111     const scalar time,
00112     const scalar d
00113 ) const
00114 {
00115 
00116     /*
00117         randomly distribute parcels in a solid cone
00118         with angle = sprayAngle,
00119         alpha = radius of the two normal vectors,
00120         = maximum sin(sprayAngle/2)
00121         beta = angle in the normal plane
00122         
00123                         o                    / (beta)
00124                         |\                  /
00125                         | \                /)
00126                         |  \              o-----------> (x-axis)
00127                         |   \
00128                         v  (alpha)
00129         */
00130 
00131     scalar angle = rndGen_.scalar01()*sprayAngle_[n]*mathematicalConstant::pi/360.0;
00132     scalar alpha = sin(angle);
00133     scalar dcorr = cos(angle);
00134 
00135     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
00136 
00137     // randomly distributed vector normal to the injection vector
00138     vector normal = vector::zero;
00139     
00140     if (sm_.twoD())
00141     {
00142         scalar reduce = 0.01;
00143         // correct beta if this is a 2D run
00144         // map it onto the 'angleOfWedge'
00145         beta *= (1.0-2.0*reduce)*0.5*sm_.angleOfWedge()/mathematicalConstant::pi;
00146         beta += reduce*sm_.angleOfWedge();
00147 
00148         normal = alpha*
00149         (
00150             sm_.axisOfWedge()*cos(beta) +
00151             sm_.axisOfWedgeNormal()*sin(beta)
00152         );
00153 
00154     }
00155     else
00156     {
00157         normal = alpha*
00158         (
00159             injectors_[n].properties()->tan1(hole)*cos(beta) +
00160             injectors_[n].properties()->tan2(hole)*sin(beta)
00161         );
00162     }
00163     
00164     // set the direction of injection by adding the normal vector
00165     vector dir = dcorr*injectors_[n].properties()->direction(n, time) + normal;
00166     dir /= mag(dir);
00167 
00168     return dir;
00169 }
00170 
00171 scalar constInjector::velocity
00172 (
00173     const label i,
00174     const scalar time
00175 ) const
00176 {
00177     const injectorType& it = sm_.injectors()[i].properties();
00178     if (it.pressureIndependentVelocity())
00179     {
00180         return it.getTableValue(it.velocityProfile(), time);
00181     }
00182     else
00183     {
00184         scalar Pref = sm_.ambientPressure();
00185         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
00186         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
00187         scalar dp = max(0.0, Pinj - Pref);
00188         return sqrt(2.0*dp/rho);
00189     }
00190 }
00191 
00192 scalar constInjector::averageVelocity
00193 (
00194     const label i
00195 ) const
00196 {    
00197     const injectorType& it = sm_.injectors()[i].properties();
00198     scalar dt = it.teoi() - it.tsoi();
00199 
00200     return it.integrateTable(it.velocityProfile())/dt;
00201 }
00202 
00203 } // End namespace Foam
00204 
00205 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd