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-------------------------------------------------------------------------------
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 "InjectionModel.H"
29
30// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31
32template<class CloudType>
34:
36{}
37
38
39template<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();
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 }
96
97
98template<class CloudType>
100(
102)
103:
105{}
106
107
108// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109
110template<class CloudType>
112{}
113
114
115// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116
117template<class CloudType>
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
130template<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
143template<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
160template<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
176template<class CloudType>
178{
179 forAll(*this, i)
180 {
181 this->operator[](i).updateMesh();
182 }
183}
184
185
186template<class CloudType>
187template<class TrackCloudType>
189(
190 TrackCloudType& cloud,
192)
193{
194 forAll(*this, i)
195 {
196 this->operator[](i).inject(cloud, td);
197 }
198}
199
200
201template<class CloudType>
202template<class TrackCloudType>
204(
205 TrackCloudType& cloud,
207 const scalar trackTime
208)
209{
210 forAll(*this, i)
211 {
212 this->operator[](i).injectSteadyState(cloud, td, trackTime);
213 }
214}
215
216
217template<class CloudType>
219{
220 forAll(*this, i)
221 {
222 this->operator[](i).info(os);
223 }
224}
225
226
227// ************************************************************************* //
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
List of injection models.
void inject(TrackCloudType &cloud, typename CloudType::parcelType::trackingData &td)
Main injection loop.
virtual ~InjectionModelList()
Destructor.
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.
scalar averageParcelMass()
Return the average parcel mass.
void injectSteadyState(TrackCloudType &cloud, typename CloudType::parcelType::trackingData &td, const scalar trackTime)
Main injection loop - steady-state.
void updateMesh()
Set injector locations when mesh is updated.
scalar timeEnd() const
Return the maximum end-of-injection time.
Templated injection model class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
const InjectionModel< CloudType > * set(const label i) const
Definition: PtrList.H:138
void resize(const label newLen)
Adjust size of PtrList.
Definition: PtrList.C:103
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
InfoProxy< ensightCells > info() const
Return info proxy.
Definition: ensightCells.H:254
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
Class used to pass data into container.
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333