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

definedHollowCone.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 "definedHollowCone.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "mathematicalConstants.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00037 
00038 defineTypeNameAndDebug(definedHollowConeInjector, 0);
00039 
00040 addToRunTimeSelectionTable
00041 (
00042     injectorModel,
00043     definedHollowConeInjector,
00044     dictionary
00045 );
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 // Construct from components
00051 definedHollowConeInjector::definedHollowConeInjector
00052 (
00053     const dictionary& dict,
00054     spray& sm
00055 )
00056 :
00057     injectorModel(dict, sm),
00058     definedHollowConeDict_(dict.subDict(typeName + "Coeffs")),
00059     dropletPDF_
00060     (
00061         pdf::New
00062         (
00063             definedHollowConeDict_.subDict("dropletPDF"),
00064             sm.rndGen()
00065         )
00066     ),
00067     innerConeAngle_(definedHollowConeDict_.lookup("innerConeAngle")),
00068     outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle"))
00069 {
00070 
00071     // convert CA to real time - inner cone angle
00072     forAll(innerConeAngle_, i)
00073     {
00074         innerConeAngle_[i][0] = sm.runTime().userTimeToTime(innerConeAngle_[i][0]);
00075     }
00076     // convert CA to real time - outer cone angle
00077     forAll(outerConeAngle_, i)
00078     {
00079         outerConeAngle_[i][0] = sm.runTime().userTimeToTime(outerConeAngle_[i][0]);
00080     }
00081 
00082     // check number of injectors
00083     if (sm.injectors().size() != 1)
00084     {
00085         Info << "Warning!!!\n"
00086              << "definedHollowConeInjector::definedHollowConeInjector"
00087              << "(const dictionary& dict, spray& sm)\n"
00088              << "Same inner/outer cone angle profiles applied to each injector"
00089              << endl;
00090     }
00091  
00092     // check number of entries in innerConeAngle list
00093     if (innerConeAngle_.empty())
00094     {
00095         FatalError << "definedHollowConeInjector::definedHollowConeInjector"
00096              << "(const dictionary& dict, spray& sm)\n"
00097              << "Number of entries in innerConeAngle must be greater than zero"
00098              << abort(FatalError);
00099     }
00100 
00101     // check number of entries in outerConeAngle list
00102     if (outerConeAngle_.empty())
00103     {
00104         FatalError << "definedHollowConeInjector::definedHollowConeInjector"
00105              << "(const dictionary& dict, spray& sm)\n"
00106              << "Number of entries in outerConeAngle must be greater than zero"
00107              << abort(FatalError);
00108     }
00109 
00110     scalar referencePressure = sm.p().average().value();
00111     // correct pressureProfile
00112     forAll(sm.injectors(), i)
00113     {
00114         sm.injectors()[i].properties()->correctProfiles(sm.fuels(), referencePressure);
00115     }
00116 
00117 }
00118 
00119 
00120 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00121 
00122 definedHollowConeInjector::~definedHollowConeInjector()
00123 {}
00124 
00125 
00126 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00127 
00128 scalar definedHollowConeInjector::d0
00129 (
00130     const label n, 
00131     const scalar t
00132 ) const
00133 {
00134     // swallow function arguments - not used
00135     // return value sampled from PDF
00136     return dropletPDF_->sample();
00137 }
00138 
00139 
00140 vector definedHollowConeInjector::direction
00141 (
00142     const label n,
00143     const label hole,
00144     const scalar t,
00145     const scalar d
00146 ) const
00147 {
00148 
00149     const injectorType& it = injectors_[n].properties();
00150 
00151     // interpolate to find inner and outer angles at time, t
00152     scalar angleInner = it.getTableValue(innerConeAngle_, t);
00153     scalar angleOuter = it.getTableValue(outerConeAngle_, t);
00154 
00155     // use random number to generate angle between inner/outer cone angles
00156     scalar angle = angleInner + rndGen_.scalar01()*(angleOuter-angleInner);
00157 
00158     scalar alpha = sin(angle*mathematicalConstant::pi/360.0);
00159     scalar dcorr = cos(angle*mathematicalConstant::pi/360.0);
00160     scalar beta = 2.0*mathematicalConstant::pi*rndGen_.scalar01();
00161 
00162     // randomly distributed vector normal to the injection vector
00163     vector normal = vector::zero;
00164     
00165     if (sm_.twoD())
00166     {
00167         scalar reduce = 0.01;
00168         // correct beta if this is a 2D run
00169         // map it onto the 'angleOfWedge'
00170 
00171         beta *= (1.0-2.0*reduce)*sm_.angleOfWedge()/(2.0*mathematicalConstant::pi);
00172         beta += reduce*sm_.angleOfWedge();
00173         normal = alpha*
00174         (
00175             sm_.axisOfWedge()*cos(beta) +
00176             sm_.axisOfWedgeNormal()*sin(beta)
00177         );
00178     }
00179     else
00180     {
00181         normal = alpha*
00182         (
00183             injectors_[n].properties()->tan1(hole)*cos(beta) +
00184             injectors_[n].properties()->tan2(hole)*sin(beta)
00185         );
00186     }
00187     
00188     // set the direction of injection by adding the normal vector
00189     vector dir = dcorr*injectors_[n].properties()->direction(hole, t) + normal;
00190     // normailse direction vector
00191     dir /= mag(dir);
00192 
00193     return dir;
00194 
00195 }
00196 
00197 scalar definedHollowConeInjector::velocity
00198 (
00199     const label i,
00200     const scalar time
00201 ) const
00202 {
00203     const injectorType& it = sm_.injectors()[i].properties();
00204     if (it.pressureIndependentVelocity())
00205     {
00206         return it.getTableValue(it.velocityProfile(), time);
00207     }
00208     else
00209     {
00210         scalar Pref = sm_.ambientPressure();
00211         scalar Pinj = it.getTableValue(it.injectionPressureProfile(), time);
00212         scalar rho = sm_.fuels().rho(Pinj, it.T(time), it.X());
00213         scalar dp = max(0.0, Pinj - Pref);
00214         return sqrt(2.0*dp/rho);
00215     }
00216 }
00217 
00218 scalar definedHollowConeInjector::averageVelocity
00219 (
00220     const label i
00221 ) const
00222 {    
00223     const injectorType& it = sm_.injectors()[i].properties();
00224     scalar dt = it.teoi() - it.tsoi();
00225     return it.integrateTable(it.velocityProfile())/dt;
00226 }
00227 
00228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00229 
00230 } // End namespace Foam
00231 
00232 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd