power.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2024-2025 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::functionObjects::power
26 
27 Description
28  Evaluates and writes the following power fields.
29  \verbatim
30  + tauUSf: tauf & Uf
31  + divTauU: fvc::div(tauUSf)
32  + divTauDotU: fvc::div(tauf) & U
33  + tauDDotGradU: divTauU - divTauDotU
34 
35  + pUSf: -pIf & Uf
36  + divPU: fvc::div(pUSf)
37  + gradPU: -fvc::grad(p) & U
38  + pDivU: divPU - gradPU
39 
40  + stressUSf: tauUSf + pUSf
41  + divStressU: fvc::div(stressUSf)
42  + divStressDotU: fvc::div(stressf) & U
43  + stressDDotGradU: divStressU - divStressDotU
44  \endverbatim
45 
46  where:
47  \verbatim
48  + p, U = cell centre pressure and velocity
49  + pIf, Uf = face normal pressure force, and velocity, vectors
50  + tauf = face shear force vectors [-transport.devTau()*mesh().magSf()]
51  + stressf = tauf - pIf
52  \endverbatim
53 
54  The domain integral of the volume fields (all except '...Sf' fields) is also
55  printed to a log file in the postProcessing directory. Domain integrals are
56  scaled by a factor, which defaults to 1e9, to make them easier to process.
57 
58 Usage
59  An example is given below of a function object specification in the
60  system/functions file with a scaling factor of 1e6 for the domain integrals
61  \verbatim
62  power
63  {
64  type power;
65  libs ("libfieldFunctionObjects.so");
66  executeControl writeTime;
67  writeControl writeTime;
68  log true;
69  factor 1e6;
70  }
71  \endverbatim
72 
73  Alternatively it can be specified using the standard 'power' function object
74  configuration file as follows
75  \verbatim
76  #includeFunc power(factor=1e6)
77  \endverbatim
78 
79 See also
80  Foam::functionObject
81  Foam::functionObjects::fvMeshFunctionObject
82  Foam::functionObjects::logFiles
83  Foam::functionObjects::writeLocalObjects
84  Foam::functionObjects::timeControl
85 
86 SourceFiles
87  power.C
88 
89 \*---------------------------------------------------------------------------*/
90 
91 #ifndef power_functionObject_H
92 #define power_functionObject_H
93 
94 #include "fvMeshFunctionObject.H"
95 #include "logFiles.H"
96 #include "writeLocalObjects.H"
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 namespace Foam
101 {
102 namespace functionObjects
103 {
104 
105 /*---------------------------------------------------------------------------*\
106  Class power Declaration
107 \*---------------------------------------------------------------------------*/
108 
109 class power
110 :
111  public fvMeshFunctionObject,
112  public logFiles,
113  public writeLocalObjects
114 {
115  // Private Static data
116 
117  //- List of the power field names
118  static const wordList fields_;
119 
120 
121  // Private Member data
122 
123  //- Scaling factor for the power output (defaults to 1e9)
124  scalar factor_;
125 
126 
127  // Private Member Functions
128 
129  //- File header information
130  virtual void writeFileHeader(const label i);
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("power");
137 
138 
139  // Constructors
140 
141  //- Construct from Time and dictionary
142  power
143  (
144  const word& name,
145  const Time& runTime,
146  const dictionary& dict
147  );
148 
149  //- Disallow default bitwise copy construction
150  power(const power&) = delete;
151 
152 
153  //- Destructor
154  virtual ~power();
155 
156 
157  // Member Functions
158 
159  //- Read the power data
160  virtual bool read(const dictionary&);
161 
162  //- Return the list of fields required
163  virtual wordList fields() const
164  {
165  return wordList::null();
166  }
167 
168  //- Calculate the power field
169  virtual bool execute();
170 
171  //- Write the power field
172  virtual bool write();
173 
174 
175  // Member Operators
176 
177  //- Disallow default bitwise assignment
178  void operator=(const power&) = delete;
179 };
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace functionObjects
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #endif
190 
191 // ************************************************************************* //
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
Evaluates and writes the following power fields.
Definition: power.H:113
void operator=(const power &)=delete
Disallow default bitwise assignment.
virtual wordList fields() const
Return the list of fields required.
Definition: power.H:162
power(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: power.C:91
virtual ~power()
Destructor.
Definition: power.C:108
TypeName("power")
Runtime type information.
virtual bool execute()
Calculate the power field.
Definition: power.C:128
virtual bool write()
Write the power field.
Definition: power.C:171
virtual bool read(const dictionary &)
Read the power data.
Definition: power.C:114
FunctionObject base class for managing a list of objects on behalf of the inheriting function object,...
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dictionary dict