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

ConeInjection.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 "ConeInjection.H"
00027 #include <lagrangianIntermediate/DataEntry.H>
00028 #include <OpenFOAM/mathematicalConstants.H>
00029 
00030 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00031 
00032 template<class CloudType>
00033 Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
00034 (
00035     const scalar time0,
00036     const scalar time1
00037 ) const
00038 {
00039     if ((time0 >= 0.0) && (time0 < duration_))
00040     {
00041         return round((time1 - time0)*parcelsPerSecond_);
00042     }
00043     else
00044     {
00045         return 0;
00046     }
00047 }
00048 
00049 
00050 template<class CloudType>
00051 Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
00052 (
00053     const scalar time0,
00054     const scalar time1
00055 ) const
00056 {
00057     if ((time0 >= 0.0) && (time0 < duration_))
00058     {
00059         return volumeFlowRate_().integrate(time0, time1);
00060     }
00061     else
00062     {
00063         return 0.0;
00064     }
00065 }
00066 
00067 
00068 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00069 
00070 template<class CloudType>
00071 Foam::ConeInjection<CloudType>::ConeInjection
00072 (
00073     const dictionary& dict,
00074     CloudType& owner
00075 )
00076 :
00077     InjectionModel<CloudType>(dict, owner, typeName),
00078     duration_(readScalar(this->coeffDict().lookup("duration"))),
00079     position_(this->coeffDict().lookup("position")),
00080     injectorCell_(-1),
00081     direction_(this->coeffDict().lookup("direction")),
00082     parcelsPerSecond_
00083     (
00084         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
00085     ),
00086     volumeFlowRate_
00087     (
00088         DataEntry<scalar>::New
00089         (
00090             "volumeFlowRate",
00091             this->coeffDict()
00092         )
00093     ),
00094     Umag_
00095     (
00096         DataEntry<scalar>::New
00097         (
00098             "Umag",
00099             this->coeffDict()
00100         )
00101     ),
00102     thetaInner_
00103     (
00104         DataEntry<scalar>::New
00105         (
00106             "thetaInner",
00107             this->coeffDict()
00108         )
00109     ),
00110     thetaOuter_
00111     (
00112         DataEntry<scalar>::New
00113         (
00114             "thetaOuter",
00115             this->coeffDict()
00116         )
00117     ),
00118     parcelPDF_
00119     (
00120         pdfs::pdf::New
00121         (
00122             this->coeffDict().subDict("parcelPDF"),
00123             owner.rndGen()
00124         )
00125     ),
00126     tanVec1_(vector::zero),
00127     tanVec2_(vector::zero)
00128 {
00129     // Normalise direction vector
00130     direction_ /= mag(direction_);
00131 
00132     // Determine direction vectors tangential to direction
00133     vector tangent = vector::zero;
00134     scalar magTangent = 0.0;
00135 
00136     while (magTangent < SMALL)
00137     {
00138         vector v = this->owner().rndGen().vector01();
00139 
00140         tangent = v - (v & direction_)*direction_;
00141         magTangent = mag(tangent);
00142     }
00143 
00144     tanVec1_ = tangent/magTangent;
00145     tanVec2_ = direction_^tanVec1_;
00146 
00147     // Set total volume to inject
00148     this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_);
00149 
00150     // Set/cache the injector cell
00151     this->findCellAtPosition(injectorCell_, position_);
00152 }
00153 
00154 
00155 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00156 
00157 template<class CloudType>
00158 Foam::ConeInjection<CloudType>::~ConeInjection()
00159 {}
00160 
00161 
00162 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00163 
00164 template<class CloudType>
00165 bool Foam::ConeInjection<CloudType>::active() const
00166 {
00167     return true;
00168 }
00169 
00170 
00171 template<class CloudType>
00172 Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
00173 {
00174     return this->SOI_ + duration_;
00175 }
00176 
00177 
00178 template<class CloudType>
00179 void Foam::ConeInjection<CloudType>::setPositionAndCell
00180 (
00181     const label,
00182     const label,
00183     const scalar,
00184     vector& position,
00185     label& cellOwner
00186 )
00187 {
00188     position = position_;
00189     cellOwner = injectorCell_;
00190 }
00191 
00192 
00193 template<class CloudType>
00194 void Foam::ConeInjection<CloudType>::setProperties
00195 (
00196     const label parcelI,
00197     const label,
00198     const scalar time,
00199     typename CloudType::parcelType& parcel
00200 )
00201 {
00202     // set particle velocity
00203     const scalar deg2Rad = mathematicalConstant::pi/180.0;
00204 
00205     scalar t = time - this->SOI_;
00206     scalar ti = thetaInner_().value(t);
00207     scalar to = thetaOuter_().value(t);
00208     scalar coneAngle = this->owner().rndGen().scalar01()*(to - ti) + ti;
00209 
00210     coneAngle *= deg2Rad;
00211     scalar alpha = sin(coneAngle);
00212     scalar dcorr = cos(coneAngle);
00213     scalar beta = mathematicalConstant::twoPi*this->owner().rndGen().scalar01();
00214 
00215     vector normal = alpha*(tanVec1_*cos(beta) + tanVec2_*sin(beta));
00216     vector dirVec = dcorr*direction_;
00217     dirVec += normal;
00218     dirVec /= mag(dirVec);
00219 
00220     parcel.U() = Umag_().value(t)*dirVec;
00221 
00222     // set particle diameter
00223     parcel.d() = parcelPDF_().sample();
00224 }
00225 
00226 
00227 template<class CloudType>
00228 bool Foam::ConeInjection<CloudType>::fullyDescribed() const
00229 {
00230     return false;
00231 }
00232 
00233 
00234 template<class CloudType>
00235 bool Foam::ConeInjection<CloudType>::validInjection(const label)
00236 {
00237     return true;
00238 }
00239 
00240 
00241 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines