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_;
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;
204 
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;
212 
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,
230  ) const;
231 
232  //- Initialise face set from face zone
233  void initialiseFaceZone
234  (
235  const word& faceZoneName,
237  DynamicList<vector>& dir,
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 // ************************************************************************* //
Foam::functionObjects::fluxSummary::zoneNames_
List< word > zoneNames_
Region (zone/surface) names.
Definition: fluxSummary.H:235
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
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
writeFile.H
Foam::Enum< modeType >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::fluxSummary::faceFlip_
List< boolList > faceFlip_
Face flip map signs.
Definition: fluxSummary.H:247
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
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
Foam::functionObjects::fluxSummary::scaleFactor_
scalar scaleFactor_
Factor to scale results.
Definition: fluxSummary.H:226
fvMeshFunctionObject.H
Foam::DynamicList< word >
Foam::functionObjects::fluxSummary::surfaceModeWrite
bool surfaceModeWrite()
Specialized write for surfaces.
Definition: fluxSummary.C:697
Foam::functionObjects::fluxSummary::faceID_
List< labelList > faceID_
Face IDs.
Definition: fluxSummary.H:241
Foam::functionObjects::fluxSummary::isSurfaceMode
bool isSurfaceMode() const
Check if surface mode instead of zone mode.
Definition: fluxSummary.C:70
Foam::functionObjects::fluxSummary::mdSurface
A functionObject surface.
Definition: fluxSummary.H:207
Foam::functionObjects::fluxSummary::checkFlowType
word checkFlowType(const dimensionSet &fieldDims, const word &fieldName) const
Check flowType (mass or volume)
Definition: fluxSummary.C:77
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:108
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::fluxSummary::needsUpdate_
bool needsUpdate_
Track if the surface needs an update.
Definition: fluxSummary.H:220
Foam::functionObjects::fluxSummary::execute
virtual bool execute()
Execute, currently does nothing.
Definition: fluxSummary.C:1083
Foam::functionObjects::fluxSummary::totalArea
scalar totalArea(const label idx) const
Calculate the total area for the surface or derived faceZone.
Definition: fluxSummary.C:657
Foam::functionObjects::fluxSummary::modeTypeNames_
static const Enum< modeType > modeTypeNames_
Face mode names.
Definition: fluxSummary.H:212
Foam::functionObjects::fluxSummary::phiName_
word phiName_
Name of flux field.
Definition: fluxSummary.H:229
Foam::functionObjects::fluxSummary::writeFileHeader
virtual void writeFileHeader(const word &zoneName, const scalar area, const vector &refDir, Ostream &os) const
Output file header information.
Definition: fluxSummary.C:1041
Foam::functionObjects::fluxSummary::fluxSummary
fluxSummary(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fluxSummary.C:935
Foam::functionObjects::fluxSummary::initialiseSurface
void initialiseSurface(const word &surfName, DynamicList< word > &names, DynamicList< vector > &dir, DynamicList< boolList > &faceFlip) const
Initialise for given surface name.
Definition: fluxSummary.C:107
Foam::functionObjects::fluxSummary::initialiseFaceZone
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
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::functionObjects::fluxSummary::mdSurfaceAndDirection
A surface with prescribed direction.
Definition: fluxSummary.H:208
Foam::functionObjects::fluxSummary::mode_
modeType mode_
Mode for face determination/to generate faces to test.
Definition: fluxSummary.H:223
Foam::functionObjects::fluxSummary::tolerance_
scalar tolerance_
Tolerance applied when matching face normals.
Definition: fluxSummary.H:254
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::fluxSummary::write
virtual bool write()
Write the fluxSummary.
Definition: fluxSummary.C:1089
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::fluxSummary::mdFaceZone
Face zone.
Definition: fluxSummary.H:204
os
OBJstream os(runTime.globalPath()/outputName)
Foam::functionObjects::fluxSummary::initialiseSurfaceAndDirection
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
Foam::functionObjects::fluxSummary::TypeName
TypeName("fluxSummary")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::fluxSummary::zoneDirections_
List< vector > zoneDirections_
Region (zone/surface) directions.
Definition: fluxSummary.H:238
Foam::functionObjects::fluxSummary::modeType
modeType
Face mode type.
Definition: fluxSummary.H:202
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fluxSummary::operator=
void operator=(const fluxSummary &)=delete
No copy assignment.
Foam::Vector< scalar >
Foam::List< word >
Foam::functionObjects::fluxSummary::read
virtual bool read(const dictionary &dict)
Read the field fluxSummary data.
Definition: fluxSummary.C:961
Foam::fieldTypes::area
const wordList area
Standard area field types (scalar, vector, tensor, etc)
vector.H
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
DynamicList.H
Foam::functionObjects::fluxSummary::filePtrs_
PtrList< OFstream > filePtrs_
Output file per face zone.
Definition: fluxSummary.H:250
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::fluxSummary
Computes the volumetric- or mass-flux information across selections of face zones.
Definition: fluxSummary.H:192
Foam::functionObjects::fluxSummary::mdFaceZoneAndDirection
Face zone with prescribed direction.
Definition: fluxSummary.H:205
Foam::PtrListOps::names
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Foam::functionObjects::fluxSummary::facePatchID_
List< labelList > facePatchID_
Face patch IDs.
Definition: fluxSummary.H:244
Foam::functionObjects::fluxSummary::update
bool update()
Initialise - after read(), before write()
Definition: fluxSummary.C:780
Foam::functionObjects::fluxSummary::mdCellZoneAndDirection
Cell zone with prescribed direction.
Definition: fluxSummary.H:206
Foam::functionObjects::fluxSummary::~fluxSummary
virtual ~fluxSummary()=default
Destructor.