OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

KinematicCloud.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "KinematicCloud.H"
00028 #include "IntegrationScheme.H"
00029 #include "interpolation.H"
00030 
00031 #include "DispersionModel.H"
00032 #include "DragModel.H"
00033 #include "InjectionModel.H"
00034 #include "PatchInteractionModel.H"
00035 #include "PostProcessingModel.H"
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 template<class ParcelType>
00040 Foam::KinematicCloud<ParcelType>::KinematicCloud
00041 (
00042     const word& cloudName,
00043     const volScalarField& rho,
00044     const volVectorField& U,
00045     const volScalarField& mu,
00046     const dimensionedVector& g
00047 )
00048 :
00049     Cloud<ParcelType>(rho.mesh(), cloudName, false),
00050     kinematicCloud(),
00051     mesh_(rho.mesh()),
00052     particleProperties_
00053     (
00054         IOobject
00055         (
00056             cloudName + "Properties",
00057             rho.mesh().time().constant(),
00058             rho.mesh(),
00059             IOobject::MUST_READ,
00060             IOobject::NO_WRITE
00061         )
00062     ),
00063     constProps_(particleProperties_),
00064     parcelTypeId_(readLabel(particleProperties_.lookup("parcelTypeId"))),
00065     coupled_(particleProperties_.lookup("coupled")),
00066     cellValueSourceCorrection_
00067     (
00068         particleProperties_.lookup("cellValueSourceCorrection")
00069     ),
00070     rndGen_(label(0)),
00071     rho_(rho),
00072     U_(U),
00073     mu_(mu),
00074     g_(g),
00075     forces_(mesh_, particleProperties_, g_.value()),
00076     interpolationSchemes_(particleProperties_.subDict("interpolationSchemes")),
00077     dispersionModel_
00078     (
00079         DispersionModel<KinematicCloud<ParcelType> >::New
00080         (
00081             particleProperties_,
00082             *this
00083         )
00084     ),
00085     dragModel_
00086     (
00087         DragModel<KinematicCloud<ParcelType> >::New
00088         (
00089             particleProperties_,
00090             *this
00091         )
00092     ),
00093     injectionModel_
00094     (
00095         InjectionModel<KinematicCloud<ParcelType> >::New
00096         (
00097             particleProperties_,
00098             *this
00099         )
00100     ),
00101     patchInteractionModel_
00102     (
00103         PatchInteractionModel<KinematicCloud<ParcelType> >::New
00104         (
00105             particleProperties_,
00106             *this
00107         )
00108     ),
00109     postProcessingModel_
00110     (
00111         PostProcessingModel<KinematicCloud<ParcelType> >::New
00112         (
00113             this->particleProperties_,
00114             *this
00115         )
00116     ),
00117     UIntegrator_
00118     (
00119         vectorIntegrationScheme::New
00120         (
00121             "U",
00122             particleProperties_.subDict("integrationSchemes")
00123         )
00124     ),
00125     UTrans_
00126     (
00127         IOobject
00128         (
00129             this->name() + "UTrans",
00130             this->db().time().timeName(),
00131             this->db(),
00132             IOobject::NO_READ,
00133             IOobject::NO_WRITE,
00134             false
00135         ),
00136         mesh_,
00137         dimensionedVector("zero", dimMass*dimVelocity, vector::zero)
00138     )
00139 {}
00140 
00141 
00142 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00143 
00144 template<class ParcelType>
00145 Foam::KinematicCloud<ParcelType>::~KinematicCloud()
00146 {}
00147 
00148 
00149 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00150 
00151 template<class ParcelType>
00152 void Foam::KinematicCloud<ParcelType>::checkParcelProperties
00153 (
00154     ParcelType& parcel,
00155     const scalar lagrangianDt,
00156     const bool fullyDescribed
00157 )
00158 {
00159     if (!fullyDescribed)
00160     {
00161         parcel.rho() = constProps_.rho0();
00162     }
00163 
00164     scalar carrierDt = this->db().time().deltaT().value();
00165     parcel.stepFraction() = (carrierDt - lagrangianDt)/carrierDt;
00166 }
00167 
00168 
00169 template<class ParcelType>
00170 void Foam::KinematicCloud<ParcelType>::resetSourceTerms()
00171 {
00172     UTrans_.field() = vector::zero;
00173 }
00174 
00175 
00176 template<class ParcelType>
00177 void Foam::KinematicCloud<ParcelType>::preEvolve()
00178 {
00179     this->dispersion().cacheFields(true);
00180     forces_.cacheFields(true);
00181 }
00182 
00183 
00184 template<class ParcelType>
00185 void Foam::KinematicCloud<ParcelType>::postEvolve()
00186 {
00187     if (debug)
00188     {
00189         this->writePositions();
00190     }
00191 
00192     this->dispersion().cacheFields(false);
00193     forces_.cacheFields(false);
00194 
00195     this->postProcessing().post();
00196 }
00197 
00198 
00199 template<class ParcelType>
00200 void Foam::KinematicCloud<ParcelType>::evolve()
00201 {
00202     preEvolve();
00203 
00204     autoPtr<interpolation<scalar> > rhoInterpolator =
00205         interpolation<scalar>::New
00206         (
00207             interpolationSchemes_,
00208             rho_
00209         );
00210 
00211     autoPtr<interpolation<vector> > UInterpolator =
00212         interpolation<vector>::New
00213         (
00214             interpolationSchemes_,
00215             U_
00216         );
00217 
00218     autoPtr<interpolation<scalar> > muInterpolator =
00219         interpolation<scalar>::New
00220         (
00221             interpolationSchemes_,
00222             mu_
00223         );
00224 
00225     typename ParcelType::trackData td
00226     (
00227         *this,
00228         constProps_,
00229         rhoInterpolator(),
00230         UInterpolator(),
00231         muInterpolator(),
00232         g_.value()
00233     );
00234 
00235     this->injection().inject(td);
00236 
00237     if (coupled_)
00238     {
00239         resetSourceTerms();
00240     }
00241 
00242     Cloud<ParcelType>::move(td);
00243 
00244     postEvolve();
00245 }
00246 
00247 
00248 template<class ParcelType>
00249 void Foam::KinematicCloud<ParcelType>::info() const
00250 {
00251     Info<< "Cloud: " << this->name() << nl
00252         << "    Total number of parcels added   = "
00253         << returnReduce(this->injection().parcelsAddedTotal(), sumOp<label>())
00254             << nl
00255         << "    Total mass introduced           = "
00256         << returnReduce(this->injection().massInjected(), sumOp<scalar>())
00257             << nl
00258         << "    Current number of parcels       = "
00259         << returnReduce(this->size(), sumOp<label>()) << nl
00260         << "    Current mass in system          = "
00261         << returnReduce(massInSystem(), sumOp<scalar>()) << nl;
00262 }
00263 
00264 
00265 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd