StandardWallInteraction.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-2017 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  const scalar trackFraction,
108  const tetIndices& tetIs
109 )
110 {
111  vector& U = p.U();
112 
113  bool& active = p.active();
114 
115  if (isA<wallPolyPatch>(pp))
116  {
117  switch (interactionType_)
118  {
120  {
121  return false;
122  }
124  {
125  keepParticle = false;
126  active = false;
127  U = Zero;
128  nEscape_++;
129  massEscape_ += p.mass()*p.nParticle();
130  break;
131  }
133  {
134  keepParticle = true;
135  active = false;
136  U = Zero;
137  nStick_++;
138  break;
139  }
141  {
142  keepParticle = true;
143  active = true;
144 
145  vector nw;
146  vector Up;
147 
148  this->owner().patchData(p, pp, nw, Up);
149 
150  // Calculate motion relative to patch velocity
151  U -= Up;
152 
153  scalar Un = U & nw;
154  vector Ut = U - Un*nw;
155 
156  if (Un > 0)
157  {
158  U -= (1.0 + e_)*Un*nw;
159  }
160 
161  U -= mu_*Ut;
162 
163  // Return velocity to global space
164  U += Up;
165 
166  break;
167  }
168  default:
169  {
171  << "Unknown interaction type "
172  << this->interactionTypeToWord(interactionType_)
173  << "(" << interactionType_ << ")" << endl
174  << abort(FatalError);
175  }
176  }
177 
178  return true;
179  }
180 
181  return false;
182 }
183 
184 
185 template<class CloudType>
187 {
188  label npe0 = this->template getBaseProperty<scalar>("nEscape");
189  label npe = npe0 + returnReduce(nEscape_, sumOp<label>());
190 
191  scalar mpe0 = this->template getBaseProperty<scalar>("massEscape");
192  scalar mpe = mpe0 + returnReduce(massEscape_, sumOp<scalar>());
193 
194  label nps0 = this->template getBaseProperty<scalar>("nStick");
195  label nps = nps0 + returnReduce(nStick_, sumOp<label>());
196 
197  scalar mps0 = this->template getBaseProperty<scalar>("massStick");
198  scalar mps = mps0 + returnReduce(massStick_, sumOp<scalar>());
199 
200  os << " Parcel fate (number, mass)" << nl
201  << " - escape = " << npe << ", " << mpe << nl
202  << " - stick = " << nps << ", " << mps << nl;
203 
204  if (this->writeTime())
205  {
206  this->setModelProperty("nEscape", npe);
207  this->setModelProperty("massEscape", mpe);
208  this->setModelProperty("nStick", nps);
209  this->setModelProperty("massStick", mps);
210  }
211 }
212 
213 
214 // ************************************************************************* //
dictionary dict
U
Definition: pEqn.H:83
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
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:91
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
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:262
virtual void info(Ostream &os)
Write patch interaction info to stream.
scalar massStick_
Mass of parcels stuck to patches.
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
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle, const scalar trackFraction, const tetIndices &tetIs)
Apply velocity correction.
label nw
Definition: createFields.H:25
label nEscape_
Number of parcels escaped.