StandardWallInteraction.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class CloudType>
32 (
33  const dictionary& dict,
34  CloudType& cloud
35 )
36 :
37  PatchInteractionModel<CloudType>(dict, cloud, typeName),
38  interactionType_
39  (
40  this->wordToInteractionType(this->coeffDict().lookup("type"))
41  ),
42  e_(0.0),
43  mu_(0.0),
44  nEscape_(0),
45  massEscape_(0.0),
46  nStick_(0),
47  massStick_(0.0)
48 {
49  switch (interactionType_)
50  {
52  {
53  const word interactionTypeName(this->coeffDict().lookup("type"));
54 
56  << "Unknown interaction result type "
57  << interactionTypeName
58  << ". Valid selections are:" << this->interactionTypeNames_
59  << endl << exit(FatalError);
60 
61  break;
62  }
64  {
65  e_ = this->coeffDict().lookupOrDefault("e", 1.0);
66  mu_ = this->coeffDict().lookupOrDefault("mu", 0.0);
67  break;
68  }
69  default:
70  {}
71  }
72 }
73 
74 
75 template<class CloudType>
77 (
79 )
80 :
82  interactionType_(pim.interactionType_),
83  e_(pim.e_),
84  mu_(pim.mu_),
85  nEscape_(pim.nEscape_),
86  massEscape_(pim.massEscape_),
87  nStick_(pim.nStick_),
88  massStick_(pim.massStick_)
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
93 
94 template<class CloudType>
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
101 template<class CloudType>
103 (
104  typename CloudType::parcelType& p,
105  const polyPatch& pp,
106  bool& keepParticle
107 )
108 {
109  vector& U = p.U();
110 
111  bool& active = p.active();
112 
113  if (isA<wallPolyPatch>(pp))
114  {
115  switch (interactionType_)
116  {
118  {
119  return false;
120  }
122  {
123  keepParticle = false;
124  active = false;
125  U = Zero;
126  nEscape_++;
127  massEscape_ += p.mass()*p.nParticle();
128  break;
129  }
131  {
132  keepParticle = true;
133  active = false;
134  U = Zero;
135  nStick_++;
136  break;
137  }
139  {
140  keepParticle = true;
141  active = true;
142 
143  vector nw;
144  vector Up;
145 
146  this->owner().patchData(p, pp, nw, Up);
147 
148  // Calculate motion relative to patch velocity
149  U -= Up;
150 
151  scalar Un = U & nw;
152  vector Ut = U - Un*nw;
153 
154  if (Un > 0)
155  {
156  U -= (1.0 + e_)*Un*nw;
157  }
158 
159  U -= mu_*Ut;
160 
161  // Return velocity to global space
162  U += Up;
163 
164  break;
165  }
166  default:
167  {
169  << "Unknown interaction type "
170  << this->interactionTypeToWord(interactionType_)
171  << "(" << interactionType_ << ")" << endl
172  << abort(FatalError);
173  }
174  }
175 
176  return true;
177  }
178 
179  return false;
180 }
181 
182 
183 template<class CloudType>
185 {
186  label npe0 = this->template getBaseProperty<scalar>("nEscape");
187  label npe = npe0 + returnReduce(nEscape_, sumOp<label>());
188 
189  scalar mpe0 = this->template getBaseProperty<scalar>("massEscape");
190  scalar mpe = mpe0 + returnReduce(massEscape_, sumOp<scalar>());
191 
192  label nps0 = this->template getBaseProperty<scalar>("nStick");
193  label nps = nps0 + returnReduce(nStick_, sumOp<label>());
194 
195  scalar mps0 = this->template getBaseProperty<scalar>("massStick");
196  scalar mps = mps0 + returnReduce(massStick_, sumOp<scalar>());
197 
198  os << " Parcel fate (number, mass)" << nl
199  << " - escape = " << npe << ", " << mpe << nl
200  << " - stick = " << nps << ", " << mps << nl;
201 
202  if (this->writeTime())
203  {
204  this->setModelProperty("nEscape", npe);
205  this->setModelProperty("massEscape", mpe);
206  this->setModelProperty("nStick", nps);
207  this->setModelProperty("massStick", mps);
208  }
209 }
210 
211 
212 // ************************************************************************* //
dictionary dict
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
scalar mu_
Restitution coefficient.
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
virtual ~StandardWallInteraction()
Destructor.
Templated patch interaction model class.
PatchInteractionModel< CloudType >::interactionType interactionType_
Interaction type.
scalar massEscape_
Mass of parcels escaped.
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
Definition: word.H:59
label nStick_
Number of parcels stuck to patches.
static const zero Zero
Definition: zero.H:97
errorManip< error > abort(error &err)
Definition: errorManip.H:131
scalar e_
Elasticity coefficient.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:218
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:265
virtual void info(Ostream &os)
Write patch interaction info to stream.
scalar massStick_
Mass of parcels stuck to patches.
U
Definition: pEqn.H:72
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
StandardWallInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:69
label nw
Definition: createFields.H:25
label nEscape_
Number of parcels escaped.