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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "PatchInteractionModel.H"
27 #include "fvMesh.H"
28 #include "Time.H"
29 #include "volFields.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 (
36  IStringStream
37  (
38  "(rebound stick escape)"
39  )()
40 );
41 
42 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 
44 template<class CloudType>
46 (
47  const interactionType& itEnum
48 )
49 {
50  word it = "other";
51 
52  switch (itEnum)
53  {
54  case itRebound:
55  {
56  it = "rebound";
57  break;
58  }
59  case itStick:
60  {
61  it = "stick";
62  break;
63  }
64  case itEscape:
65  {
66  it = "escape";
67  break;
68  }
69  default:
70  {
71  }
72  }
73 
74  return it;
75 }
76 
77 
78 template<class CloudType>
81 (
82  const word& itWord
83 )
84 {
85  if (itWord == "rebound")
86  {
87  return itRebound;
88  }
89  else if (itWord == "stick")
90  {
91  return itStick;
92  }
93  else if (itWord == "escape")
94  {
95  return itEscape;
96  }
97  else
98  {
99  return itOther;
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
106 template<class CloudType>
108 (
109  CloudType& owner
110 )
111 :
113  UName_("unknown_UName")
114 {}
115 
116 
117 template<class CloudType>
119 (
120  const dictionary& dict,
121  CloudType& owner,
122  const word& type
123 )
124 :
125  CloudSubModelBase<CloudType>(owner, dict, typeName, type),
126  UName_(this->coeffDict().lookupOrDefault("UName", word("U"))),
127  escapedParcels_(0),
128  escapedMass_(0.0)
129 {}
130 
131 
132 template<class CloudType>
134 (
136 )
137 :
139  UName_(pim.UName_),
140  escapedParcels_(pim.escapedParcels_),
141  escapedMass_(pim.escapedMass_)
142 {}
143 
144 
145 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
146 
147 template<class CloudType>
149 {}
150 
151 
152 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
153 
154 template<class CloudType>
156 {
157  return UName_;
158 }
159 
160 
161 template<class CloudType>
163 (
164  const scalar mass
165 )
166 {
167  escapedMass_ += mass;
168  escapedParcels_++;
169 }
170 
171 
172 template<class CloudType>
174 {
175  const label escapedParcels0 =
176  this->template getBaseProperty<label>("escapedParcels");
177  const label escapedParcelsTotal =
178  escapedParcels0 + returnReduce(escapedParcels_, sumOp<label>());
179 
180  const scalar escapedMass0 =
181  this->template getBaseProperty<scalar>("escapedMass");
182  const scalar escapedMassTotal =
183  escapedMass0 + returnReduce(escapedMass_, sumOp<scalar>());
184 
185  os << " Parcel fate: system (number, mass)" << nl
186  << " - escape = " << escapedParcelsTotal
187  << ", " << escapedMassTotal << endl;
188 
189  if (this->outputTime())
190  {
191  this->setBaseProperty("escapedParcels", escapedParcelsTotal);
192  escapedParcels_ = 0;
193 
194  this->setBaseProperty("escapedMass", escapedMassTotal);
195  escapedMass_ = 0.0;
196  }
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
203 
204 // ************************************************************************* //
volFields.H
PatchInteractionModel.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::PatchInteractionModel::escapedParcels_
label escapedParcels_
Number of parcels escaped.
Definition: PatchInteractionModel.H:87
Foam::PatchInteractionModel::addToEscapedParcels
void addToEscapedParcels(const scalar mass)
Add to escaped parcels.
Definition: PatchInteractionModel.C:163
PatchInteractionModelNew.C
Foam::PatchInteractionModel::~PatchInteractionModel
virtual ~PatchInteractionModel()
Destructor.
Definition: PatchInteractionModel.C:148
Foam::PatchInteractionModel::interactionTypeNames_
static wordList interactionTypeNames_
Definition: PatchInteractionModel.H:73
Foam::PatchInteractionModel::UName_
const word UName_
Name of velocity field - default = "U".
Definition: PatchInteractionModel.H:81
Foam::CloudSubModelBase
Base class for cloud sub-models.
Definition: CloudSubModelBase.H:49
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::PatchInteractionModel::UName
const word & UName() const
Return name of velocity field.
Definition: PatchInteractionModel.C:155
Foam::PatchInteractionModel< CloudType >
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:59
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
fvMesh.H
Foam::PatchInteractionModel::PatchInteractionModel
PatchInteractionModel(CloudType &owner)
Construct null from owner.
Definition: PatchInteractionModel.C:108
Foam::sumOp
Definition: ops.H:162
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::PatchInteractionModel::wordToInteractionType
static interactionType wordToInteractionType(const word &itWord)
Convert word to interaction result.
Definition: PatchInteractionModel.C:81
Foam::PatchInteractionModel::info
virtual void info(Ostream &os)
Write patch interaction info to stream.
Definition: PatchInteractionModel.C:173
Foam::PatchInteractionModel::escapedMass_
scalar escapedMass_
Mass of parcels escaped.
Definition: PatchInteractionModel.H:90
Foam::PatchInteractionModel< Foam::DSMCCloud >::interactionType
interactionType
Definition: PatchInteractionModel.H:65
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::PatchInteractionModel::interactionTypeToWord
static word interactionTypeToWord(const interactionType &itEnum)
Convert interaction result to word.
Definition: PatchInteractionModel.C:46
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588