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 // ************************************************************************* //
Foam::MultiInteraction::active
virtual bool active() const
Flag to indicate whether model activates patch interaction model.
Definition: MultiInteraction.C:116
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::MultiInteraction::correct
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
Definition: MultiInteraction.C:131
Foam::MultiInteraction::MultiInteraction
MultiInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
Definition: MultiInteraction.C:90
MultiInteraction.H
Foam::MultiInteraction
Runs multiple patch interaction models in turn. Takes dictionary where all the subdictionaries are th...
Definition: MultiInteraction.H:92
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::PatchInteractionModel
Templated patch interaction model class.
Definition: KinematicCloud.H:89
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:67
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:74
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:62
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:220
Foam::patchIdentifier::index
label index() const
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:158