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
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 
45 Usage
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 
97 Note
98  For surface and direction, phi='U' can be used for determining the fluxes.
99 
100 See also
101  - Foam::functionObject
102  - Foam::functionObjects::fvMeshFunctionObject
103  - Foam::functionObjects::writeFile
104  - Foam::functionObjects::timeControl
105  - ExtendedCodeGuide::functionObjects::field::fluxSummary
106 
107 SourceFiles
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 
122 namespace Foam
123 {
124 
125 // Forward Declarations
126 class dimensionSet;
127 
128 namespace functionObjects
129 {
130 
131 /*---------------------------------------------------------------------------*\
132  Class fluxSummary Declaration
133 \*---------------------------------------------------------------------------*/
134 
135 class fluxSummary
136 :
137  public fvMeshFunctionObject,
138  public writeFile
139 {
140 public:
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 
158 protected:
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
166  modeType mode_;
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_;
189  //- Face flip map signs
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
214  void initialiseSurface
215  (
216  const word& surfName,
218  DynamicList<vector>& dir,
219  DynamicList<boolList>& faceFlip
220  ) const;
221 
222  //- Initialise for given surface name and direction
224  (
225  const word& surfName,
226  const vector& refDir,
228  DynamicList<vector>& dir,
229  DynamicList<boolList>& faceFlip
230  ) const;
231 
232  //- Initialise face set from face zone
233  void initialiseFaceZone
234  (
235  const word& faceZoneName,
238  DynamicList<labelList>& faceID,
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,
249  DynamicList<vector>& dir,
251  DynamicList<labelList>& facePatchID,
252  DynamicList<boolList>& faceFlip
253  ) const;
254 
255  //- Initialise face set from cell zone and direction
257  (
258  const word& cellZoneName,
259  const vector& refDir,
261  DynamicList<vector>& dir,
262  DynamicList<labelList>& faceID,
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 
286 public:
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 // ************************************************************************* //
modeType mode_
Mode for face determination/to generate faces to test.
Definition: fluxSummary.H:227
dictionary dict
virtual bool write()
Write the fluxSummary.
Definition: fluxSummary.C:1094
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
List< labelList > faceID_
Face IDs.
Definition: fluxSummary.H:255
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 field fluxSummary data.
Definition: fluxSummary.C:966
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Computes the volumetric- or mass-flux information across selections of face zones.
Definition: fluxSummary.H:188
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 Time and dictionary.
Definition: fluxSummary.C:940
List< labelList > facePatchID_
Face patch IDs.
Definition: fluxSummary.H:260
engineTime & runTime
bool update()
Initialise - after read(), before write()
Definition: fluxSummary.C:785
List< boolList > faceFlip_
Face flip map signs.
Definition: fluxSummary.H:265
word phiName_
Name of flux field.
Definition: fluxSummary.H:237
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:69
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:245
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:270
const wordList area
Standard area field types (scalar, vector, tensor, etc)
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, currently does nothing.
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:212
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
scalar scaleFactor_
Factor to scale results.
Definition: fluxSummary.H:232
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
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
List< vector > zoneDirections_
Region (zone/surface) directions.
Definition: fluxSummary.H:250
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:276
bool needsUpdate_
Track if the surface needs an update.
Definition: fluxSummary.H:222
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