MultiInteraction.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-2013 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 
26 #include "MultiInteraction.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class CloudType>
31 bool Foam::MultiInteraction<CloudType>::read(const dictionary& dict)
32 {
33  // Count dictionaries
34 
35  Info<< "Patch interaction model " << typeName << nl
36  << "Executing in turn " << endl;
37 
38  label nModels = 0;
39  forAllConstIter(dictionary, dict, iter)
40  {
41  if (iter().isDict())
42  {
43  Info<< " " << iter().name() << endl;
44 
45  nModels++;
46  }
47  }
48 
49  models_.setSize(nModels);
50  nModels = 0;
51  forAllConstIter(dictionary, dict, iter)
52  {
53  if (iter().isDict())
54  {
55  models_.set
56  (
57  nModels++,
59  (
60  iter().dict(),
61  this->owner()
62  )
63  );
64  }
65  }
66 
67  oneInteractionOnly_ = Switch(dict.lookup("oneInteractionOnly"));
68 
69  if (oneInteractionOnly_)
70  {
71  Info<< "Stopping upon first model that interacts with particle."
72  << nl << endl;
73  }
74  else
75  {
76  Info<< "Allowing multiple models to interact."
77  << nl << endl;
78  }
79 
80  return true;
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
85 
86 template<class CloudType>
88 (
89  const dictionary& dict,
90  CloudType& cloud
91 )
92 :
93  PatchInteractionModel<CloudType>(dict, cloud, typeName)
94 {
95  read(this->coeffDict());
96 }
97 
98 
99 template<class CloudType>
101 (
102  const MultiInteraction<CloudType>& pim
103 )
104 :
106  oneInteractionOnly_(pim.oneInteractionOnly_),
107  models_(pim.models_)
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
112 
113 template<class CloudType>
115 {}
116 
117 
118 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
119 
120 template<class CloudType>
122 {
123  forAll(models_, i)
124  {
125  if (models_[i].active())
126  {
127  return true;
128  }
129  }
130  return false;
131 }
132 
133 
134 template<class CloudType>
136 (
137  typename CloudType::parcelType& p,
138  const polyPatch& pp,
139  bool& keepParticle,
140  const scalar trackFraction,
141  const tetIndices& tetIs
142 )
143 {
144  label origFacei = p.face();
145  label patchi = pp.index();
146 
147  bool interacted = false;
148 
149  forAll(models_, i)
150  {
151  bool myInteracted = models_[i].correct
152  (
153  p,
154  this->owner().pMesh().boundaryMesh()[patchi],
155  keepParticle,
156  trackFraction,
157  tetIs
158  );
159 
160  if (myInteracted && oneInteractionOnly_)
161  {
162  break;
163  }
164 
165  interacted = (interacted || myInteracted);
166 
167 
168  // Check if perhaps the interaction model has changed patches
169  // (CoincidentBaffleInteraction can do this)
170 
171  if (p.face() != origFacei)
172  {
173  origFacei = p.face();
174  patchi = p.patch(p.face());
175 
176  // Interaction model has moved particle off wall?
177  if (patchi == -1)
178  {
179  break;
180  }
181  }
182  }
183 
184  return interacted;
185 }
186 
187 
188 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
virtual bool active() const
Flag to indicate whether model activates patch interaction model.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Definition: boundaryMesh.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Runs multiple patch interaction models in turn. Takes dictionary where all the subdictionaries are th...
Templated patch interaction model class.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
bool read(const char *, int32_t &)
Definition: int32IO.C:85
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle, const scalar trackFraction, const tetIndices &tetIs)
Apply velocity correction.
virtual ~MultiInteraction()
Destructor.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
static const char nl
Definition: Ostream.H:262
MultiInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
label patchi
messageStream Info
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
label index() const
Return the index of this patch in the boundaryMesh.