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-2019 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 {}
142 
143 
144 template<class CloudType>
146 (
147  const dictionary& dict,
148  CloudType& owner,
149  const word& type
150 )
151 :
152  CloudSubModelBase<CloudType>(owner, dict, typeName, type),
154  (
155  owner,
156  this->localPath(),
157  type,
158  this->coeffDict(),
159  false // Do not write by default
160  ),
161  UName_(this->coeffDict().lookupOrDefault("U", word("U"))),
162  escapedParcels_(0),
163  escapedMass_(0.0)
164 {}
165 
166 
167 template<class CloudType>
169 (
171 )
172 :
175  UName_(pim.UName_),
176  escapedParcels_(pim.escapedParcels_),
177  escapedMass_(pim.escapedMass_)
178 {}
179 
180 
181 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
182 
183 template<class CloudType>
185 {
186  return UName_;
187 }
188 
189 
190 template<class CloudType>
192 (
193  const scalar mass
194 )
195 {
196  escapedMass_ += mass;
197  ++escapedParcels_;
198 }
199 
200 
201 template<class CloudType>
203 {
204  const label escapedParcels0 =
205  this->template getBaseProperty<label>("escapedParcels");
206  const label escapedParcelsTotal =
207  escapedParcels0 + returnReduce(escapedParcels_, sumOp<label>());
208 
209  const scalar escapedMass0 =
210  this->template getBaseProperty<scalar>("escapedMass");
211  const scalar escapedMassTotal =
212  escapedMass0 + returnReduce(escapedMass_, sumOp<scalar>());
213 
214  os << " Parcel fate: system (number, mass)" << nl
215  << " - escape = " << escapedParcelsTotal
216  << ", " << escapedMassTotal << endl;
217 
218  if (!this->writtenHeader_)
219  {
220  this->writeFileHeader(this->file());
221  this->writtenHeader_ = true;
222  this->file() << endl;
223  }
224 
225  this->writeCurrentTime(this->file());
226  this->file()
227  << tab << escapedParcelsTotal << tab << escapedMassTotal;
228 
229 
230  if (this->writeTime())
231  {
232  this->setBaseProperty("escapedParcels", escapedParcelsTotal);
233  escapedParcels_ = 0;
234 
235  this->setBaseProperty("escapedMass", escapedMassTotal);
236  escapedMass_ = 0.0;
237  }
238 }
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
244 
245 // ************************************************************************* //
volFields.H
PatchInteractionModel.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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
void addToEscapedParcels(const scalar mass)
Add to escaped parcels.
Definition: PatchInteractionModel.C:192
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:337
Foam::writeHeader
static void writeHeader(Ostream &os, const word &fieldName)
Definition: rawSurfaceWriterImpl.C:49
Foam::PatchInteractionModel::UName
const word & UName() const
Return name of velocity field.
Definition: PatchInteractionModel.C:184
Foam::sumOp
Definition: ops.H:213
Foam::PatchInteractionModel
Templated patch interaction model class.
Definition: KinematicCloud.H:89
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
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:121
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:371
Foam::nl
constexpr char nl
Definition: Ostream.H:372
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::PatchInteractionModel::info
virtual void info(Ostream &os)
Write patch interaction info to stream.
Definition: PatchInteractionModel.C:202
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::functionObjects::writeFile
functionObject base class for writing single files
Definition: writeFile.H:59
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