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

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