sectionalForceGraph.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) 2026 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::sectionalForceGraph
26 
27 Description
28  This function calculates the fluid forces and moments at a series of
29  section-planes through a given set of patches. It writes the result into a
30  graph which can be used to construct part of a shear force and bending
31  moment diagram. Points in the graph are graded to approximately match the
32  resolution of the mesh.
33 
34  The cut-planes are defined by a normal, and the line of the graph is
35  defined by an origin and extends in the direction of the normal. Forces and
36  moments are calculated on the side of the planes to which the normal
37  points. If the "other" side also needs to be generated then the function
38  can be executed with the normal reversed.
39 
40  Note that to construct full shear force and bending moment diagrams would
41  require supporting and/or dynamic forces to be included also. This function
42  only generates the contribution from the surrounding fluid.
43 
44  Example of function object specification:
45  \verbatim
46  sectionalForceGraph1
47  {
48  type sectionalForceGraph;
49  libs ("libforces.so");
50  patches (hull);
51  origin (0 0 0);
52  normal (1 0 0);
53  nPoints 20;
54  axis x;
55  setFormat raw;
56  }
57  \endverbatim
58 
59 Usage
60  \table
61  Property | Description | Required | Default value
62  type | Type name: sectionalForceGraph | yes |
63  patches | Patches included in the forces calculation | yes |
64  origin | Origin of the plot | yes |
65  normal | Normal to the section planes | yes |
66  nPoints | Number of points in the plot | yes |
67  axis | Component of the position to plot against | yes |
68  setFormat | Graph output format | yes |
69  p | Pressure field name | no | p
70  U | Velocity field name | no | U
71  rho | Density field name | no | rho
72  phase | Phase name for phase-fraction | no |
73  rhoRef | Reference density | if incompressible |
74  pRef | Reference pressure | no | 0
75  \endtable
76 
77 SourceFiles
78  sectionalForceGraph.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef sectionalForceGraph_functionObject_H
83 #define sectionalForceGraph_functionObject_H
84 
85 #include "sectionalForcesBase.H"
86 #include "coordSet.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 namespace functionObjects
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class sectionalForceGraph Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class sectionalForceGraph
100 :
101  public sectionalForcesBase
102 {
103  // Private Data
104 
105  //- The normal to the selection planes
106  vector normal_;
107 
108  //- The origin of the plot
109  vector origin_;
110 
111  //- The distances from the origin to the section planes
112  mutable autoPtr<scalarField> distancesPtr_;
113 
114  //- The number of points in the plot
115  label nPoints_;
116 
117  //- The direction over which to plot the results
118  coordSet::axisType axis_;
119 
120  //- File writer
121  autoPtr<setWriter> formatter_;
122 
123  //- Number of optimisation iterations. Default is 2.
124  label nOptimiseIter_;
125 
126 
127  // Private Member Functions
128 
129  //- Clear the cached weights
130  virtual void clear();
131 
132 
133 protected:
134 
135  // Protected Member Functions
136 
137  //- Return the normal to the section planes
138  virtual vector normal() const;
139 
140  //- Return the origin of the plot
141  virtual point origin() const;
142 
143  //- Return the distances from the origin to the section planes
144  virtual tmp<scalarField> distances() const;
145 
146 
147 public:
148 
149  //- Runtime type information
150  TypeName("sectionalForceGraph");
151 
152 
153  // Constructors
154 
155  //- Construct from Time and dictionary
157  (
158  const word& name,
159  const Time& runTime,
160  const dictionary& dict
161  );
162 
163  //- Disallow default bitwise copy construction
164  sectionalForceGraph(const sectionalForceGraph&) = delete;
165 
166 
167  //- Destructor
169 
170 
171  // Member Functions
172 
173  //- Read the sectionalForceGraph data
174  virtual bool read(const dictionary&);
175 
176  //- Write the sectionalForceGraph
177  virtual bool write();
178 
179 
180  // Member Operators
181 
182  //- Disallow default bitwise assignment
183  void operator=(const sectionalForceGraph&) = delete;
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace functionObjects
190 } // End namespace Foam
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
axisType
Enumeration defining the output format for coordinates.
Definition: coordSet.H:58
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.
This function calculates the fluid forces and moments at a series of section-planes through a given s...
void operator=(const sectionalForceGraph &)=delete
Disallow default bitwise assignment.
sectionalForceGraph(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
TypeName("sectionalForceGraph")
Runtime type information.
virtual tmp< scalarField > distances() const
Return the distances from the origin to the section planes.
virtual point origin() const
Return the origin of the plot.
virtual vector normal() const
Return the normal to the section planes.
virtual bool write()
Write the sectionalForceGraph.
virtual bool read(const dictionary &)
Read the sectionalForceGraph data.
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
vector point
Point is a vector.
Definition: point.H:41
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dictionary dict