Loading...
Searching...
No Matches
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 }
94 return it;
95}
96
97
98template<class CloudType>
101(
102 const word& itWord
103)
104{
105 if (itWord == "none")
106 {
107 return itNone;
108 }
109 if (itWord == "rebound")
110 {
111 return itRebound;
112 }
113 else if (itWord == "stick")
115 return itStick;
116 }
117 else if (itWord == "escape")
118 {
119 return itEscape;
120 }
121 else
122 {
123 return itOther;
125}
126
127
128// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
129
130template<class CloudType>
132(
133 CloudType& owner
134)
135:
136 CloudSubModelBase<CloudType>(owner),
137 functionObjects::writeFile(owner, this->localPath(), typeName, false),
138 UName_("unknown_U"),
140 escapedMass_(0.0),
141 Urmax_(1e-4)
142{}
143
144
145template<class CloudType>
147(
148 const dictionary& dict,
150 const word& type
151)
152:
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")),
164 escapedMass_(0.0),
165 Urmax_(this->coeffDict().template getOrDefault<scalar>("UrMax", 0))
166{}
167
168
169template<class CloudType>
171(
173)
174:
176 functionObjects::writeFile(pim),
177 UName_(pim.UName_),
178 escapedParcels_(pim.escapedParcels_),
179 escapedMass_(pim.escapedMass_),
181{}
182
183
184// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
185
186template<class CloudType>
188{
189 return UName_;
190}
191
192
193template<class CloudType>
195{
196 return Urmax_;
197}
198
199
200template<class CloudType>
202(
203 const scalar mass
204)
208}
209
211template<class CloudType>
213{}
214
215
216template<class CloudType>
218{
220
221 const label escapedParcels0 =
222 this->template getBaseProperty<label>("escapedParcels");
223 const label escapedParcelsTotal =
224 escapedParcels0 + returnReduce(escapedParcels_, sumOp<label>());
225
226 const scalar escapedMass0 =
227 this->template getBaseProperty<scalar>("escapedMass");
228 const scalar escapedMassTotal =
229 escapedMass0 + returnReduce(escapedMass_, sumOp<scalar>());
230
231 Log_<< " Parcel fate: system (number, mass)" << nl
232 << " - escape = " << escapedParcelsTotal
233 << ", " << escapedMassTotal << endl;
234
235 if (!this->writtenHeader_)
236 {
237 this->writeFileHeader(this->file());
238 this->writtenHeader_ = true;
239 this->file() << endl;
240 }
241
242 this->writeCurrentTime(this->file());
243 this->file()
244 << tab << escapedParcelsTotal << tab << escapedMassTotal;
245
246
247 if (this->writeTime())
248 {
249 this->setBaseProperty("escapedParcels", escapedParcelsTotal);
250 escapedParcels_ = 0;
251
252 this->setBaseProperty("escapedMass", escapedMassTotal);
253 escapedMass_ = 0.0;
254 }
255}
256
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
261
262// ************************************************************************* //
Base class for cloud sub-models.
virtual fileName localPath() const
Output directory.
const CloudType & owner() const
Return const access to the owner cloud.
virtual void info()
Write to info.
CloudSubModelBase(CloudType &owner)
Construct null from owner cloud.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Templated patch interaction model class.
virtual void postEvolve()
Post-evolve hook.
const scalar & Urmax() const
Return Urmax.
PatchInteractionModel(CloudType &owner)
Construct null from owner.
scalar escapedMass_
Mass of parcels escaped.
label escapedParcels_
Number of parcels escaped.
virtual void addToEscapedParcels(const scalar mass)
Add to escaped parcels.
const word & UName() const
Return name of velocity field.
virtual void info()
Write patch interaction info.
static interactionType wordToInteractionType(const word &itWord)
Convert word to interaction result.
virtual void writeFileHeader(Ostream &os)
Output file header information.
const word UName_
Name of velocity field - default = "U".
static word interactionTypeToWord(const interactionType &itEnum)
Convert interaction result to word.
scalar Urmax_
Maximum relative U with patch for particle to be removed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition writeFile.C:334
void writeHeaderValue(Ostream &os, const string &property, const Type &value) const
Write a (commented) header property and value pair.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
Definition writeFile.C:200
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
Definition writeFile.C:344
bool writtenHeader_
Flag to identify whether the header has been written.
Definition writeFile.H:157
virtual OFstream & file()
Return access to the file (if only 1).
Definition writeFile.C:270
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition writeFile.C:318
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
Type getBaseProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from the base model.
const dictionary & dict() const
Return const access to the cloud dictionary.
const word & modelType() const
Return const access to the sub-model type.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
return returnReduce(nRefine-oldNRefine, sumOp< label >())
#define Log_
Report write to Foam::Info if the class log switch is true.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
List< word > wordList
List of word.
Definition fileName.H:60
DSMCCloud< dsmcParcel > CloudType
static void writeHeader(Ostream &os, const word &fieldName)
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
constexpr char tab
The tab '\t' character(0x09).
Definition Ostream.H:49
volScalarField & e