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 | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fluxSummary
26 
27 Group
28  grpUtilityFunctionObjects
29 
30 Description
31  This function object calculates the flux across selections of faces.
32 
33  Output comprises, per set of faces, the:
34  - positive
35  - negative
36  - net
37  - absolute
38  fluxes
39 
40  Example of function object specification:
41  \verbatim
42  fluxSummary1
43  {
44  type fluxSummary;
45  functionObjectLibs ("libutilityFunctionObjects.so");
46  ...
47  write yes;
48  log yes;
49  mode cellZoneAndDirection;
50  cellZoneAndDirection
51  (
52  (porosity (1 0 0))
53  );
54  scaleFactor 1.2;
55  }
56  \endverbatim
57 
58  \heading Function object usage
59  \table
60  Property | Description | Required | Default value
61  type | type name: fluxSummary | yes |
62  write | write flux data to file | no | yes
63  log | write flux data to standard output | no | yes
64  mode | mode to generate faces to test | yes |
65  scaleFactor | optional factor to scale result | no | 1
66  \endtable
67 
68  The mode is one of:
69  - faceZone
70  - faceZoneAndDirection
71  - cellZoneAndDirection
72 
73  Output data is written to files of the form <timeDir>/<faceZoneName>.dat
74 
75 SeeAlso
76  Foam::functionObject
77  Foam::OutputFilterFunctionObject
78 
79 SourceFiles
80  fluxSummary.C
81  IOfluxSummary.H
82 
83 \*---------------------------------------------------------------------------*/
84 
85 #ifndef fluxSummary_H
86 #define fluxSummary_H
87 
88 #include "functionObjectFile.H"
89 #include "Switch.H"
90 #include "vector.H"
91 #include "DynamicList.H"
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 namespace Foam
96 {
97 
98 // Forward declaration of classes
99 class objectRegistry;
100 class dictionary;
101 class polyMesh;
102 class mapPolyMesh;
103 
104 /*---------------------------------------------------------------------------*\
105  Class fluxSummary Declaration
106 \*---------------------------------------------------------------------------*/
107 
108 class fluxSummary
109 :
110  public functionObjectFile
111 {
112 public:
113 
114  // Public enumerations
115 
116  //- Face mode type
117  enum modeType
118  {
119  mdFaceZone,
122  };
123 
124  //- Mode type names
125  static const NamedEnum<modeType, 3> modeTypeNames_;
126 
127 
128 protected:
129 
130  // Protected data
131 
132  //- Name of function object
133  // Also used as the name of the output directory
134  word name_;
135 
136  //- Reference to the database
138 
139  //- on/off switch
140  bool active_;
141 
142  //- Switch to send output to Info as well
143  Switch log_;
144 
145  //- Mode for face determination
147 
148  //- Scale factor
149  scalar scaleFactor_;
150 
151  //- Name of flux field, default = phi
152  word phiName_;
153 
154 
155  // Per-faceZone information
156 
157  //- Region names
159 
160  //- Reference direction
162 
163  //- Face IDs
165 
166  //- Face patch IDs
168 
169  //- Face flip map signs
171 
172  //- Sum of face areas
174 
175  //- Output file per face zone
177 
178 
179  //- Tolerance applied when matching face normals
180  scalar tolerance_;
181 
182 
183  // Private Member Functions
184 
185  //- Initialise face set from face zone
186  void initialiseFaceZone
187  (
188  const word& faceZoneName,
189  DynamicList<word>& faceZoneNames,
191  DynamicList<List<label> >& facePatchID,
192  DynamicList<List<scalar> >& faceSign
193  ) const;
194 
195  //- Initialise face set from face zone and direction
197  (
198  const word& faceZoneName,
199  const vector& refDir,
200  DynamicList<vector>& dir,
201  DynamicList<word>& faceZoneNames,
203  DynamicList<List<label> >& facePatchID,
204  DynamicList<List<scalar> >& faceSign
205  ) const;
206 
207  //- Initialise face set from cell zone and direction
209  (
210  const word& cellZoneName,
211  const vector& refDir,
212  DynamicList<vector>& dir,
213  DynamicList<word>& faceZoneNames,
214  DynamicList<List<label> >& faceID,
215  DynamicList<List<label> >& facePatchID,
216  DynamicList<List<scalar> >& faceSign
217  ) const;
218 
219  //- Initialise the total area per derived faceZone
220  void initialiseFaceArea();
221 
222  //- Output file header information
223  virtual void writeFileHeader
224  (
225  const word& fzName,
226  const scalar area,
227  const vector& refDir,
228  Ostream& os
229  ) const;
230 
231  //- Disallow default bitwise copy construct
232  fluxSummary(const fluxSummary&);
233 
234  //- Disallow default bitwise assignment
235  void operator=(const fluxSummary&);
236 
237 
238 public:
239 
240  //- Runtime type information
241  TypeName("fluxSummary");
242 
243 
244  // Constructors
245 
246  //- Construct for given objectRegistry and dictionary.
247  // Allow the possibility to load fields from files
249  (
250  const word& name,
251  const objectRegistry&,
252  const dictionary&,
253  const bool loadFromFiles = false
254  );
255 
256 
257  //- Destructor
258  virtual ~fluxSummary();
259 
260 
261  // Member Functions
262 
263  //- Return name of the set of field min/max
264  virtual const word& name() const
265  {
266  return name_;
267  }
268 
269  //- Read the field min/max data
270  virtual void read(const dictionary&);
271 
272  //- Execute, currently does nothing
273  virtual void execute();
274 
275  //- Execute at the final time-loop, currently does nothing
276  virtual void end();
277 
278  //- Called when time was set at the end of the Time::operator++
279  virtual void timeSet();
280 
281  //- Write the fluxSummary
282  virtual void write();
283 
284  //- Update for changes of mesh
285  virtual void updateMesh(const mapPolyMesh&)
286  {}
287 
288  //- Update for changes of mesh
289  virtual void movePoints(const polyMesh&)
290  {}
291 };
292 
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 } // End namespace Foam
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #endif
301 
302 // ************************************************************************* //
Foam::fluxSummary::mdFaceZoneAndDirection
@ mdFaceZoneAndDirection
Definition: fluxSummary.H:149
Foam::fluxSummary::faceZoneName_
List< word > faceZoneName_
Region names.
Definition: fluxSummary.H:187
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::fluxSummary::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: fluxSummary.H:314
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::DynamicList< word >
Foam::fluxSummary::mdFaceZone
@ mdFaceZone
Definition: fluxSummary.H:148
Foam::fluxSummary::obr_
const objectRegistry & obr_
Reference to the database.
Definition: fluxSummary.H:166
Foam::fluxSummary::operator=
void operator=(const fluxSummary &)
Disallow default bitwise assignment.
Foam::fluxSummary
This function object calculates the flux across selections of faces.
Definition: fluxSummary.H:137
Foam::fluxSummary::name_
word name_
Name of function object.
Definition: fluxSummary.H:163
Foam::fluxSummary::TypeName
TypeName("fluxSummary")
Runtime type information.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::fluxSummary::phiName_
word phiName_
Name of flux field, default = phi.
Definition: fluxSummary.H:181
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::fluxSummary::initialiseFaceArea
void initialiseFaceArea()
Initialise the total area per derived faceZone.
Definition: fluxSummary.C:543
Foam::fluxSummary::execute
virtual void execute()
Execute, currently does nothing.
Definition: fluxSummary.C:794
Foam::fluxSummary::scaleFactor_
scalar scaleFactor_
Scale factor.
Definition: fluxSummary.H:178
Foam::fluxSummary::faceSign_
List< List< scalar > > faceSign_
Face flip map signs.
Definition: fluxSummary.H:199
Foam::fluxSummary::facePatchID_
List< List< label > > facePatchID_
Face patch IDs.
Definition: fluxSummary.H:196
Foam::fluxSummary::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: fluxSummary.C:800
Foam::fluxSummary::initialiseCellZoneAndDirection
void initialiseCellZoneAndDirection(const word &cellZoneName, const vector &refDir, DynamicList< vector > &dir, DynamicList< word > &faceZoneNames, DynamicList< List< label > > &faceID, DynamicList< List< label > > &facePatchID, DynamicList< List< scalar > > &faceSign) const
Initialise face set from cell zone and direction.
Definition: fluxSummary.C:262
Foam::fluxSummary::mode_
modeType mode_
Mode for face determination.
Definition: fluxSummary.H:175
Foam::fluxSummary::tolerance_
scalar tolerance_
Tolerance applied when matching face normals.
Definition: fluxSummary.H:209
Switch.H
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::fluxSummary::initialiseFaceZone
void initialiseFaceZone(const word &faceZoneName, DynamicList< word > &faceZoneNames, DynamicList< List< label > > &faceID, DynamicList< List< label > > &facePatchID, DynamicList< List< scalar > > &faceSign) const
Initialise face set from face zone.
Definition: fluxSummary.C:64
Foam::fluxSummary::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: fluxSummary.C:625
Foam::fluxSummary::log_
Switch log_
Switch to send output to Info as well.
Definition: fluxSummary.H:172
Foam::fluxSummary::refDir_
List< vector > refDir_
Reference direction.
Definition: fluxSummary.H:190
Foam::fluxSummary::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fluxSummary.C:806
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fluxSummary::fluxSummary
fluxSummary(const fluxSummary &)
Disallow default bitwise copy construct.
Foam::fluxSummary::~fluxSummary
virtual ~fluxSummary()
Destructor.
Definition: fluxSummary.C:619
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fluxSummary::name
virtual const word & name() const
Return name of the set of field min/max.
Definition: fluxSummary.H:293
Foam::fluxSummary::filePtrs_
PtrList< OFstream > filePtrs_
Output file per face zone.
Definition: fluxSummary.H:205
functionObjectFile.H
Foam::fluxSummary::faceArea_
List< scalar > faceArea_
Sum of face areas.
Definition: fluxSummary.H:202
Foam::fluxSummary::writeFileHeader
virtual void writeFileHeader(const word &fzName, const scalar area, const vector &refDir, Ostream &os) const
Output file header information.
Definition: fluxSummary.C:760
Foam::Vector< scalar >
Foam::List< word >
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
Foam::fluxSummary::mdCellZoneAndDirection
@ mdCellZoneAndDirection
Definition: fluxSummary.H:150
vector.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::fluxSummary::write
virtual void write()
Write the fluxSummary.
Definition: fluxSummary.C:812
Foam::fluxSummary::faceID_
List< List< label > > faceID_
Face IDs.
Definition: fluxSummary.H:193
DynamicList.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fluxSummary::modeType
modeType
Face mode type.
Definition: fluxSummary.H:146
Foam::fluxSummary::modeTypeNames_
static const NamedEnum< modeType, 3 > modeTypeNames_
Mode type names.
Definition: fluxSummary.H:154
Foam::fluxSummary::initialiseFaceZoneAndDirection
void initialiseFaceZoneAndDirection(const word &faceZoneName, const vector &refDir, DynamicList< vector > &dir, DynamicList< word > &faceZoneNames, DynamicList< List< label > > &faceID, DynamicList< List< label > > &facePatchID, DynamicList< List< scalar > > &faceSign) const
Initialise face set from face zone and direction.
Definition: fluxSummary.C:153
Foam::fluxSummary::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: fluxSummary.H:318
Foam::NamedEnum< modeType, 3 >
Foam::fluxSummary::active_
bool active_
on/off switch
Definition: fluxSummary.H:169