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-2022 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,
35 )
36 :
38  interactionType_
39  (
40  this->wordToInteractionType(this->coeffDict().lookup("type"))
41  ),
42  e_(0),
43  mu_(0),
44  nEscape_(0),
45  massEscape_(0),
46  nStick_(0),
47  massStick_(0)
48 {
49  switch (interactionType_)
50  {
52  {
54  << "Unknown patch interaction type "
55  << this->coeffDict().template lookup<word>("type")
56  << ". Valid types are:"
58  << nl << exit(FatalError);
59 
60  break;
61  }
62 
64  {
65  e_ = this->coeffDict().template lookupOrDefault<scalar>("e", 1);
66  mu_ = this->coeffDict().template lookupOrDefault<scalar>("mu", 0);
67 
68  break;
69  }
70  default:
71 
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 )
110 {
111  if (!isA<wallPolyPatch>(pp))
112  {
113  return false;
114  }
115 
116  switch (interactionType_)
117  {
119  {
120  return false;
121  }
122 
124  {
125  keepParticle = false;
126  p.moving() = false;
127  p.U() = Zero;
128  nEscape_++;
129  massEscape_ += p.mass()*p.nParticle();
130 
131  return true;
132  }
133 
135  {
136  keepParticle = true;
137  p.moving() = false;
138  p.U() = Zero;
139  nStick_++;
140 
141  return true;
142  }
143 
145  {
146  keepParticle = true;
147  p.moving() = true;
148 
149  vector nw, Up;
150  this->owner().patchData(p, pp, nw, Up);
151 
152  // Make motion relative to patch velocity
153  p.U() -= Up;
154 
155  const scalar Un = p.U() & nw;
156  const vector Ut = p.U() - Un*nw;
157 
158  if (Un > 0)
159  {
160  p.U() -= (1 + e_)*Un*nw;
161  }
162 
163  p.U() -= mu_*Ut;
164 
165  // Return velocity to global space
166  p.U() += Up;
167 
168  return true;
169  }
170 
171  default:
172  {
173  return false;
174  }
175  }
176 }
177 
178 
179 template<class CloudType>
181 {
182  label npe0 = this->template getBaseProperty<scalar>("nEscape");
183  label npe = npe0 + returnReduce(nEscape_, sumOp<label>());
184 
185  scalar mpe0 = this->template getBaseProperty<scalar>("massEscape");
186  scalar mpe = mpe0 + returnReduce(massEscape_, sumOp<scalar>());
187 
188  label nps0 = this->template getBaseProperty<scalar>("nStick");
189  label nps = nps0 + returnReduce(nStick_, sumOp<label>());
190 
191  scalar mps0 = this->template getBaseProperty<scalar>("massStick");
192  scalar mps = mps0 + returnReduce(massStick_, sumOp<scalar>());
193 
194  os << " Parcel fate (number, mass)" << nl
195  << " - escape = " << npe << ", " << mpe << nl
196  << " - stick = " << nps << ", " << mps << nl;
197 
198  if (this->writeTime())
199  {
200  this->setModelProperty("nEscape", npe);
201  this->setModelProperty("massEscape", mpe);
202  this->setModelProperty("nStick", nps);
203  this->setModelProperty("massStick", mps);
204  }
205 }
206 
207 
208 // ************************************************************************* //
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:225
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Templated patch interaction model class.
virtual void info(Ostream &os)
Write patch interaction info to stream.
StandardWallInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
scalar mu_
Restitution coefficient.
scalar e_
Elasticity coefficient.
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
virtual ~StandardWallInteraction()
Destructor.
PatchInteractionModel< CloudType >::interactionType interactionType_
Interaction type.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
Definition: subModelBase.C:128
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
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
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
error FatalError
static const char nl
Definition: Ostream.H:266
dictionary dict
volScalarField & p