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-------------------------------------------------------------------------------
10License
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
32template<class CloudType>
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++,
61 PatchInteractionModel<CloudType>::New
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
88template<class CloudType>
90(
91 const dictionary& dict,
93)
94:
96{
97 read(this->coeffDict());
98}
99
100
101template<class CloudType>
103(
105)
106:
108 oneInteractionOnly_(pim.oneInteractionOnly_),
109 models_(pim.models_)
110{}
111
112
113// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
114
115template<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
129template<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
179template<class CloudType>
181{
182 for (auto& m : models_)
183 {
184 m.postEvolve();
185 }
186}
187
188
189template<class CloudType>
191{
192 for (auto& m : models_)
193 {
194 Info<< "Patch interaction model " << m.type() << ':' << endl;
195 m.info(os);
196 }
197}
198
199
200// ************************************************************************* //
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:220
InfoProxy< IOstream > info() const
Return info proxy.
Definition: IOstream.H:413
Runs multiple patch interaction models in turn. Takes dictionary where all the subdictionaries are th...
virtual void postEvolve()
Post-evolve hook.
virtual bool active() const
Flag to indicate whether model activates patch interaction model.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Templated patch interaction model class.
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
virtual bool read()
Re-read model coefficients if they have changed.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:63
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
InfoProxy< ensightCells > info() const
Return info proxy.
Definition: ensightCells.H:254
label index() const noexcept
The index of this patch in the boundaryMesh.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
Definition: subModelBase.C:131
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:78
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333