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 -------------------------------------------------------------------------------
11 License
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 
29 #include "PatchInteractionModel.H"
30 #include "fvMesh.H"
31 #include "Time.H"
32 #include "volFields.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 template<class CloudType>
38 {
39  "rebound", "stick", "escape"
40 };
41 
42 
43 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 
45 template<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 
59 template<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 
98 template<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")
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 
130 template<class CloudType>
132 (
133  CloudType& owner
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 
144 
145 template<class CloudType>
147 (
148  const dictionary& dict,
149  CloudType& owner,
150  const word& type
151 )
152 :
153  CloudSubModelBase<CloudType>(owner, dict, typeName, type),
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 
168 
169 template<class CloudType>
171 (
173 )
174 :
177  UName_(pim.UName_),
178  escapedParcels_(pim.escapedParcels_),
179  escapedMass_(pim.escapedMass_),
180  Urmax_(pim.Urmax_)
181 {}
182 
183 
184 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
185 
186 template<class CloudType>
188 {
189  return UName_;
190 }
191 
192 
193 template<class CloudType>
195 {
196  return Urmax_;
197 }
198 
199 
200 template<class CloudType>
202 (
203  const scalar mass
204 )
205 {
206  escapedMass_ += mass;
207  ++escapedParcels_;
208 }
209 
210 
211 template<class CloudType>
213 {}
214 
215 
216 template<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 // ************************************************************************* //
volFields.H
PatchInteractionModel.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::PatchInteractionModel::escapedParcels_
label escapedParcels_
Number of parcels escaped.
Definition: PatchInteractionModel.H:96
Foam::PatchInteractionModel::addToEscapedParcels
virtual void addToEscapedParcels(const scalar mass)
Add to escaped parcels.
Definition: PatchInteractionModel.C:202
PatchInteractionModelNew.C
Foam::PatchInteractionModel::UName_
const word UName_
Name of velocity field - default = "U".
Definition: PatchInteractionModel.H:90
Foam::CloudSubModelBase
Base class for cloud sub-models.
Definition: CloudSubModelBase.H:51
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::writeHeader
static void writeHeader(Ostream &os, const word &fieldName)
Definition: rawSurfaceWriterImpl.C:66
Foam::PatchInteractionModel::UName
const word & UName() const
Return name of velocity field.
Definition: PatchInteractionModel.C:187
Foam::sumOp
Definition: ops.H:213
Foam::PatchInteractionModel::Urmax
const scalar & Urmax() const
Return Urmax.
Definition: PatchInteractionModel.C:194
Foam::PatchInteractionModel
Templated patch interaction model class.
Definition: KinematicCloud.H:89
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::PatchInteractionModel::postEvolve
virtual void postEvolve()
Post-evolve hook.
Definition: PatchInteractionModel.C:212
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
fvMesh.H
Foam::PatchInteractionModel::PatchInteractionModel
PatchInteractionModel(CloudType &owner)
Construct null from owner.
Definition: PatchInteractionModel.C:132
Time.H
Foam::tab
constexpr char tab
Definition: Ostream.H:403
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< word >
Foam::PatchInteractionModel::writeFileHeader
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition: PatchInteractionModel.C:46
Foam::PatchInteractionModel::wordToInteractionType
static interactionType wordToInteractionType(const word &itWord)
Convert word to interaction result.
Definition: PatchInteractionModel.C:101
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::PatchInteractionModel::info
virtual void info(Ostream &os)
Write patch interaction info to stream.
Definition: PatchInteractionModel.C:217
Foam::PatchInteractionModel::Urmax_
scalar Urmax_
Maximum relative U with patch for particle to be removed.
Definition: PatchInteractionModel.H:102
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::PatchInteractionModel::escapedMass_
scalar escapedMass_
Mass of parcels escaped.
Definition: PatchInteractionModel.H:99
Foam::PatchInteractionModel< Foam::KinematicCloud< Cloud< basicKinematicCollidingParcel > > >::interactionType
interactionType
Definition: PatchInteractionModel.H:73
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::PatchInteractionModel::interactionTypeToWord
static word interactionTypeToWord(const interactionType &itEnum)
Convert interaction result to word.
Definition: PatchInteractionModel.C:61