Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Kinematic / DispersionModel / DispersionRASModel / DispersionRASModel.C
blob5473886f5db15959a721d5fea6ac36df2f4f4929
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "DispersionRASModel.H"
27 #include "demandDrivenData.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template<class CloudType>
32 Foam::DispersionRASModel<CloudType>::DispersionRASModel
34     const dictionary&,
35     CloudType& owner
38     DispersionModel<CloudType>(owner),
39     turbulence_
40     (
41         owner.mesh().objectRegistry::template lookupObject
42         <
43             compressible::RASModel
44         >
45         (
46             "RASProperties"
47         )
48     ),
49     kPtr_(NULL),
50     ownK_(false),
51     epsilonPtr_(NULL),
52     ownEpsilon_(false)
56 template<class CloudType>
57 Foam::DispersionRASModel<CloudType>::DispersionRASModel
59     DispersionRASModel<CloudType>& dm
62     DispersionModel<CloudType>(dm),
63     turbulence_(dm.turbulence_),
64     kPtr_(dm.kPtr_),
65     ownK_(dm.ownK_),
66     epsilonPtr_(dm.epsilonPtr_),
67     ownEpsilon_(dm.ownEpsilon_)
69     dm.ownK_ = false;
70     dm.ownEpsilon_ = false;
74 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
76 template<class CloudType>
77 Foam::DispersionRASModel<CloudType>::~DispersionRASModel()
79     cacheFields(false);
83 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
85 template<class CloudType>
86 void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
88     if (store)
89     {
90         tmp<volScalarField> tk = this->turbulence().k();
91         if (tk.isTmp())
92         {
93             kPtr_ = tk.ptr();
94             ownK_ = true;
95         }
96         else
97         {
98             kPtr_ = tk.operator->();
99             ownK_ = false;
100         }
102         tmp<volScalarField> tepsilon = this->turbulence().epsilon();
103         if (tepsilon.isTmp())
104         {
105             epsilonPtr_ = tepsilon.ptr();
106             ownEpsilon_ = true;
107         }
108         else
109         {
110             epsilonPtr_ = tepsilon.operator->();
111             ownEpsilon_ = false;
112         }
113     }
114     else
115     {
116         if (ownK_ && kPtr_)
117         {
118             deleteDemandDrivenData(kPtr_);
119             ownK_ = false;
120         }
121         if (ownEpsilon_ && epsilonPtr_)
122         {
123             deleteDemandDrivenData(epsilonPtr_);
124             ownEpsilon_ = false;
125         }
126     }
130 template<class CloudType>
131 void Foam::DispersionRASModel<CloudType>::write(Ostream& os) const
133     DispersionModel<CloudType>::write(os);
135     os.writeKeyword("ownK") << ownK_ << token::END_STATEMENT << endl;
136     os.writeKeyword("ownEpsilon") << ownEpsilon_ << token::END_STATEMENT
137         << endl;
141 // ************************************************************************* //