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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2018 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 "injectionModelList.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace regionModels
36 {
37 namespace surfaceFilmModels
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 injectionModelList::injectionModelList(surfaceFilmRegionModel& film)
43 :
45  filmSubModelBase(film)
46 {}
47 
48 
49 injectionModelList::injectionModelList
50 (
52  const dictionary& dict
53 )
54 :
57  (
58  "injectionModelList",
59  film,
60  dict,
61  "injectionModelList",
62  "injectionModelList"
63  ),
64  massInjected_(film.intCoupledPatchIDs().size(), Zero)
65 {
66  const wordList activeModels(dict.lookup("injectionModels"));
67 
68  wordHashSet models(activeModels);
69 
70  Info<< " Selecting film injection models" << endl;
71  if (models.size())
72  {
73  this->setSize(models.size());
74 
75  label i = 0;
76  for (const word& model : models)
77  {
78  set(i, injectionModel::New(film, dict, model));
79  i++;
80  }
81  }
82  else
83  {
84  Info<< " none" << endl;
85  }
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
90 
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
98 (
99  scalarField& availableMass,
100  volScalarField& massToInject,
101  volScalarField& diameterToInject
102 )
103 {
104  // Correct models that accumulate mass and diameter transfers
105  forAll(*this, i)
106  {
107  injectionModel& im = operator[](i);
108  im.correct(availableMass, massToInject, diameterToInject);
109  }
110 
111  // Push values to boundaries ready for transfer to the primary region
112  massToInject.correctBoundaryConditions();
113  diameterToInject.correctBoundaryConditions();
114 
116 
117  forAll(patchIDs, i)
118  {
119  label patchi = patchIDs[i];
120  massInjected_[i] =
121  massInjected_[i] + sum(massToInject.boundaryField()[patchi]);
122  }
123 }
124 
125 
127 {
129 
130  scalar injectedMass = 0;
131  scalarField patchInjectedMasses
132  (
133  pbm.size() - film().regionMesh().globalData().processorPatches().size(),
134  0
135  );
136 
137  forAll(*this, i)
138  {
139  const injectionModel& im = operator[](i);
140  injectedMass += im.injectedMassTotal();
141  im.patchInjectedMassTotals(patchInjectedMasses);
142  }
143 
144  os << indent << "injected mass = " << injectedMass << nl;
145 
146  forAll(patchInjectedMasses, patchi)
147  {
148  if (mag(patchInjectedMasses[patchi]) > VSMALL)
149  {
150  os << indent << indent << "from patch " << pbm[patchi].name()
151  << " = " << patchInjectedMasses[patchi] << nl;
152  }
153  }
154 
155  scalarField mass0(massInjected_.size(), Zero);
156  this->getBaseProperty("massInjected", mass0);
157 
158  scalarField mass(massInjected_);
159  Pstream::listCombineGather(mass, plusEqOp<scalar>());
160  mass += mass0;
161 
163 
164  forAll(patchIDs, i)
165  {
166  label patchi = patchIDs[i];
167  Info<< indent << " - patch: " << pbm[patchi].name() << ": "
168  << mass[i] << endl;
169  }
170 
171  if (film().time().writeTime())
172  {
173  setBaseProperty("massInjected", mass);
174  massInjected_ = 0.0;
175  }
176 }
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace surfaceFilmModels
182 } // End namespace regionModels
183 } // End namespace Foam
184 
185 // ************************************************************************* //
const labelList patchIDs(pbm.indices(polyPatchNames, true))
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream. ...
Definition: dictionary.C:367
const polyBoundaryMesh & pbm
const T & operator[](const label i) const
Return const reference to the element at given position. FatalError for bounds problem or nullptr...
Definition: UPtrListI.H:289
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
virtual void correct(scalarField &availableMass, volScalarField &massToInject, volScalarField &diameterToInject)
Correct.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:493
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Base class for surface film sub-models.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Type getBaseProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from the base model.
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
virtual void info(Ostream &os)
Provide some info.
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:104
const surfaceFilmRegionModel & film() const
Return const access to the film surface film model.
virtual bool writeTime() const
Flag to indicate when to write a property.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
const labelList & intCoupledPatchIDs() const noexcept
List of patch IDs internally coupled with the primary region.
Definition: regionModelI.H:97
static autoPtr< injectionModel > New(surfaceFilmRegionModel &film, const dictionary &dict, const word &mdoelType)
Return a reference to the selected injection model.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:608
A class for handling words, derived from Foam::string.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:26
const globalMeshData & globalData() const
Return parallel info (demand-driven)
Definition: polyMesh.C:1311
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
Base class for film injection models, handling mass transfer from the film.
OBJstream os(runTime.globalPath()/outputName)
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:337
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
void setBaseProperty(const word &entryName, const Type &value)
Add generic property to the base model.
void correctBoundaryConditions()
Correct boundary field.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static void listCombineGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
List< label > labelList
A List of labels.
Definition: List.H:62
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127