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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenFOAM Foundation
9  Copyright (C) 2020 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 "transferModelList.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace regionModels
36 {
37 namespace surfaceFilmModels
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 transferModelList::transferModelList(surfaceFilmRegionModel& film)
43 :
45  filmSubModelBase(film)
46 {}
47 
48 
49 transferModelList::transferModelList
50 (
52  const dictionary& dict
53 )
54 :
57  (
58  "transferModelList",
59  film,
60  dict,
61  "transferModelList",
62  "transferModelList"
63  ),
64  massTransferred_(film.intCoupledPatchIDs().size(), Zero)
65 {
66  const wordList activeModels
67  (
68  dict.getOrDefault<wordList>("transferModels", wordList())
69  );
70 
71  wordHashSet models(activeModels);
72 
73  Info<< " Selecting film transfer models" << endl;
74  if (models.size() > 0)
75  {
76  this->setSize(models.size());
77 
78  label i = 0;
79  for (const word& model : models)
80  {
81  set(i, transferModel::New(film, dict, model));
82  i++;
83  }
84  }
85  else
86  {
87  Info<< " none" << endl;
88  }
89 }
90 
91 
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
93 
95 {}
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
101 (
102  scalarField& availableMass,
103  volScalarField& massToTransfer
104 )
105 {
106  // Correct models that accumulate mass and diameter transfers
107  forAll(*this, i)
108  {
109  operator[](i).correct(availableMass, massToTransfer);
110  }
111 
112  // Push values to boundaries ready for transfer to the primary region
113  massToTransfer.correctBoundaryConditions();
114 
115  const labelList& patchIDs = film().intCoupledPatchIDs();
116 
117  forAll(patchIDs, i)
118  {
119  label patchi = patchIDs[i];
120  massTransferred_[i] =
121  massTransferred_[i] + sum(massToTransfer.boundaryField()[patchi]);
122  }
123 }
124 
125 
127 (
128  scalarField& availableMass,
129  volScalarField& massToTransfer,
130  volScalarField& energyToTransfer
131 )
132 {
133  // Correct models that accumulate mass and diameter transfers
134  forAll(*this, i)
135  {
136  operator[](i).correct(availableMass, massToTransfer, energyToTransfer);
137  }
138 
139  // Push values to boundaries ready for transfer to the primary region
140  massToTransfer.correctBoundaryConditions();
141  energyToTransfer.correctBoundaryConditions();
142 
143  const labelList& patchIDs = film().intCoupledPatchIDs();
144 
145  forAll(patchIDs, i)
146  {
147  label patchi = patchIDs[i];
148  massTransferred_[i] =
149  massTransferred_[i] + sum(massToTransfer.boundaryField()[patchi]);
150  }
151 }
152 
153 
155 {
156  const polyBoundaryMesh& pbm = film().regionMesh().boundaryMesh();
157 
158  scalar transferredMass = 0;
159  scalarField patchTransferredMasses
160  (
161  pbm.size() - film().regionMesh().globalData().processorPatches().size(),
162  0
163  );
164 
165  forAll(*this, i)
166  {
167  const transferModel& im = operator[](i);
168  transferredMass += im.transferredMassTotal();
169  im.patchTransferredMassTotals(patchTransferredMasses);
170  }
171 
172  os << indent << "transferred mass = " << transferredMass << nl;
173 
174  forAll(patchTransferredMasses, patchi)
175  {
176  if (mag(patchTransferredMasses[patchi]) > VSMALL)
177  {
178  os << indent << indent << "from patch " << pbm[patchi].name()
179  << " = " << patchTransferredMasses[patchi] << nl;
180  }
181  }
182 
183  scalarField mass0(massTransferred_.size(), Zero);
184  this->getBaseProperty("massTransferred", mass0);
185 
186  scalarField mass(massTransferred_);
188  mass += mass0;
189 
190  const labelList& patchIDs = film().intCoupledPatchIDs();
191 
192  forAll(patchIDs, i)
193  {
194  label patchi = patchIDs[i];
195  Info<< indent << " - patch: " << pbm[patchi].name() << ": "
196  << mass[i] << endl;
197  }
198 
199  if (film().time().writeTime())
200  {
201  setBaseProperty("massTransferred", mass);
202  massTransferred_ = 0.0;
203  }
204 }
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace surfaceFilmModels
210 } // End namespace regionModels
211 } // End namespace Foam
212 
213 // ************************************************************************* //
setSize
points setSize(newPointi)
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::regionModels::surfaceFilmModels::transferModelList::correct
virtual void correct(scalarField &availableMass, volScalarField &massToTransfer)
Correct kinematic transfers.
Definition: transferModelList.C:101
Foam::regionModels::surfaceFilmModels::transferModelList::info
virtual void info(Ostream &os)
Provide some info.
Definition: transferModelList.C:154
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
transferModelList.H
Foam::subModelBase::getBaseProperty
Type getBaseProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from the base model.
Definition: subModelBaseTemplates.C:32
Foam::regionModels::surfaceFilmModels::filmSubModelBase::writeTime
virtual bool writeTime() const
Flag to indicate when to write a property.
Definition: filmSubModelBase.C:98
Foam::regionModels::surfaceFilmModels::filmSubModelBase::film
const surfaceFilmRegionModel & film() const
Return const access to the film surface film model.
Definition: filmSubModelBaseI.H:39
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::HashSet< word, Hash< word > >
Foam::globalMeshData::processorPatches
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
Definition: globalMeshData.H:381
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::regionModels::surfaceFilmModels::transferModel::transferredMassTotal
virtual scalar transferredMassTotal() const
Return the total mass transferred.
Definition: transferModel.C:105
Foam::Field< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
Foam::regionModels::surfaceFilmModels::transferModel::patchTransferredMassTotals
virtual void patchTransferredMassTotals(scalarField &patchMasses) const
Accumulate the total mass transferred for the patches into the.
Definition: transferModel.H:160
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
Foam::Pstream::listCombineGather
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
Definition: combineGatherScatter.C:290
Foam::IOobject::name
const word & name() const noexcept
Return name.
Definition: IOobjectI.H:65
Foam::regionModels::surfaceFilmModels::transferModel
Base class for film transfer models, handling mass transfer between the film and the continuous phase...
Definition: transferModel.H:58
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< word >
Foam::subModelBase::setBaseProperty
void setBaseProperty(const word &entryName, const Type &value)
Add generic property to the base model.
Definition: subModelBaseTemplates.C:66
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
Foam::regionModels::surfaceFilmModels::transferModelList::~transferModelList
virtual ~transferModelList()
Destructor.
Definition: transferModelList.C:94
Foam::regionModels::surfaceFilmModels::transferModel::New
static autoPtr< transferModel > New(surfaceFilmRegionModel &film, const dictionary &dict, const word &modelType)
Return a reference to the selected injection model.
Definition: transferModelNew.C:43
Foam::plusEqOp
Definition: ops.H:72
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1295
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::regionModels::regionModel::intCoupledPatchIDs
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:175
Foam::regionModels::surfaceFilmModels::filmSubModelBase
Base class for surface film sub-models.
Definition: filmSubModelBase.H:56
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62