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 | Copyright (C) 2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "InjectionModel.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class CloudType>
32 :
34 {}
35 
36 
37 template<class CloudType>
39 (
40  const dictionary& dict,
41  CloudType& owner
42 )
43 :
45 {
46  wordList modelNames(dict.toc());
47 
48  Info<< "Constructing particle injection models" << endl;
49 
50  if (modelNames.size() > 0)
51  {
52  this->setSize(modelNames.size());
53 
54  label i = 0;
55  forAllConstIter(IDLList<entry>, dict, iter)
56  {
57  const word& model = iter().keyword();
58  Info<< "Creating injector: " << model << endl;
59  const dictionary& props = iter().dict();
60 
61  this->set
62  (
63  i++,
65  (
66  props,
67  model,
68  props.lookup("type"),
69  owner
70  )
71  );
72  }
73  }
74  else
75  {
76  this->setSize(1);
77 
78  this->set
79  (
80  0,
82  (
83  dict,
84  "none",
85  "none",
86  owner
87  )
88  );
89  }
90 }
91 
92 
93 template<class CloudType>
95 (
97 )
98 :
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
104 
105 template<class CloudType>
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 template<class CloudType>
114 {
115  scalar minTime = GREAT;
116  forAll(*this, i)
117  {
118  minTime = min(minTime, this->operator[](i).timeStart());
119  }
120 
121  return minTime;
122 }
123 
124 
125 template<class CloudType>
127 {
128  scalar maxTime = -GREAT;
129  forAll(*this, i)
130  {
131  maxTime = max(maxTime, this->operator[](i).timeEnd());
132  }
133 
134  return maxTime;
135 }
136 
137 
138 template<class CloudType>
140 (
141  const scalar time0,
142  const scalar time1
143 )
144 {
145  scalar vol = 0.0;
146  forAll(*this, i)
147  {
148  vol += this->operator[](i).volumeToInject(time0, time1);
149  }
150 
151  return vol;
152 }
153 
154 
155 template<class CloudType>
157 {
158  scalar mass = 0.0;
159  scalar massTotal = 0.0;
160  forAll(*this, i)
161  {
162  scalar mt = this->operator[](i).massTotal();
163  mass += mt*this->operator[](i).averageParcelMass();
164  massTotal += mt;
165  }
166 
167  return mass/massTotal;
168 }
169 
170 
171 template<class CloudType>
173 {
174  forAll(*this, i)
175  {
176  this->operator[](i).updateMesh();
177  }
178 }
179 
180 
181 template<class CloudType>
182 template<class TrackData>
184 {
185  forAll(*this, i)
186  {
187  this->operator[](i).inject(td);
188  }
189 }
190 
191 
192 template<class CloudType>
193 template<class TrackData>
195 (
196  TrackData& td,
197  const scalar trackTime
198 )
199 {
200  forAll(*this, i)
201  {
202  this->operator[](i).injectSteadyState(td, trackTime);
203  }
204 }
205 
206 
207 template<class CloudType>
209 {
210  forAll(*this, i)
211  {
212  this->operator[](i).info(os);
213  }
214 }
215 
216 
217 // ************************************************************************* //
void inject(TrackData &td)
Main injection loop.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
static autoPtr< InjectionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector with lookup from dictionary.
scalar averageParcelMass()
Return the average parcel mass.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
wordList toc() const
Return the table of contents.
Definition: dictionary.C:707
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define forAll(list, i)
Definition: UList.H:421
virtual ~InjectionModelList()
Destructor.
Templated injection model class.
scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
scalar timeStart() const
Return the minimum start-of-injection time.
void injectSteadyState(TrackData &td, const scalar trackTime)
Main injection loop - steady-state.
void updateMesh()
Set injector locations when mesh is updated.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
virtual void info(Ostream &os)
Write injection info to stream.
scalar timeEnd() const
Return the maximum end-of-injection time.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const InjectionModel< CloudType > & operator[](const label) const
Return element const reference.
List of injection models.
InjectionModelList(CloudType &owner)
Construct null from owner.