Loading...
Searching...
No Matches
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>
33bool 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++,
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;
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 }
174
175 return interacted;
176}
177
178
179template<class CloudType>
181{
182 for (auto& m : models_)
184 m.postEvolve();
185 }
186}
187
188
189template<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// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const CloudType & owner() const
Return const access to the owner cloud.
InfoProxy< IOstream > info() const noexcept
Return info proxy, used to print IOstream information to a stream.
Definition IOstream.H:551
Runs multiple patch interaction models in turn. Takes dictionary where all the subdictionaries are th...
virtual void postEvolve()
Post-evolve hook.
MultiInteraction(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
virtual bool correct(typename CloudType::parcelType &p, const polyPatch &pp, bool &keepParticle)
Apply velocity correction.
virtual void info()
Write patch interaction.
virtual bool active() const
Flag to indicate whether model activates patch interaction model.
Templated patch interaction model class.
PatchInteractionModel(CloudType &owner)
Construct null from owner.
virtual void info()
Write patch interaction info.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A cloud is a registry collection of lagrangian particles.
Definition cloud.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
const dictionary & dict() const
Return const access to the cloud dictionary.
volScalarField & p
#define Log_
Report write to Foam::Info if the class log switch is true.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition BitOps.H:73
DSMCCloud< dsmcParcel > CloudType
messageStream Info
Information stream (stdout output on master, null elsewhere).
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299