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

ManualInjection.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 <lagrangianIntermediate/ManualInjection.H>
00027 #include <OpenFOAM/mathematicalConstants.H>
00028 
00029 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00030 
00031 template<class CloudType>
00032 Foam::label Foam::ManualInjection<CloudType>::parcelsToInject
00033 (
00034     const scalar time0,
00035     const scalar time1
00036 ) const
00037 {
00038     if ((0.0 >= time0) && (0.0 < time1))
00039     {
00040         return positions_.size();
00041     }
00042     else
00043     {
00044         return 0;
00045     }
00046 }
00047 
00048 
00049 template<class CloudType>
00050 Foam::scalar Foam::ManualInjection<CloudType>::volumeToInject
00051 (
00052     const scalar time0,
00053     const scalar time1
00054 ) const
00055 {
00056     // All parcels introduced at SOI
00057     if ((0.0 >= time0) && (0.0 < time1))
00058     {
00059         return this->volumeTotal_;
00060     }
00061     else
00062     {
00063         return 0.0;
00064     }
00065 }
00066 
00067 
00068 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00069 
00070 template<class CloudType>
00071 Foam::ManualInjection<CloudType>::ManualInjection
00072 (
00073     const dictionary& dict,
00074     CloudType& owner
00075 )
00076 :
00077     InjectionModel<CloudType>(dict, owner, typeName),
00078     positionsFile_(this->coeffDict().lookup("positionsFile")),
00079     positions_
00080     (
00081         IOobject
00082         (
00083             positionsFile_,
00084             owner.db().time().constant(),
00085             owner.mesh(),
00086             IOobject::MUST_READ,
00087             IOobject::NO_WRITE
00088         )
00089     ),
00090     diameters_(positions_.size()),
00091     U0_(this->coeffDict().lookup("U0")),
00092     parcelPDF_
00093     (
00094         pdfs::pdf::New
00095         (
00096             this->coeffDict().subDict("parcelPDF"),
00097             owner.rndGen()
00098         )
00099     )
00100 {
00101     // Construct parcel diameters
00102     forAll(diameters_, i)
00103     {
00104         diameters_[i] = parcelPDF_->sample();
00105     }
00106 
00107     // Determine volume of particles to inject
00108     this->volumeTotal_ = sum(pow3(diameters_))*mathematicalConstant::pi/6.0;
00109 }
00110 
00111 
00112 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00113 
00114 template<class CloudType>
00115 Foam::ManualInjection<CloudType>::~ManualInjection()
00116 {}
00117 
00118 
00119 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00120 
00121 template<class CloudType>
00122 bool Foam::ManualInjection<CloudType>::active() const
00123 {
00124     return true;
00125 }
00126 
00127 
00128 template<class CloudType>
00129 Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const
00130 {
00131     // Not used
00132     return this->SOI_;
00133 }
00134 
00135 
00136 template<class CloudType>
00137 void Foam::ManualInjection<CloudType>::setPositionAndCell
00138 (
00139     const label parcelI,
00140     const label,
00141     const scalar,
00142     vector& position,
00143     label& cellOwner
00144 )
00145 {
00146     position = positions_[parcelI];
00147     this->findCellAtPosition(cellOwner, position);
00148 }
00149 
00150 
00151 template<class CloudType>
00152 void Foam::ManualInjection<CloudType>::setProperties
00153 (
00154     const label parcelI,
00155     const label,
00156     const scalar,
00157     typename CloudType::parcelType& parcel
00158 )
00159 {
00160     // set particle velocity
00161     parcel.U() = U0_;
00162 
00163     // set particle diameter
00164     parcel.d() = diameters_[parcelI];
00165 }
00166 
00167 
00168 template<class CloudType>
00169 bool Foam::ManualInjection<CloudType>::fullyDescribed() const
00170 {
00171     return false;
00172 }
00173 
00174 
00175 template<class CloudType>
00176 bool Foam::ManualInjection<CloudType>::validInjection(const label)
00177 {
00178     return true;
00179 }
00180 
00181 
00182 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines