CloudFunctionObjectList.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  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "entry.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class CloudType>
36 (
37  CloudType& owner
38 )
39 :
41  owner_(owner),
42  dict_()
43 {}
44 
45 
46 template<class CloudType>
48 (
49  CloudType& owner,
50  const dictionary& dict,
51  const bool readFields
52 )
53 :
55  owner_(owner),
56  dict_(dict)
57 {
58  if (readFields)
59  {
60  Info<< "Constructing cloud functions" << endl;
61 
62  this->resize(dict.size());
63 
64  label count = 0;
65  for (const word& modelName : dict.toc())
66  {
67  const dictionary& modelDict = dict.subDict(modelName);
68 
69  {
70  this->set
71  (
72  count,
74  (
75  modelDict,
76  owner,
77  modelDict.get<word>("type"),
78  modelName
79  )
80  );
81  }
82  ++count;
83  }
84 
85  if (!count)
86  {
87  Info<< " none" << endl;
88  }
89  }
90 }
91 
92 
93 template<class CloudType>
95 (
96  const CloudFunctionObjectList& cfol
97 )
98 :
100  owner_(cfol.owner_),
101  dict_(cfol.dict_)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 template<class CloudType>
109 (
110  const typename parcelType::trackingData& td
111 )
112 {
113  forAll(*this, i)
114  {
115  this->operator[](i).preEvolve(td);
116  }
117 }
118 
119 
120 template<class CloudType>
122 (
123  const typename parcelType::trackingData& td
124 )
125 {
126  forAll(*this, i)
127  {
128  this->operator[](i).postEvolve(td);
129  }
130 }
131 
132 
133 template<class CloudType>
135 (
136  parcelType& p,
137  const scalar dt,
138  const point& position0,
139  bool& keepParticle
140 )
141 {
142  forAll(*this, i)
143  {
144  if (!keepParticle)
145  {
146  return;
147  }
148 
149  this->operator[](i).postMove(p, dt, position0, keepParticle);
150  }
151 }
152 
153 
154 template<class CloudType>
156 (
157  const parcelType& p,
158  const polyPatch& pp,
159  bool& keepParticle
160 )
161 {
162  forAll(*this, i)
163  {
164  if (!keepParticle)
165  {
166  return;
167  }
168 
169  this->operator[](i).postPatch(p, pp, keepParticle);
170  }
171 }
172 
173 
174 template<class CloudType>
176 (
177  const parcelType& p,
178  bool& keepParticle
179 )
180 {
181  forAll(*this, i)
182  {
183  if (!keepParticle)
184  {
185  return;
186  }
187 
188  this->operator[](i).postFace(p, keepParticle);
189  }
190 }
191 
192 
193 // ************************************************************************* //
Foam::CloudFunctionObjectList::postEvolve
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
Definition: CloudFunctionObjectList.C:122
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::CloudFunctionObjectList::postPatch
virtual void postPatch(const parcelType &p, const polyPatch &pp, bool &keepParticle)
Post-patch hook.
Definition: CloudFunctionObjectList.C:156
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::CloudFunctionObjectList::owner_
const CloudType & owner_
Reference to the owner cloud.
Definition: CloudFunctionObjectList.H:69
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
entry.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
resize
patchWriters resize(patchIds.size())
CloudFunctionObjectList.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::CloudFunctionObjectList::postFace
virtual void postFace(const parcelType &p, bool &keepParticle)
Post-face hook.
Definition: CloudFunctionObjectList.C:176
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:123
Foam::CloudFunctionObjectList
List of cloud function objects.
Definition: CloudFunctionObjectList.H:54
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::Vector< scalar >
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:62
Foam::CloudFunctionObjectList::dict_
const dictionary dict_
Dictionary.
Definition: CloudFunctionObjectList.H:72
Foam::CloudFunctionObjectList::CloudFunctionObjectList
CloudFunctionObjectList(CloudType &owner)
Null constructor.
Definition: CloudFunctionObjectList.C:36
Foam::CloudFunctionObjectList::postMove
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: CloudFunctionObjectList.C:135
Foam::CloudFunctionObjectList::preEvolve
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
Definition: CloudFunctionObjectList.C:109