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 -------------------------------------------------------------------------------
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 "InjectionModel.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class CloudType>
34 :
36 {}
37 
38 
39 template<class CloudType>
41 (
42  const dictionary& dict,
43  CloudType& owner
44 )
45 :
47 {
48  Info<< "Constructing particle injection models" << endl;
49 
50  label count = dict.size();
51  if (count)
52  {
53  this->resize(count);
54  }
55 
56  count = 0;
57  for (const entry& dEntry : dict)
58  {
59  const word& model = dEntry.keyword();
60  const dictionary& props = dEntry.dict();
61 
62  Info<< "Creating injector: " << model << endl;
63 
64  this->set
65  (
66  count,
68  (
69  props,
70  model,
71  props.get<word>("type"),
72  owner
73  )
74  );
75 
76  ++count;
77  }
78 
79  if (!count)
80  {
81  this->resize(1);
82 
83  this->set
84  (
85  0,
87  (
88  dict,
89  "none",
90  "none",
91  owner
92  )
93  );
94  }
95 }
96 
97 
98 template<class CloudType>
100 (
102 )
103 :
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 
110 template<class CloudType>
112 {}
113 
114 
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 
117 template<class CloudType>
119 {
120  scalar minTime = GREAT;
121  forAll(*this, i)
122  {
123  minTime = min(minTime, this->operator[](i).timeStart());
124  }
125 
126  return minTime;
127 }
128 
129 
130 template<class CloudType>
132 {
133  scalar maxTime = -GREAT;
134  forAll(*this, i)
135  {
136  maxTime = max(maxTime, this->operator[](i).timeEnd());
137  }
138 
139  return maxTime;
140 }
141 
142 
143 template<class CloudType>
145 (
146  const scalar time0,
147  const scalar time1
148 )
149 {
150  scalar vol = 0.0;
151  forAll(*this, i)
152  {
153  vol += this->operator[](i).volumeToInject(time0, time1);
154  }
155 
156  return vol;
157 }
158 
159 
160 template<class CloudType>
162 {
163  scalar mass = 0.0;
164  scalar massTotal = 0.0;
165  forAll(*this, i)
166  {
167  scalar mt = this->operator[](i).massTotal();
168  mass += mt*this->operator[](i).averageParcelMass();
169  massTotal += mt;
170  }
171 
172  return mass/massTotal;
173 }
174 
175 
176 template<class CloudType>
178 {
179  forAll(*this, i)
180  {
181  this->operator[](i).updateMesh();
182  }
183 }
184 
185 
186 template<class CloudType>
187 template<class TrackCloudType>
189 (
190  TrackCloudType& cloud,
191  typename CloudType::parcelType::trackingData& td
192 )
193 {
194  forAll(*this, i)
195  {
196  this->operator[](i).inject(cloud, td);
197  }
198 }
199 
200 
201 template<class CloudType>
202 template<class TrackCloudType>
204 (
205  TrackCloudType& cloud,
206  typename CloudType::parcelType::trackingData& td,
207  const scalar trackTime
208 )
209 {
210  forAll(*this, i)
211  {
212  this->operator[](i).injectSteadyState(cloud, td, trackTime);
213  }
214 }
215 
216 
217 template<class CloudType>
219 {
220  forAll(*this, i)
221  {
222  this->operator[](i).info(os);
223  }
224 }
225 
226 
227 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::InjectionModelList::inject
void inject(TrackCloudType &cloud, typename CloudType::parcelType::trackingData &td)
Main injection loop.
Definition: InjectionModelList.C:189
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::InjectionModelList::injectSteadyState
void injectSteadyState(TrackCloudType &cloud, typename CloudType::parcelType::trackingData &td, const scalar trackTime)
Main injection loop - steady-state.
Definition: InjectionModelList.C:204
Foam::InjectionModel
Templated injection model class.
Definition: InjectionModel.H:73
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
InjectionModel.H
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::InjectionModelList::timeEnd
scalar timeEnd() const
Return the maximum end-of-injection time.
Definition: InjectionModelList.C:131
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::InjectionModelList::averageParcelMass
scalar averageParcelMass()
Return the average parcel mass.
Definition: InjectionModelList.C:161
Foam::InjectionModelList::volumeToInject
scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
Definition: InjectionModelList.C:145
resize
patchWriters resize(patchIds.size())
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::InjectionModelList::~InjectionModelList
virtual ~InjectionModelList()
Destructor.
Definition: InjectionModelList.C:111
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
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
os
OBJstream os(runTime.globalPath()/outputName)
Foam::InjectionModelList::InjectionModelList
InjectionModelList(CloudType &owner)
Construct null from owner.
Definition: InjectionModelList.C:33
Foam::InjectionModelList::updateMesh
void updateMesh()
Set injector locations when mesh is updated.
Definition: InjectionModelList.C:177
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::InjectionModelList::info
virtual void info(Ostream &os)
Write injection info to stream.
Definition: InjectionModelList.C:218
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::InjectionModelList::timeStart
scalar timeStart() const
Return the minimum start-of-injection time.
Definition: InjectionModelList.C:118
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::InjectionModelList
List of injection models.
Definition: KinematicCloud.H:83