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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "MultiInteraction.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class CloudType>
33 bool Foam::MultiInteraction<CloudType>::read(const dictionary& dict)
34 {
35  // Count dictionaries
36 
37  Info<< "Patch interaction model " << typeName << nl
38  << "Executing in turn " << endl;
39 
40  label count = 0;
41  for (const entry& dEntry : dict)
42  {
43  if (dEntry.isDict())
44  {
45  Info<< " " << dEntry.name() << endl;
46 
47  ++count;
48  }
49  }
50 
51  models_.resize(count);
52 
53  count = 0;
54  for (const entry& dEntry : dict)
55  {
56  if (dEntry.isDict())
57  {
58  models_.set
59  (
60  count++,
62  (
63  dEntry.dict(),
64  this->owner()
65  )
66  );
67  }
68  }
69 
70  dict.readEntry("oneInteractionOnly", oneInteractionOnly_);
71  if (oneInteractionOnly_)
72  {
73  Info<< "Stopping upon first model that interacts with particle."
74  << nl << endl;
75  }
76  else
77  {
78  Info<< "Allowing multiple models to interact."
79  << nl << endl;
80  }
81 
82  return true;
83 }
84 
85 
86 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
87 
88 template<class CloudType>
90 (
91  const dictionary& dict,
93 )
94 :
96 {
97  read(this->coeffDict());
98 }
99 
100 
101 template<class CloudType>
103 (
104  const MultiInteraction<CloudType>& pim
105 )
106 :
108  oneInteractionOnly_(pim.oneInteractionOnly_),
109  models_(pim.models_)
110 {}
111 
112 
113 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
114 
115 template<class CloudType>
117 {
118  forAll(models_, i)
119  {
120  if (models_[i].active())
121  {
122  return true;
123  }
124  }
125  return false;
126 }
127 
128 
129 template<class CloudType>
131 (
132  typename CloudType::parcelType& p,
133  const polyPatch& pp,
134  bool& keepParticle
135 )
136 {
137  label origFacei = p.face();
138  label patchi = pp.index();
139 
140  bool interacted = false;
141 
142  forAll(models_, i)
143  {
144  bool myInteracted = models_[i].correct
145  (
146  p,
147  this->owner().pMesh().boundaryMesh()[patchi],
148  keepParticle
149  );
150 
151  if (myInteracted && oneInteractionOnly_)
152  {
153  break;
154  }
155 
156  interacted = (interacted || myInteracted);
157 
158 
159  // Check if perhaps the interaction model has changed patches
160  // (CoincidentBaffleInteraction can do this)
161 
162  if (p.face() != origFacei)
163  {
164  origFacei = p.face();
165  patchi = p.patch();
166 
167  // Interaction model has moved particle off wall?
168  if (patchi == -1)
169  {
170  break;
171  }
172  }
173  }
174 
175  return interacted;
176 }
177 
178 
179 template<class CloudType>
181 {
182  for (auto& m : models_)
183  {
184  m.postEvolve();
185  }
186 }
187 
188 
189 template<class CloudType>
191 {
192  PatchInteractionModel<CloudType>::info();
193 
194  for (auto& m : models_)
195  {
196  Log_<< "Patch interaction model " << m.type() << ':' << endl;
197  m.info();
198  }
199 }
200 
201 
202 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
InfoProxy< IOstream > info() const noexcept
Return info proxy, used to print IOstream information to a stream.
Definition: IOstream.H:517
virtual void info()
Write patch interaction.
Runs multiple patch interaction models in turn. Takes dictionary where all the subdictionaries are th...
Templated patch interaction model class.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
#define Log_
Report write to Foam::Info if the class log switch is true.
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
virtual void postEvolve()
Post-evolve hook.
MultiInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
virtual bool active() const
Flag to indicate whether model activates patch interaction model.
messageStream Info
Information stream (stdout output on master, null elsewhere)
volScalarField & p
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())