Loading...
Searching...
No Matches
DispersionRASModel.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "DispersionRASModel.H"
30#include "turbulenceModel.H"
31
32// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
33
34template<class CloudType>
37{
38 const objectRegistry& obr = this->owner().mesh();
39 const word turbName =
41 (
43 this->owner().U().group()
44 );
45
46 const turbulenceModel* turb = obr.findObject<turbulenceModel>(turbName);
47
48 if (turb)
49 {
50 return turb->k();
51 }
52
54 << "Turbulence model not found in mesh database" << nl
55 << "Database objects include: " << obr.sortedToc()
56 << abort(FatalError);
58 return nullptr;
59}
60
61
62template<class CloudType>
65{
66 const objectRegistry& obr = this->owner().mesh();
67 const word turbName =
69 (
71 this->owner().U().group()
72 );
73
74 const turbulenceModel* turb = obr.findObject<turbulenceModel>(turbName);
75
76 if (turb)
77 {
78 return turb->epsilon();
79 }
80
82 << "Turbulence model not found in mesh database" << nl
83 << "Database objects include: " << obr.sortedToc()
84 << abort(FatalError);
85
86 return nullptr;
87}
88
89
90// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91
92template<class CloudType>
94(
95 const dictionary&,
96 CloudType& owner
97)
98:
100 kPtr_(nullptr),
101 epsilonPtr_(nullptr),
102 ownK_(false),
103 ownEpsilon_(false)
104{}
105
106
107template<class CloudType>
109(
111)
112:
114 kPtr_(dm.kPtr_),
115 epsilonPtr_(dm.epsilonPtr_),
116 ownK_(dm.ownK_),
117 ownEpsilon_(dm.ownEpsilon_)
118{
119 dm.ownK_ = false;
120 dm.ownEpsilon_ = false;
121}
122
123
124// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
125
126template<class CloudType>
128{
130}
131
132
133// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
134
135template<class CloudType>
137{
138 if (store)
139 {
140 tmp<volScalarField> tk = this->kModel();
141 if (tk.movable())
142 {
143 // Take ownership
144 kPtr_ = tk.ptr();
145 ownK_ = true;
146 }
147 else
148 {
149 kPtr_ = &tk.cref();
150 ownK_ = false;
151 }
152
153 tmp<volScalarField> tepsilon = this->epsilonModel();
154 if (tepsilon.movable())
155 {
156 // Take ownership
157 epsilonPtr_ = tepsilon.ptr();
158 ownEpsilon_ = true;
159 }
160 else
161 {
162 epsilonPtr_ = &tepsilon();
163 ownEpsilon_ = false;
164 }
165 }
166 else
167 {
168 if (ownK_)
169 {
171 ownK_ = false;
172 }
173 if (ownEpsilon_)
174 {
175 deleteDemandDrivenData(epsilonPtr_);
176 ownEpsilon_ = false;
177 }
178 }
179}
180
181
182template<class CloudType>
184{
186
187 os.writeEntry("ownK", ownK_);
188 os.writeEntry("ownEpsilon", ownEpsilon_);
189}
190
191
192// ************************************************************************* //
compressible::turbulenceModel & turb
virtual void write(Ostream &os) const
Write to os.
const CloudType & owner() const
Return const access to the owner cloud.
Base class for dispersion modelling.
DispersionModel(CloudType &owner)
Construct null from owner.
Base class for particle dispersion models based on RAS turbulence.
const volScalarField * epsilonPtr_
Turbulence epsilon.
tmp< volScalarField > kModel() const
Return the k field from the turbulence model.
virtual void cacheFields(const bool store)
Cache carrier fields.
const volScalarField * kPtr_
Turbulence k.
virtual void write(Ostream &os) const
Write.
tmp< volScalarField > epsilonModel() const
Return the epsilon field from the turbulence model.
bool ownEpsilon_
Local ownership of the epsilon field.
DispersionRASModel(const dictionary &dict, CloudType &owner)
Construct from components.
virtual ~DispersionRASModel()
Destructor.
bool ownK_
Local ownership of the k field.
Foam::List< Key > sortedToc(const Compare &comp) const
Definition HashTable.C:168
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition Ostream.H:331
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Registry of regIOobjects.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
A class for managing temporary objects.
Definition tmp.H:75
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Definition tmpI.H:221
bool movable() const noexcept
True if this is a non-null managed pointer with a unique ref-count.
Definition tmpI.H:214
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
Definition tmpI.H:256
Abstract base class for turbulence models (RAS, LES and laminar).
static const word propertiesName
Default name of the turbulence properties dictionary.
A class for handling words, derived from Foam::string.
Definition word.H:66
U
Definition pEqn.H:72
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
DSMCCloud< dsmcParcel > CloudType
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void deleteDemandDrivenData(DataPtr &dataPtr)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50