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