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

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