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-2016 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  // do nothing
72  }
73  }
74 }
75 
76 
77 template<class CloudType>
79 (
81 )
82 :
84  interactionType_(pim.interactionType_),
85  e_(pim.e_),
86  mu_(pim.mu_),
87  nEscape_(pim.nEscape_),
88  massEscape_(pim.massEscape_),
89  nStick_(pim.nStick_),
90  massStick_(pim.massStick_)
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 
96 template<class CloudType>
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
103 template<class CloudType>
105 (
106  typename CloudType::parcelType& p,
107  const polyPatch& pp,
108  bool& keepParticle,
109  const scalar trackFraction,
110  const tetIndices& tetIs
111 )
112 {
113  vector& U = p.U();
114 
115  bool& active = p.active();
116 
117  if (isA<wallPolyPatch>(pp))
118  {
119  switch (interactionType_)
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, trackFraction, tetIs, 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
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:217
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:68
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.