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