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 -------------------------------------------------------------------------------
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 Class
28  Foam::functionObjects::fluxSummary
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
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 
45 Usage
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 
89 Note
90  For surface and direction, phi='U' can be used for determining the fluxes.
91 
92 SourceFiles
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 
107 namespace Foam
108 {
109 
110 // Forward Declarations
111 class dimensionSet;
112 
113 namespace functionObjects
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class fluxSummary Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class fluxSummary
121 :
122  public fvMeshFunctionObject,
123  public writeFile
124 {
125 public:
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 
143 protected:
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
151  modeType mode_;
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
199  void initialiseSurface
200  (
201  const word& surfName,
203  DynamicList<vector>& dir,
204  DynamicList<boolList>& faceFlip
205  ) const;
206 
207  //- Initialise for given surface name and direction
209  (
210  const word& surfName,
211  const vector& refDir,
213  DynamicList<vector>& dir,
214  DynamicList<boolList>& faceFlip
215  ) const;
216 
217  //- Initialise face set from face zone
218  void initialiseFaceZone
219  (
220  const word& faceZoneName,
223  DynamicList<labelList>& faceID,
224  DynamicList<labelList>& facePatchID,
225  DynamicList<boolList>& faceFlip
226  ) const;
227 
228  //- Initialise face set from face zone and direction
230  (
231  const word& faceZoneName,
232  const vector& refDir,
234  DynamicList<vector>& dir,
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,
246  DynamicList<vector>& dir,
247  DynamicList<labelList>& faceID,
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 
271 public:
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 // ************************************************************************* //
modeType mode_
Mode for face determination/to generate faces to test.
Definition: fluxSummary.H:212
dictionary dict
virtual bool write()
Write the function-object results.
Definition: fluxSummary.C:1094
List< labelList > faceID_
Face IDs.
Definition: fluxSummary.H:240
scalar totalArea(const label idx) const
Calculate the total area for the surface or derived faceZone.
Definition: fluxSummary.C:662
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition: fluxSummary.C:966
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
Computes the volumetric- or mass-flux information across selections of face zones.
Definition: fluxSummary.H:173
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
fluxSummary(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition: fluxSummary.C:940
List< labelList > facePatchID_
Face patch IDs.
Definition: fluxSummary.H:245
engineTime & runTime
bool update()
Initialise - after read(), before write()
Definition: fluxSummary.C:785
List< boolList > faceFlip_
Face flip map signs.
Definition: fluxSummary.H:250
word phiName_
Name of flux field.
Definition: fluxSummary.H:222
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:365
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual ~fluxSummary()=default
Destructor.
const word & name() const noexcept
Return the name of this functionObject.
List< word > zoneNames_
Region (zone/surface) names.
Definition: fluxSummary.H:230
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
bool surfaceModeWrite()
Specialized write for surfaces.
Definition: fluxSummary.C:702
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:257
bool isSurfaceMode() const
Check if surface mode instead of zone mode.
Definition: fluxSummary.C:63
PtrList< OFstream > filePtrs_
Output file per face zone.
Definition: fluxSummary.H:255
A class for handling words, derived from Foam::string.
Definition: word.H:63
void operator=(const fluxSummary &)=delete
No copy assignment.
virtual bool execute()
Execute the function-object operations.
Definition: fluxSummary.C:1088
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
static const Enum< modeType > modeTypeNames_
Face mode names.
Definition: fluxSummary.H:197
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
scalar scaleFactor_
Factor to scale results.
Definition: fluxSummary.H:217
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: PtrList.H:56
const wordList area
Standard area field types (scalar, vector, tensor, etc)
virtual void writeFileHeader(const word &zoneName, const scalar area, const vector &refDir, Ostream &os) const
Output file header information.
Definition: fluxSummary.C:1046
void initialiseSurface(const word &surfName, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< boolList > &faceFlip) const
Initialise for given surface name.
Definition: fluxSummary.C:100
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:174
auto & names
List< vector > zoneDirections_
Region (zone/surface) directions.
Definition: fluxSummary.H:235
word checkFlowType(const dimensionSet &fieldDims, const word &fieldName) const
Check flowType (mass or volume)
Definition: fluxSummary.C:70
scalar tolerance_
Tolerance applied when matching face normals.
Definition: fluxSummary.H:261
bool needsUpdate_
Track if the surface needs an update.
Definition: fluxSummary.H:207
TypeName("fluxSummary")
Runtime type information.
Namespace for OpenFOAM.
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:126