patchInjection.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) 2015-2017 OpenFOAM Foundation
9  Copyright (C) 2018-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 "patchInjection.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace regionModels
37 {
38 namespace surfaceFilmModels
39 {
40 
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 
43 defineTypeNameAndDebug(patchInjection, 0);
44 addToRunTimeSelectionTable(injectionModel, patchInjection, dictionary);
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 patchInjection::patchInjection
49 (
51  const dictionary& dict
52 )
53 :
54  injectionModel(type(), film, dict),
55  deltaStable_(coeffDict_.getOrDefault<scalar>("deltaStable", 0))
56 {
57  const polyBoundaryMesh& pbm = film.regionMesh().boundaryMesh();
58  patchIDs_.setSize
59  (
60  pbm.size() - film.regionMesh().globalData().processorPatches().size()
61  );
62 
64  if (coeffDict_.readIfPresent("patches", patchNames))
65  {
66  const labelHashSet patchSet = pbm.patchSet(patchNames);
67 
68  Info<< " applying to patches:" << nl;
69 
70  label pidi = 0;
71  for (const label patchi : patchSet)
72  {
73  patchIDs_[pidi++] = patchi;
74  Info<< " " << pbm[patchi].name() << endl;
75  }
76  patchIDs_.setSize(pidi);
77  patchInjectedMasses_.setSize(pidi, 0);
78  }
79  else
80  {
81  Info<< " applying to all patches" << endl;
82 
83  forAll(patchIDs_, patchi)
84  {
85  patchIDs_[patchi] = patchi;
86  }
87 
88  patchInjectedMasses_.setSize(patchIDs_.size(), 0);
89  }
90 
91  if (!patchIDs_.size())
92  {
94  << "No patches selected"
95  << exit(FatalError);
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
103 {}
104 
105 
106 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
107 
109 (
110  scalarField& availableMass,
111  scalarField& massToInject,
112  scalarField& diameterToInject
113 )
114 {
115  // Do not correct if no patches selected
116  if (!patchIDs_.size()) return;
117 
118  const scalarField& delta = film().delta();
119  const scalarField& rho = film().rho();
120  const scalarField& magSf = film().magSf();
121 
122  const polyBoundaryMesh& pbm = film().regionMesh().boundaryMesh();
123 
124  forAll(patchIDs_, pidi)
125  {
126  label patchi = patchIDs_[pidi];
127  const polyPatch& pp = pbm[patchi];
128  const labelList& faceCells = pp.faceCells();
129 
130  // Accumulate the total mass removed from patch
131  scalar dMassPatch = 0;
132 
133  forAll(faceCells, fci)
134  {
135  label celli = faceCells[fci];
136 
137  scalar ddelta = max(0.0, delta[celli] - deltaStable_);
138  scalar dMass = ddelta*rho[celli]*magSf[celli];
139  massToInject[celli] += dMass;
140  availableMass[celli] -= dMass;
141  dMassPatch += dMass;
142  }
143 
144  patchInjectedMasses_[pidi] += dMassPatch;
145  addToInjectedMass(dMassPatch);
146  }
147 
149 
150  if (writeTime())
151  {
152  scalarField patchInjectedMasses0
153  (
154  getModelProperty<scalarField>
155  (
156  "patchInjectedMasses",
157  scalarField(patchInjectedMasses_.size(), 0)
158  )
159  );
160 
161  scalarField patchInjectedMassTotals(patchInjectedMasses_);
162  Pstream::listCombineGather(patchInjectedMassTotals, plusEqOp<scalar>());
163  patchInjectedMasses0 += patchInjectedMassTotals;
164 
165  setModelProperty<scalarField>
166  (
167  "patchInjectedMasses",
168  patchInjectedMasses0
169  );
170 
171  patchInjectedMasses_ = 0;
172  }
173 }
174 
175 
177 {
178  // Do not correct if no patches selected
179  if (!patchIDs_.size()) return;
180 
181  scalarField patchInjectedMasses
182  (
183  getModelProperty<scalarField>
184  (
185  "patchInjectedMasses",
187  )
188  );
189 
192 
193  forAll(patchIDs_, pidi)
194  {
195  label patchi = patchIDs_[pidi];
196  patchMasses[patchi] +=
197  patchInjectedMasses[pidi] + patchInjectedMassTotals[pidi];
198  }
199 }
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace surfaceFilmModels
205 } // End namespace regionModels
206 } // End namespace Foam
207 
208 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::regionModels::surfaceFilmModels::injectionModel::correct
void correct()
Correct.
Definition: injectionModel.C:81
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:70
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::regionModels::surfaceFilmModels::patchInjection::patchInjectedMasses_
scalarField patchInjectedMasses_
Injected mass for each patch at which the film is removed.
Definition: patchInjection.H:78
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::globalMeshData::processorPatches
const labelList & processorPatches() const
Return list of processor patch labels.
Definition: globalMeshData.H:381
Foam::regionModels::surfaceFilmModels::patchInjection::patchInjectedMassTotals
virtual void patchInjectedMassTotals(scalarField &patchMasses) const
Accumulate the total mass injected for the patches into the.
Definition: patchInjection.C:176
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel::delta
virtual const volScalarField & delta() const =0
Return the film thickness [m].
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:350
Foam::regionModels::surfaceFilmModels::patchInjection::~patchInjection
virtual ~patchInjection()
Destructor.
Definition: patchInjection.C:102
Foam::regionModels::surfaceFilmModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(surfaceFilmRegionModel, kinematicSingleLayer, mesh)
Foam::HashSet< label, Hash< label > >
rho
rho
Definition: readInitialConditions.H:88
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::regionModels::surfaceFilmModels::patchInjection::patchIDs_
labelList patchIDs_
List of patch IDs at which the film is removed.
Definition: patchInjection.H:75
Foam::Field< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::regionModels::singleLayerRegion::magSf
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
Definition: singleLayerRegion.C:223
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
delta
scalar delta
Definition: LISASMDCalcMethod2.H:8
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrListI.H:105
patchNames
wordList patchNames(nPatches)
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::regionModels::surfaceFilmModels::injectionModel
Base class for film injection models, handling mass transfer from the film.
Definition: injectionModel.H:58
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel::rho
virtual const volScalarField & rho() const =0
Return the film density [kg/m3].
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:363
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
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::regionModels::surfaceFilmModels::defineTypeNameAndDebug
defineTypeNameAndDebug(kinematicSingleLayer, 0)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::List< label >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
patchInjection.H
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::polyBoundaryMesh::patchSet
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
Definition: polyBoundaryMesh.C:862
Foam::plusEqOp
Definition: ops.H:72
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1295
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56