InjectionModelList.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) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 2022 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 
29 #include "InjectionModel.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 :
37 {}
38 
39 
40 template<class CloudType>
42 (
43  const dictionary& dict,
44  CloudType& owner
45 )
46 :
48 {
49  Info<< "Constructing particle injection models" << endl;
50 
51  label count = dict.size();
52  if (count)
53  {
54  this->resize(count);
55  }
56 
57  count = 0;
58  for (const entry& dEntry : dict)
59  {
60  const word& model = dEntry.keyword();
61  const dictionary& props = dEntry.dict();
62 
63  Info<< "Creating injector: " << model << endl;
64 
65  this->set
66  (
67  count,
69  (
70  props,
71  model,
72  props.get<word>("type"),
73  owner
74  )
75  );
76 
77  ++count;
78  }
79 
80  if (!count)
81  {
82  this->resize(1);
83 
84  this->set
85  (
86  0,
88  (
89  dict,
90  "none",
91  "none",
92  owner
93  )
94  );
95  }
96 }
97 
98 
99 template<class CloudType>
101 (
102  const InjectionModelList<CloudType>& iml
103 )
104 :
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class CloudType>
113 {
114  scalar minTime = GREAT;
115  for (const auto& model : *this)
116  {
117  minTime = min(minTime, model.timeStart());
118  }
119 
120  return minTime;
121 }
122 
123 
124 template<class CloudType>
126 {
127  scalar maxTime = -GREAT;
128  for (const auto& model : *this)
129  {
130  maxTime = max(maxTime, model.timeEnd());
131  }
133  return maxTime;
134 }
135 
136 
137 template<class CloudType>
139 (
140  const scalar time0,
141  const scalar time1
142 )
143 {
144  scalar vol = 0.0;
145  for (auto& model : *this)
146  {
147  vol += model.volumeToInject(time0, time1);
148  }
149 
150  return vol;
151 }
152 
153 
154 template<class CloudType>
156 {
157  scalar mass = 0.0;
158  scalar massTotal = 0.0;
159  for (auto& model : *this)
160  {
161  scalar mt = model.massTotal();
162  mass += mt*model.averageParcelMass();
163  massTotal += mt;
164  }
165 
166  return mass/massTotal;
167 }
168 
169 
170 template<class CloudType>
172 {
173  for (auto& model : *this)
174  {
175  model.updateMesh();
176  }
177 }
178 
179 
180 template<class CloudType>
181 template<class TrackCloudType>
183 (
184  TrackCloudType& cloud,
185  typename CloudType::parcelType::trackingData& td
186 )
187 {
188  for (auto& model : *this)
189  {
190  model.inject(cloud, td);
191  }
192 }
193 
194 
195 template<class CloudType>
196 template<class TrackCloudType>
198 (
199  TrackCloudType& cloud,
200  typename CloudType::parcelType::trackingData& td,
201  const scalar trackTime
202 )
203 {
204  for (auto& model : *this)
205  {
206  model.injectSteadyState(cloud, td, trackTime);
207  }
208 }
209 
210 
211 template<class CloudType>
213 {
214  for (auto& model : *this)
215  {
216  model.info();
217  }
218 }
219 
220 
221 // ************************************************************************* //
void inject(TrackCloudType &cloud, typename CloudType::parcelType::trackingData &td)
Main injection loop.
dictionary dict
scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
InjectionModelList(CloudType &owner)
Construct null from owner.
patchWriters resize(patchIds.size())
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void updateMesh()
Set injector locations when mesh is updated.
void injectSteadyState(TrackCloudType &cloud, typename CloudType::parcelType::trackingData &td, const scalar trackTime)
Main injection loop - steady-state.
Templated injection model class.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
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.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
scalar timeStart() const
Return the minimum start-of-injection time.
scalar averageParcelMass()
Return the average parcel mass.
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
virtual void info()
Write injection info.
messageStream Info
Information stream (stdout output on master, null elsewhere)
scalar timeEnd() const
Return the maximum end-of-injection time.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67