forces.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 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::forces
26 
27 Description
28  Calculates the forces and moments by integrating the pressure and
29  skin-friction forces over a given list of patches.
30 
31  Member function forces::write() calculates the forces/moments and
32  writes the forces/moments into the file <timeDir>/forces.dat and bin
33  data (if selected) to the file <timeDir>/forces_bin.dat
34 
35  Example of function object specification:
36  \verbatim
37  forces1
38  {
39  type forces;
40  libs ("libforces.so");
41  ...
42  log yes;
43  patches (walls);
44 
45  binData
46  {
47  nBin 20;
48  direction (1 0 0);
49  cumulative yes;
50  }
51  }
52  \endverbatim
53 
54 Usage
55  \table
56  Property | Description | Required | Default value
57  type | Type name: forces | yes |
58  log | Write force data to standard output | no | no
59  patches | Patches included in the forces calculation | yes |
60  p | Pressure field name | no | p
61  U | Velocity field name | no | U
62  rho | Density field name (see below) | no | rho
63  phase | Phase name for phase-fraction | no |
64  CofR | Centre of rotation | yes |
65  directForceDensity | Force density supplied directly (see below)|no|no
66  fD | Name of force density field (see below) | no | fD
67  \endtable
68 
69  Bin data is optional, but if the dictionary is present, the entries must
70  be defined according o
71  \table
72  nBin | number of data bins | yes |
73  direction | direction along which bins are defined | yes |
74  cumulative | bin data accumulated with increasing distance | yes |
75  \endtable
76 
77  Note
78  - For incompressible cases, set \c rho to \c rhoInf and provide
79  a \c rhoInf value corresponding to the free-stream constant density.
80  - If the \c phase name is specified the corresponding phase-fraction field
81  \c alpha.<phase> is used to filter the surface force field
82  before integration.
83  - If the force density is supplied directly, set the \c directForceDensity
84  flag to 'yes', and supply the force density field using the \c
85  fDName entry
86 
87 See also
88  Foam::functionObject
89  Foam::functionObjects::forcesBase
90  Foam::functionObjects::fvMeshFunctionObject
91  Foam::functionObjects::logFiles
92  Foam::functionObjects::timeControl
93  Foam::forceCoeffs
94 
95 SourceFiles
96  forces.C
97 
98 \*---------------------------------------------------------------------------*/
99 
100 #ifndef functionObjects_forces_H
101 #define functionObjects_forces_H
102 
103 #include "forcesBase.H"
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 namespace functionObjects
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class forces Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class forces
117 :
118  public forcesBase
119 {
120 
121 protected:
122 
123  // Protected data
124 
125  //- Centre of rotation
126  vector CofR_;
127 
128 
129  // Protected Member Functions
130 
131  //- Return the current centre of the rigid body
132  virtual vector CofR() const;
133 
134  //- Write the constant centre of rotation value in the header
135  virtual void writeCoRValueHeader(Ostream& file);
136 
137  //- Do not write the constant centre of rotation
138  virtual void writeCoRHeader(Ostream& file);
139 
140  //- Do not write the constant centre of rotation
141  virtual void writeCofR(Ostream& file);
142 
143 
144 public:
145 
146  //- Runtime type information
147  TypeName("forces");
148 
149 
150  // Constructors
151 
152  //- Construct from Time and dictionary
153  forces
154  (
155  const word& name,
156  const Time& runTime,
157  const dictionary& dict
158  );
159 
160  //- Construct from objectRegistry and dictionary
161  forces
162  (
163  const word& name,
164  const objectRegistry& obr,
165  const dictionary&
166  );
167 
168  //- Disallow default bitwise copy construction
169  forces(const forces&) = delete;
170 
171 
172  //- Destructor
173  virtual ~forces();
174 
175 
176  // Member Functions
177 
178  //- Read the forces data
179  virtual bool read(const dictionary&);
180 
181 
182  // Member Operators
183 
184  //- Disallow default bitwise assignment
185  void operator=(const forces&) = delete;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace functionObjects
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #endif
197 
198 // ************************************************************************* //
const word & name() const
Return the name of this functionObject.
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:113
Calculates the forces and moments by integrating the pressure and skin-friction forces over a given l...
Definition: forces.H:188
virtual ~forces()
Destructor.
Definition: forces.C:96
virtual void writeCoRHeader(Ostream &file)
Do not write the constant centre of rotation.
Definition: forces.C:56
forces(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: forces.C:67
virtual void writeCoRValueHeader(Ostream &file)
Write the constant centre of rotation value in the header.
Definition: forces.C:50
TypeName("forces")
Runtime type information.
vector CofR_
Centre of rotation.
Definition: forces.H:195
virtual vector CofR() const
Return the current centre of the rigid body.
Definition: forces.C:44
void operator=(const forces &)=delete
Disallow default bitwise assignment.
virtual void writeCofR(Ostream &file)
Do not write the constant centre of rotation.
Definition: forces.C:60
virtual bool read(const dictionary &)
Read the forces data.
Definition: forces.C:102
Namespace for OpenFOAM.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dictionary dict