FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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