PatchInteractionModel.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 Copyright (C) 2016-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30#include "fvMesh.H"
31#include "Time.H"
32#include "volFields.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36template<class CloudType>
38{
39 "rebound", "stick", "escape"
40};
41
42
43// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44
45template<class CloudType>
47{
48 this->writeHeader(os, "Particle patch interaction");
49 this->writeHeaderValue(os, "Model", this->modelType());
50
51 this->writeCommented(os, "Time");
52 this->writeTabbed(os, "escapedParcels");
53 this->writeTabbed(os, "escapedMass");
54}
55
56
57// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58
59template<class CloudType>
61(
62 const interactionType& itEnum
63)
64{
65 word it = "other";
66
67 switch (itEnum)
68 {
69 case itNone:
70 {
71 it = "none";
72 break;
73 }
74 case itRebound:
75 {
76 it = "rebound";
77 break;
78 }
79 case itStick:
80 {
81 it = "stick";
82 break;
83 }
84 case itEscape:
85 {
86 it = "escape";
87 break;
88 }
89 default:
90 {
91 }
92 }
93
94 return it;
95}
96
97
98template<class CloudType>
101(
102 const word& itWord
103)
104{
105 if (itWord == "none")
106 {
107 return itNone;
109 if (itWord == "rebound")
110 {
111 return itRebound;
112 }
113 else if (itWord == "stick")
114 {
115 return itStick;
116 }
117 else if (itWord == "escape")
118 {
119 return itEscape;
120 }
121 else
122 {
123 return itOther;
124 }
125}
126
127
128// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
129
130template<class CloudType>
132(
134)
135:
137 functionObjects::writeFile(owner, this->localPath(), typeName, false),
138 UName_("unknown_U"),
139 escapedParcels_(0),
140 escapedMass_(0.0),
141 Urmax_(1e-4)
142{}
143
145template<class CloudType>
147(
148 const dictionary& dict,
149 CloudType& owner,
150 const word& type
151)
152:
153 CloudSubModelBase<CloudType>(owner, dict, typeName, type),
154 functionObjects::writeFile
155 (
156 owner,
157 this->localPath(),
158 type,
159 this->coeffDict(),
160 false // Do not write by default
161 ),
162 UName_(this->coeffDict().template getOrDefault<word>("U", "U")),
163 escapedParcels_(0),
164 escapedMass_(0.0),
165 Urmax_(this->coeffDict().template getOrDefault<scalar>("UrMax", 0))
166{}
167
169template<class CloudType>
171(
174:
176 functionObjects::writeFile(pim),
177 UName_(pim.UName_),
178 escapedParcels_(pim.escapedParcels_),
179 escapedMass_(pim.escapedMass_),
180 Urmax_(pim.Urmax_)
181{}
182
183
184// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
185
186template<class CloudType>
189 return UName_;
190}
192
193template<class CloudType>
195{
196 return Urmax_;
197}
198
199
200template<class CloudType>
202(
203 const scalar mass
204)
205{
206 escapedMass_ += mass;
207 ++escapedParcels_;
208}
209
210
211template<class CloudType>
213{}
214
215
216template<class CloudType>
218{
219 const label escapedParcels0 =
220 this->template getBaseProperty<label>("escapedParcels");
221 const label escapedParcelsTotal =
222 escapedParcels0 + returnReduce(escapedParcels_, sumOp<label>());
223
224 const scalar escapedMass0 =
225 this->template getBaseProperty<scalar>("escapedMass");
226 const scalar escapedMassTotal =
227 escapedMass0 + returnReduce(escapedMass_, sumOp<scalar>());
228
229 os << " Parcel fate: system (number, mass)" << nl
230 << " - escape = " << escapedParcelsTotal
231 << ", " << escapedMassTotal << endl;
232
233 if (!this->writtenHeader_)
234 {
235 this->writeFileHeader(this->file());
236 this->writtenHeader_ = true;
237 this->file() << endl;
238 }
239
240 this->writeCurrentTime(this->file());
241 this->file()
242 << tab << escapedParcelsTotal << tab << escapedMassTotal;
243
244
245 if (this->writeTime())
246 {
247 this->setBaseProperty("escapedParcels", escapedParcelsTotal);
248 escapedParcels_ = 0;
249
250 this->setBaseProperty("escapedMass", escapedMassTotal);
251 escapedMass_ = 0.0;
252 }
253}
254
255
256// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257
259
260// ************************************************************************* //
Base class for cloud sub-models.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Templated patch interaction model class.
virtual void postEvolve()
Post-evolve hook.
const scalar & Urmax() const
Return Urmax.
virtual void addToEscapedParcels(const scalar mass)
Add to escaped parcels.
const word & UName() const
Return name of velocity field.
static interactionType wordToInteractionType(const word &itWord)
Convert word to interaction result.
virtual void writeFileHeader(Ostream &os)
Output file header information.
static word interactionTypeToWord(const interactionType &itEnum)
Convert interaction result to word.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
InfoProxy< ensightCells > info() const
Return info proxy.
Definition: ensightCells.H:254
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
constexpr char tab
The tab '\t' character(0x09)
Definition: Ostream.H:52
dictionary dict
volScalarField & e
Definition: createFields.H:11