transferModelList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2021 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 
40 :
42  filmSubModelBase(film)
43 {}
44 
45 
47 (
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  Info<< " Selecting film transfer" << endl;
64 
65  if (dict.isDict("transfer"))
66  {
67  const dictionary& transferDict(dict.subDict("transfer"));
68  this->setSize(transferDict.size());
69 
70  label i = 0;
71  forAllConstIter(dictionary, transferDict, iter)
72  {
73  set
74  (
75  i++,
77  (
78  film,
79  transferDict.isDict(iter().keyword())
80  ? transferDict.subDict(iter().keyword())
82  iter().keyword()
83  )
84  );
85  }
86  }
87  else if (dict.found("transferModels"))
88  {
89  const wordList models(dict.lookup("transferModels"));
90  this->setSize(models.size());
91 
92  forAll(models, i)
93  {
94  set(i, transferModel::New(film, dict, models[i]));
95  }
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 (
110  scalarField& availableMass,
111  volScalarField& massToTransfer,
112  volVectorField& momentumToTransfer
113 )
114 {
115  // Correct models that accumulate mass and diameter transfers
116  forAll(*this, i)
117  {
118  operator[](i).correct
119  (
120  availableMass,
121  massToTransfer,
122  momentumToTransfer
123  );
124  }
125 
126  // Push values to boundaries ready for transfer to the primary region
127  massToTransfer.correctBoundaryConditions();
128 
129  const labelList& patchIDs = film().intCoupledPatchIDs();
130 
131  forAll(patchIDs, i)
132  {
133  label patchi = patchIDs[i];
134  massTransferred_[i] =
135  massTransferred_[i] + sum(massToTransfer.boundaryField()[patchi]);
136  }
137 }
138 
139 
141 (
142  scalarField& availableMass,
143  volScalarField& massToTransfer,
144  volVectorField& momentumToTransfer,
145  volScalarField& energyToTransfer
146 )
147 {
148  // Correct models that accumulate mass and diameter transfers
149  forAll(*this, i)
150  {
151  operator[](i).correct
152  (
153  availableMass,
154  massToTransfer,
155  momentumToTransfer,
156  energyToTransfer
157  );
158  }
159 
160  // Push values to boundaries ready for transfer to the primary region
161  massToTransfer.correctBoundaryConditions();
162  momentumToTransfer.correctBoundaryConditions();
163  energyToTransfer.correctBoundaryConditions();
164 
165  const labelList& patchIDs = film().intCoupledPatchIDs();
166 
167  forAll(patchIDs, i)
168  {
169  label patchi = patchIDs[i];
170  massTransferred_[i] =
171  massTransferred_[i] + sum(massToTransfer.boundaryField()[patchi]);
172  }
173 }
174 
175 
177 {
178  const polyBoundaryMesh& pbm = film().regionMesh().boundaryMesh();
179 
180  scalar transferredMass = 0;
181  scalarField patchTransferredMasses
182  (
184  0
185  );
186 
187  forAll(*this, i)
188  {
189  const transferModel& im = operator[](i);
190  transferredMass += im.transferredMassTotal();
191  im.patchTransferredMassTotals(patchTransferredMasses);
192  }
193 
194  os << indent << "transferred mass = " << transferredMass << nl;
195 
196  forAll(patchTransferredMasses, patchi)
197  {
198  if (mag(patchTransferredMasses[patchi]) > vSmall)
199  {
200  os << indent << indent << "from patch " << pbm[patchi].name()
201  << " = " << patchTransferredMasses[patchi] << nl;
202  }
203  }
204 
205  scalarField mass0(massTransferred_.size(), 0);
206  this->getBaseProperty("massTransferred", mass0);
207 
208  scalarField mass(massTransferred_);
210  mass += mass0;
211 
212  const labelList& patchIDs = film().intCoupledPatchIDs();
213 
214  forAll(patchIDs, i)
215  {
216  label patchi = patchIDs[i];
217  Info<< indent << " - patch: " << pbm[patchi].name() << ": "
218  << mass[i] << endl;
219  }
220 
221  if (film().time().writeTime())
222  {
223  setBaseProperty("massTransferred", mass);
224  massTransferred_ = 0.0;
225  }
226 }
227 
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 } // End namespace surfaceFilmModels
232 } // End namespace regionModels
233 } // End namespace Foam
234 
235 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:453
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const labelList & processorPatches() const
Return list of processor patch labels.
const word & name() const
Return name.
Definition: IOobject.H:315
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Base class for surface film sub-models.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
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:164
const T & operator[](const label) const
Return element const reference.
Definition: UPtrListI.H:96
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:956
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
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.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
virtual scalar transferredMassTotal() const
Return the total mass transferred.
Definition: transferModel.C:92
virtual void correct(scalarField &availableMass, volScalarField &massToTransfer, volVectorField &momentumToTransfer)
Correct kinematic transfers.
transferModelList(surfaceFilmRegionModel &film)
Construct null.
static const dictionary null
Null dictionary.
Definition: dictionary.H:242
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:55
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1435
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:54
virtual void info(Ostream &os)
Provide some info.
static const char nl
Definition: Ostream.H:260
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
static autoPtr< transferModel > New(surfaceFilmRegionModel &film, const dictionary &dict, const word &modelType)
Return a reference to the selected ejection model.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
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:173
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864