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

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