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-------------------------------------------------------------------------------
11License
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
34namespace Foam
35{
36namespace regionModels
37{
38namespace surfaceFilmModels
39{
40
41// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42
45
46// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47
49(
51 const dictionary& dict
52)
53:
54 injectionModel(type(), film, dict),
55 deltaStable_(coeffDict_.getOrDefault<scalar>("deltaStable", 0))
56{
59 (
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);
78 }
79 else
80 {
81 Info<< " applying to all patches" << endl;
82
83 forAll(patchIDs_, patchi)
84 {
85 patchIDs_[patchi] = patchi;
86 }
87
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",
158 )
159 );
160
163 patchInjectedMasses0 += patchInjectedMassTotals;
164
165 setModelProperty<scalarField>
166 (
167 "patchInjectedMasses",
168 patchInjectedMasses0
169 );
170
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// ************************************************************************* //
scalar delta
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
void setSize(const label n)
Alias for resize()
Definition: List.H:218
static void listCombineGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
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.
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1310
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:371
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
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.
Base class for film injection models, handling mass transfer from the film.
void addToInjectedMass(const scalar dMass)
Add to injected mass.
Remove and inject the mass in the film as it passes over the selected patches.
scalarField patchInjectedMasses_
Injected mass for each patch at which the film is removed.
scalar deltaStable_
Stable film thickness - mass only removed if thickness exceeds.
virtual void patchInjectedMassTotals(scalarField &patchMasses) const
Accumulate the total mass injected for the patches into the.
labelList patchIDs_
List of patch IDs at which the film is removed.
virtual const volScalarField & rho() const =0
Return the film density [kg/m3].
virtual const volScalarField & delta() const =0
Return the film thickness [m].
const dictionary coeffDict_
Coefficients dictionary.
Definition: subModelBase.H:82
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
wordList patchNames(nPatches)
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333