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

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