transferModelList.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) 2017 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 "transferModelList.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace regionModels
33 {
34 namespace surfaceFilmModels
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
39 transferModelList::transferModelList(surfaceFilmModel& film)
40 :
42  filmSubModelBase(film)
43 {}
44 
45 
46 transferModelList::transferModelList
47 (
48  surfaceFilmModel& film,
49  const dictionary& dict
50 )
51 :
54  (
55  "transferModelList",
56  film,
57  dict,
58  "transferModelList",
59  "transferModelList"
60  ),
61  massTransferred_(film.intCoupledPatchIDs().size(), 0.0)
62 {
63  const wordList activeModels
64  (
65  dict.lookupOrDefault("transferModels", wordList())
66  );
67 
68  wordHashSet models;
69  forAll(activeModels, i)
70  {
71  models.insert(activeModels[i]);
72  }
73 
74  Info<< " Selecting film transfer models" << endl;
75  if (models.size() > 0)
76  {
77  this->setSize(models.size());
78 
79  label i = 0;
80  forAllConstIter(wordHashSet, models, iter)
81  {
82  const word& model = iter.key();
83  set(i, transferModel::New(film, dict, model));
84  i++;
85  }
86  }
87  else
88  {
89  Info<< " none" << endl;
90  }
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 (
104  scalarField& availableMass,
105  volScalarField& massToTransfer
106 )
107 {
108  // Correct models that accumulate mass and diameter transfers
109  forAll(*this, i)
110  {
111  operator[](i).correct(availableMass, massToTransfer);
112  }
113 
114  // Push values to boundaries ready for transfer to the primary region
115  massToTransfer.correctBoundaryConditions();
116 
117  const labelList& patchIDs = film().intCoupledPatchIDs();
118 
119  forAll(patchIDs, i)
120  {
121  label patchi = patchIDs[i];
122  massTransferred_[i] =
123  massTransferred_[i] + sum(massToTransfer.boundaryField()[patchi]);
124  }
125 }
126 
127 
129 (
130  scalarField& availableMass,
131  volScalarField& massToTransfer,
132  volScalarField& energyToTransfer
133 )
134 {
135  // Correct models that accumulate mass and diameter transfers
136  forAll(*this, i)
137  {
138  operator[](i).correct(availableMass, massToTransfer, energyToTransfer);
139  }
140 
141  // Push values to boundaries ready for transfer to the primary region
142  massToTransfer.correctBoundaryConditions();
143  energyToTransfer.correctBoundaryConditions();
144 
145  const labelList& patchIDs = film().intCoupledPatchIDs();
146 
147  forAll(patchIDs, i)
148  {
149  label patchi = patchIDs[i];
150  massTransferred_[i] =
151  massTransferred_[i] + sum(massToTransfer.boundaryField()[patchi]);
152  }
153 }
154 
155 
157 {
158  const polyBoundaryMesh& pbm = film().regionMesh().boundaryMesh();
159 
160  scalar transferredMass = 0;
161  scalarField patchTransferredMasses
162  (
164  0
165  );
166 
167  forAll(*this, i)
168  {
169  const transferModel& im = operator[](i);
170  transferredMass += im.transferredMassTotal();
171  im.patchTransferredMassTotals(patchTransferredMasses);
172  }
173 
174  os << indent << "transferred mass = " << transferredMass << nl;
175 
176  forAll(patchTransferredMasses, patchi)
177  {
178  if (mag(patchTransferredMasses[patchi]) > VSMALL)
179  {
180  os << indent << indent << "from patch " << pbm[patchi].name()
181  << " = " << patchTransferredMasses[patchi] << nl;
182  }
183  }
184 
185  scalarField mass0(massTransferred_.size(), 0);
186  this->getBaseProperty("massTransferred", mass0);
187 
188  scalarField mass(massTransferred_);
190  mass += mass0;
191 
192  const labelList& patchIDs = film().intCoupledPatchIDs();
193 
194  forAll(patchIDs, i)
195  {
196  label patchi = patchIDs[i];
197  Info<< indent << " - patch: " << pbm[patchi].name() << ": "
198  << mass[i] << endl;
199  }
200 
201  if (film().time().writeTime())
202  {
203  setBaseProperty("massTransferred", mass);
204  massTransferred_ = 0.0;
205  }
206 }
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace surfaceFilmModels
212 } // End namespace regionModels
213 } // End namespace Foam
214 
215 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:424
const surfaceFilmModel & film() const
Return const access to the film surface film model.
A HashTable with keys but without contents.
Definition: HashSet.H:59
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
const labelList & processorPatches() const
Return list of processor patch labels.
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
const word & name() const
Return name.
Definition: IOobject.H:291
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:223
static autoPtr< transferModel > New(surfaceFilmModel &film, const dictionary &dict, const word &modelType)
Return a reference to the selected injection model.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Base class for film transfer models, handling mass transfer between the film and the continuous phase...
Definition: transferModel.H:56
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
const T & operator[](const label) const
Return element const reference.
Definition: UPtrListI.H:103
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
virtual bool writeTime() const
Flag to indicate when to write a property.
virtual scalar transferredMassTotal() const
Return the total mass transferred.
virtual void correct(scalarField &availableMass, volScalarField &massToTransfer)
Correct kinematic transfers.
A class for handling words, derived from string.
Definition: word.H:59
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1182
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:131
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void info(Ostream &os)
Provide some info.
static const char nl
Definition: Ostream.H:262
virtual void patchTransferredMassTotals(scalarField &patchMasses) const
Accumulate the total mass transferred for the patches into the.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
label patchi
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
void setBaseProperty(const word &entryName, const Type &value)
Add generic property to the base model.
void correctBoundaryConditions()
Correct boundary field.
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
Type getBaseProperty(const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const
Retrieve generic property from the base model.
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:179
Namespace for OpenFOAM.