fluxSummary.H
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 OpenFOAM Foundation
9 Copyright (C) 2015-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
27Class
28 Foam::functionObjects::fluxSummary
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Computes the volumetric- or mass-flux
35 information across selections of face zones.
36
37 Operands:
38 \table
39 Operand | Type | Location
40 input | - | -
41 output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<faceN>
42 output field | - | -
43 \endtable
44
45Usage
46 Minimal example by using \c system/controlDict.functions:
47 \verbatim
48 fluxSummary1
49 {
50 // Mandatory entries (unmodifiable)
51 type fluxSummary;
52 libs (fieldFunctionObjects);
53
54 // Mandatory entries (runtime modifiable)
55 mode cellZoneAndDirection;
56 cellZoneAndDirection
57 (
58 (porosity (1 0 0))
59 );
60
61 // Optional entries (runtime modifiable)
62 phi phi;
63 scaleFactor 1.0;
64 tolerance 0.8;
65
66 // Optional (inherited) entries
67 ...
68 }
69 \endverbatim
70
71 where the entries mean:
72 \table
73 Property | Description | Type | Req'd | Dflt
74 type | Type name: fluxSummary | word | yes | -
75 libs | Library name: fieldFunctionObjects | word | yes | -
76 mode | Mode to generate faces to test | word | yes | -
77 phi | Name of surface flux field | word | no | phi
78 scaleFactor | Factor to scale results | scalar | no | 1.0
79 tolerance | Tolerance for reference direction | scalar | no | 0.8
80 \endtable
81
82 Options for the \c mode entry:
83 \verbatim
84 faceZone
85 faceZoneAndDirection
86 cellZoneAndDirection
87 surface
88 surfaceAndDirection
89 \endverbatim
90
91 The inherited entries are elaborated in:
92 - \link functionObject.H \endlink
93 - \link writeFile.H \endlink
94
95 Usage by the \c postProcess utility is not available.
96
97Note
98 For surface and direction, phi='U' can be used for determining the fluxes.
99
100See also
101 - Foam::functionObject
102 - Foam::functionObjects::fvMeshFunctionObject
103 - Foam::functionObjects::writeFile
104 - Foam::functionObjects::timeControl
105 - ExtendedCodeGuide::functionObjects::field::fluxSummary
106
107SourceFiles
108 fluxSummary.C
109
110\*---------------------------------------------------------------------------*/
111
112#ifndef functionObjects_fluxSummary_H
113#define functionObjects_fluxSummary_H
114
115#include "fvMeshFunctionObject.H"
116#include "writeFile.H"
117#include "vector.H"
118#include "DynamicList.H"
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121
122namespace Foam
123{
124
125// Forward Declarations
126class dimensionSet;
127
128namespace functionObjects
129{
130
131/*---------------------------------------------------------------------------*\
132 Class fluxSummary Declaration
133\*---------------------------------------------------------------------------*/
134
135class fluxSummary
136:
137 public fvMeshFunctionObject,
138 public writeFile
139{
140public:
141
142 // Public Enumerations
143
144 //- Face mode type
145 enum modeType
146 {
147 mdFaceZone,
150 mdSurface,
152 };
153
154 //- Face mode names
155 static const Enum<modeType> modeTypeNames_;
156
157
158protected:
159
160 // Protected Data
161
162 //- Track if the surface needs an update
163 bool needsUpdate_;
164
165 //- Mode for face determination/to generate faces to test
167
168 //- Factor to scale results
169 scalar scaleFactor_;
170
171 //- Name of flux field
172 word phiName_;
173
174
175 // Per-faceZone/surface information
176
177 //- Region (zone/surface) names
178 List<word> zoneNames_;
179
180 //- Region (zone/surface) directions
181 List<vector> zoneDirections_;
182
183 //- Face IDs
184 List<labelList> faceID_;
185
186 //- Face patch IDs
187 List<labelList> facePatchID_;
188
189 //- Face flip map signs
190 List<boolList> faceFlip_;
191
192 //- Output file per face zone
194
195
196 //- Tolerance applied when matching face normals
197 scalar tolerance_;
198
199
200 // Protected Member Functions
201
202 //- Check if surface mode instead of zone mode
203 bool isSurfaceMode() const;
205 //- Check flowType (mass or volume)
206 // Return name on success, fatal error on failure.
208 (
209 const dimensionSet& fieldDims,
210 const word& fieldName
211 ) const;
213 //- Initialise for given surface name
215 (
216 const word& surfName,
217 DynamicList<word>& names,
219 DynamicList<boolList>& faceFlip
220 ) const;
221
222 //- Initialise for given surface name and direction
224 (
225 const word& surfName,
226 const vector& refDir,
227 DynamicList<word>& names,
230 ) const;
231
232 //- Initialise face set from face zone
234 (
235 const word& faceZoneName,
236 DynamicList<word>& names,
239 DynamicList<labelList>& facePatchID,
240 DynamicList<boolList>& faceFlip
241 ) const;
242
243 //- Initialise face set from face zone and direction
245 (
246 const word& faceZoneName,
247 const vector& refDir,
248 DynamicList<word>& names,
251 DynamicList<labelList>& facePatchID,
252 DynamicList<boolList>& faceFlip
253 ) const;
255 //- Initialise face set from cell zone and direction
257 (
258 const word& cellZoneName,
259 const vector& refDir,
260 DynamicList<word>& names,
263 DynamicList<labelList>& facePatchID,
264 DynamicList<boolList>& faceFlip
265 ) const;
266
267 //- Calculate the total area for the surface or derived faceZone
268 scalar totalArea(const label idx) const;
269
270 //- Initialise - after read(), before write()
271 bool update();
272
273 //- Output file header information
274 virtual void writeFileHeader
275 (
276 const word& zoneName,
277 const scalar area,
278 const vector& refDir,
279 Ostream& os
280 ) const;
281
282 //- Specialized write for surfaces
283 bool surfaceModeWrite();
284
285
286public:
287
288 //- Runtime type information
289 TypeName("fluxSummary");
290
291
292 // Constructors
293
294 //- Construct from Time and dictionary
296 (
297 const word& name,
298 const Time& runTime,
299 const dictionary& dict
300 );
301
302 //- No copy construct
303 fluxSummary(const fluxSummary&) = delete;
304
305 //- No copy assignment
306 void operator=(const fluxSummary&) = delete;
307
308
309 //- Destructor
310 virtual ~fluxSummary() = default;
311
312
313 // Member Functions
314
315 //- Read the field fluxSummary data
316 virtual bool read(const dictionary& dict);
317
318 //- Execute, currently does nothing
319 virtual bool execute();
320
321 //- Write the fluxSummary
322 virtual bool write();
323};
324
325
326// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
327
328} // End namespace functionObjects
329} // End namespace Foam
330
331// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332
333#endif
334
335// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
const word & name() const noexcept
Return the name of this functionObject.
Computes the volumetric- or mass-flux information across selections of face zones.
Definition: fluxSummary.H:196
scalar scaleFactor_
Factor to scale results.
Definition: fluxSummary.H:226
void initialiseFaceZoneAndDirection(const word &faceZoneName, const vector &refDir, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< labelList > &faceID, DynamicList< labelList > &facePatchID, DynamicList< boolList > &faceFlip) const
Initialise face set from face zone and direction.
Definition: fluxSummary.C:258
fluxSummary(const fluxSummary &)=delete
No copy construct.
List< labelList > facePatchID_
Face patch IDs.
Definition: fluxSummary.H:244
List< vector > zoneDirections_
Region (zone/surface) directions.
Definition: fluxSummary.H:238
PtrList< OFstream > filePtrs_
Output file per face zone.
Definition: fluxSummary.H:250
void initialiseCellZoneAndDirection(const word &cellZoneName, const vector &refDir, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< labelList > &faceID, DynamicList< labelList > &facePatchID, DynamicList< boolList > &faceFlip) const
Initialise face set from cell zone and direction.
Definition: fluxSummary.C:360
scalar tolerance_
Tolerance applied when matching face normals.
Definition: fluxSummary.H:254
modeType mode_
Mode for face determination/to generate faces to test.
Definition: fluxSummary.H:223
static const Enum< modeType > modeTypeNames_
Face mode names.
Definition: fluxSummary.H:212
scalar totalArea(const label idx) const
Calculate the total area for the surface or derived faceZone.
Definition: fluxSummary.C:657
virtual void writeFileHeader(const word &zoneName, const scalar area, const vector &refDir, Ostream &os) const
Output file header information.
Definition: fluxSummary.C:1041
void initialiseSurfaceAndDirection(const word &surfName, const vector &refDir, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< boolList > &faceFlip) const
Initialise for given surface name and direction.
Definition: fluxSummary.C:133
virtual bool read(const dictionary &dict)
Read the field fluxSummary data.
Definition: fluxSummary.C:961
virtual ~fluxSummary()=default
Destructor.
void initialiseSurface(const word &surfName, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< boolList > &faceFlip) const
Initialise for given surface name.
Definition: fluxSummary.C:107
List< labelList > faceID_
Face IDs.
Definition: fluxSummary.H:241
word checkFlowType(const dimensionSet &fieldDims, const word &fieldName) const
Check flowType (mass or volume)
Definition: fluxSummary.C:77
word phiName_
Name of flux field.
Definition: fluxSummary.H:229
bool isSurfaceMode() const
Check if surface mode instead of zone mode.
Definition: fluxSummary.C:70
void operator=(const fluxSummary &)=delete
No copy assignment.
@ mdCellZoneAndDirection
Cell zone with prescribed direction.
Definition: fluxSummary.H:206
@ mdSurface
A functionObject surface.
Definition: fluxSummary.H:207
@ mdFaceZoneAndDirection
Face zone with prescribed direction.
Definition: fluxSummary.H:205
@ mdSurfaceAndDirection
A surface with prescribed direction.
Definition: fluxSummary.H:208
bool update()
Initialise - after read(), before write()
Definition: fluxSummary.C:780
List< word > zoneNames_
Region (zone/surface) names.
Definition: fluxSummary.H:235
TypeName("fluxSummary")
Runtime type information.
List< boolList > faceFlip_
Face flip map signs.
Definition: fluxSummary.H:247
bool needsUpdate_
Track if the surface needs an update.
Definition: fluxSummary.H:220
virtual bool execute()
Execute, currently does nothing.
Definition: fluxSummary.C:1083
virtual bool write()
Write the fluxSummary.
Definition: fluxSummary.C:1089
bool surfaceModeWrite()
Specialized write for surfaces.
Definition: fluxSummary.C:697
void initialiseFaceZone(const word &faceZoneName, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< labelList > &faceID, DynamicList< labelList > &facePatchID, DynamicList< boolList > &faceFlip) const
Initialise face set from face zone.
Definition: fluxSummary.C:181
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Base class for writing single files from the function objects.
Definition: writeFile.H:120
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73