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

DispersionRASModel.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 "DispersionRASModel.H"
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template<class CloudType>
00032 Foam::DispersionRASModel<CloudType>::DispersionRASModel
00033 (
00034     const dictionary& dict,
00035     CloudType& owner
00036 )
00037 :
00038     DispersionModel<CloudType>(dict, owner),
00039     turbulence_
00040     (
00041         owner.mesh().objectRegistry::lookupObject<compressible::RASModel>
00042         (
00043             "RASProperties"
00044         )
00045     ),
00046     kPtr_(NULL),
00047     ownK_(false),
00048     epsilonPtr_(NULL),
00049     ownEpsilon_(false)
00050 {}
00051 
00052 
00053 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00054 
00055 template<class CloudType>
00056 Foam::DispersionRASModel<CloudType>::~DispersionRASModel()
00057 {
00058     cacheFields(false);
00059 }
00060 
00061 
00062 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00063 
00064 template<class CloudType>
00065 void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
00066 {
00067     if (store)
00068     {
00069         tmp<volScalarField> tk = this->turbulence().k();
00070         if (tk.isTmp())
00071         {
00072             kPtr_ = tk.ptr();
00073             ownK_ = true;
00074         }
00075         else
00076         {
00077             kPtr_ = tk.operator->();
00078             ownK_ = false;
00079         }
00080 
00081         tmp<volScalarField> tepsilon = this->turbulence().epsilon();
00082         if (tepsilon.isTmp())
00083         {
00084             epsilonPtr_ = tepsilon.ptr();
00085             ownEpsilon_ = true;
00086         }
00087         else
00088         {
00089             epsilonPtr_ = tepsilon.operator->();
00090             ownEpsilon_ = false;
00091         }
00092     }
00093     else
00094     {
00095         if (ownK_ && kPtr_)
00096         {
00097             delete kPtr_;
00098             ownK_ = false;
00099         }
00100         if (ownEpsilon_ && epsilonPtr_)
00101         {
00102             delete epsilonPtr_;
00103             ownEpsilon_ = false;
00104         }
00105     }
00106 }
00107 
00108 
00109 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd