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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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.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 = vector::zero;
126  nEscape_++;
127  massEscape_ += p.nParticle()*p.mass();
128  break;
129  }
131  {
132  keepParticle = true;
133  active = false;
134  U = vector::zero;
135  nStick_++;
136  massStick_ += p.nParticle()*p.mass();
137  break;
138  }
140  {
141  keepParticle = true;
142  active = true;
143 
144  vector nw;
145  vector Up;
146 
147  this->owner().patchData(p, pp, trackFraction, tetIs, nw, Up);
148 
149  // Calculate motion relative to patch velocity
150  U -= Up;
151 
152  scalar Un = U & nw;
153  vector Ut = U - Un*nw;
154 
155  if (Un > 0)
156  {
157  U -= (1.0 + e_)*Un*nw;
158  }
159 
160  U -= mu_*Ut;
161 
162  // Return velocity to global space
163  U += Up;
164 
165  break;
166  }
167  default:
168  {
170  << "Unknown interaction type "
171  << this->interactionTypeToWord(interactionType_)
172  << "(" << interactionType_ << ")" << endl
173  << abort(FatalError);
174  }
175  }
176 
177  return true;
178  }
179 
180  return false;
181 }
182 
183 
184 template<class CloudType>
186 {
188 
189  label npe0 = this->template getModelProperty<scalar>("nEscape");
190  label npe = npe0 + returnReduce(nEscape_, sumOp<label>());
191 
192  scalar mpe0 = this->template getModelProperty<scalar>("massEscape");
193  scalar mpe = mpe0 + returnReduce(massEscape_, sumOp<scalar>());
194 
195  label nps0 = this->template getModelProperty<scalar>("nStick");
196  label nps = nps0 + returnReduce(nStick_, sumOp<label>());
197 
198  scalar mps0 = this->template getModelProperty<scalar>("massStick");
199  scalar mps = mps0 + returnReduce(massStick_, sumOp<scalar>());
200 
201  os << " Parcel fate: walls (number, mass)" << nl
202  << " - escape = " << npe << ", " << mpe << nl
203  << " - stick = " << nps << ", " << mps << nl;
204 
205  if (this->outputTime())
206  {
207  this->setModelProperty("nEscape", npe);
208  nEscape_ = 0;
209 
210  this->setModelProperty("massEscape", mpe);
211  massEscape_ = 0.0;
212 
213  this->setModelProperty("nStick", nps);
214  nStick_ = 0;
215 
216  this->setModelProperty("massStick", mps);
217  massStick_ = 0.0;
218  }
219 }
220 
221 
222 // ************************************************************************* //
Foam::StandardWallInteraction::correct
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle, const scalar trackFraction, const tetIndices &tetIs)
Apply velocity correction.
Definition: StandardWallInteraction.C:105
p
p
Definition: pEqn.H:62
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::StandardWallInteraction
Wall interaction model. Three choices:
Definition: StandardWallInteraction.H:57
nw
label nw
Definition: createFields.H:25
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
U
U
Definition: pEqn.H:46
Foam::StandardWallInteraction::~StandardWallInteraction
virtual ~StandardWallInteraction()
Destructor.
Definition: StandardWallInteraction.C:97
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::StandardWallInteraction::info
virtual void info(Ostream &os)
Write patch interaction info to stream.
Definition: StandardWallInteraction.C:185
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Foam::StandardWallInteraction::nEscape_
label nEscape_
Number of parcels escaped.
Definition: StandardWallInteraction.H:79
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::StandardWallInteraction::massStick_
scalar massStick_
Mass of parcels stuck to patches.
Definition: StandardWallInteraction.H:88
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::StandardWallInteraction::e_
scalar e_
Elasticity coefficient.
Definition: StandardWallInteraction.H:70
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::StandardWallInteraction::interactionType_
PatchInteractionModel< CloudType >::interactionType interactionType_
Interaction type.
Definition: StandardWallInteraction.H:67
Foam::tetIndices
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:73
Foam::cloud
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::sumOp
Definition: ops.H:162
Foam::Vector< scalar >
Foam::StandardWallInteraction::nStick_
label nStick_
Number of parcels stuck to patches.
Definition: StandardWallInteraction.H:85
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
Foam::StandardWallInteraction::massEscape_
scalar massEscape_
Mass of parcels escaped.
Definition: StandardWallInteraction.H:82
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
StandardWallInteraction.H
Foam::StandardWallInteraction::StandardWallInteraction
StandardWallInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
Definition: StandardWallInteraction.C:32
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress
Foam::StandardWallInteraction::mu_
scalar mu_
Restitution coefficient.
Definition: StandardWallInteraction.H:73