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) 2011-2015 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 "injectionModelList.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace regionModels
33 {
34 namespace surfaceFilmModels
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
39 injectionModelList::injectionModelList(surfaceFilmModel& owner)
40 :
42  filmSubModelBase(owner)
43 {}
44 
45 
46 injectionModelList::injectionModelList
47 (
49  const dictionary& dict
50 )
51 :
54  (
55  "injectionModelList",
56  owner,
57  dict,
58  "injectionModelList",
59  "injectionModelList"
60  ),
61  massInjected_(owner.intCoupledPatchIDs().size(), 0.0)
62 {
63  const wordList activeModels(dict.lookup("injectionModels"));
64 
65  wordHashSet models;
66  forAll(activeModels, i)
67  {
68  models.insert(activeModels[i]);
69  }
70 
71  Info<< " Selecting film injection models" << endl;
72  if (models.size() > 0)
73  {
74  this->setSize(models.size());
75 
76  label i = 0;
77  forAllConstIter(wordHashSet, models, iter)
78  {
79  const word& model = iter.key();
80  set(i, injectionModel::New(owner, dict, model));
81  i++;
82  }
83  }
84  else
85  {
86  Info<< " none" << endl;
87  }
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
100 (
101  scalarField& availableMass,
102  volScalarField& massToInject,
103  volScalarField& diameterToInject
104 )
105 {
106  // Correct models that accumulate mass and diameter transfers
107  forAll(*this, i)
108  {
109  injectionModel& im = operator[](i);
110  im.correct(availableMass, massToInject, diameterToInject);
111  }
112 
113  // Push values to boundaries ready for transfer to the primary region
114  massToInject.correctBoundaryConditions();
115  diameterToInject.correctBoundaryConditions();
116 
117  const labelList& patchIDs = owner().intCoupledPatchIDs();
118 
119  forAll(patchIDs, i)
120  {
121  label patchi = patchIDs[i];
122  massInjected_[i] =
123  massInjected_[i] + sum(massToInject.boundaryField()[patchi]);
124  }
125 }
126 
127 
129 {
130  const polyBoundaryMesh& pbm = owner().regionMesh().boundaryMesh();
131 
132  scalar injectedMass = 0;
133  scalarField patchInjectedMasses(pbm.size(), 0);
134 
135  forAll(*this, i)
136  {
137  const injectionModel& im = operator[](i);
138  injectedMass += im.injectedMassTotal();
139  im.patchInjectedMassTotals(patchInjectedMasses);
140  }
141 
142  os << indent << "injected mass = " << injectedMass << nl;
143 
144  forAll(pbm, patchi)
145  {
146  if (mag(patchInjectedMasses[patchi]) > VSMALL)
147  {
148  os << indent << indent << "from patch " << pbm[patchi].name()
149  << " = " << patchInjectedMasses[patchi] << nl;
150  }
151  }
152 
153  scalarField mass0(massInjected_.size(), 0.0);
154  this->getBaseProperty("massInjected", mass0);
155 
156  scalarField mass(massInjected_);
158  mass += mass0;
159 
160  const labelList& patchIDs = owner().intCoupledPatchIDs();
161 
162  forAll(patchIDs, i)
163  {
164  label patchi = patchIDs[i];
165  Info<< indent << " - patch: " << pbm[patchi].name() << ": "
166  << mass[i] << endl;
167  }
168 
169  if (owner().time().outputTime())
170  {
171  setBaseProperty("massInjected", mass);
172  massInjected_ = 0.0;
173  }
174 }
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace surfaceFilmModels
180 } // End namespace regionModels
181 } // End namespace Foam
182 
183 // ************************************************************************* //
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:193
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
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
dimensioned< scalar > mag(const dimensioned< Type > &)
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
void setBaseProperty(const word &entryName, const Type &value)
Add generic property to the base model.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Base class for film injection models, handling mass transfer from the film.
virtual void info(Ostream &os)
Provide some info.
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
virtual void patchInjectedMassTotals(scalarField &patchMasses) const
Accumulate the total mass injected for the patches into the.
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual scalar injectedMassTotal() const
Return the total mass injected.
Foam::polyBoundaryMesh.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const surfaceFilmModel & owner() const
Return const access to the owner surface film model.
#define forAll(list, i)
Definition: UList.H:421
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
label patchi
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const word & name() const
Return name.
Definition: IOobject.H:260
static autoPtr< injectionModel > New(surfaceFilmModel &owner, const dictionary &dict, const word &mdoelType)
Return a reference to the selected injection model.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
void correctBoundaryConditions()
Correct boundary field.
A HashTable with keys but without contents.
Definition: HashSet.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Type getBaseProperty(const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const
Retrieve generic property from the base model.
virtual bool outputTime() const
Flag to indicate when to write a property.
virtual void correct(scalarField &availableMass, volScalarField &massToInject, volScalarField &diameterToInject)
Correct.
const injectionModel & operator[](const label) const
Return element const reference.