sectionalForcesBase.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::sectionalForcesBase
26 
27 Description
28  Base class for sectional forces function objects
29 
30 SourceFiles
31  sectionalForcesBase.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef sectionalForcesBase_functionObject_H
36 #define sectionalForcesBase_functionObject_H
37 
38 #include "fvMeshFunctionObject.H"
39 #include "indirectPrimitivePatch.H"
40 #include "patchCutPlot.H"
41 #include "volFieldsFwd.H"
42 #include "surfaceFieldsFwd.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 namespace functionObjects
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class sectionalForcesBase Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 :
58 {
59  // Private Data
60 
61  //- Mesh patches to integrate the forces over
62  labelHashSet patchSet_;
63 
64  //- Primitive patch containing all mesh patches
65  mutable autoPtr<indirectPrimitivePatch> patchPtr_;
66 
67  //- Name of pressure field
68  word pName_;
69 
70  //- Name of velocity field
71  word UName_;
72 
73  //- Name of density field (optional)
74  word rhoName_;
75 
76  //- The name of the phase (optional)
77  word phaseName_;
78 
79  //- Reference density needed for incompressible calculations
80  scalar rhoRef_;
81 
82  //- Reference pressure
83  scalar pRef_;
84 
85  //- Weights
86  mutable autoPtr<List<patchCutPlot::weight>> weightsPtr_;
87 
88 
89  // Private Member Functions
90 
91  //- Multiply the argument by the volume fraction (if any)
92  template<class Type>
93  tmp<SurfaceField<Type>> timesAlpha
94  (
96  ) const;
97 
98  //- Multiply the argument by the volume fraction (if any)
99  template<class Type>
100  tmp<Field<Type>> timesAlpha
101  (
102  const tmp<Field<Type>> psi,
103  const label patchi
104  ) const;
105 
106  //- Multiply the argument by the density
107  template<class Type>
108  tmp<SurfaceField<Type>> timesRho
109  (
110  const tmp<SurfaceField<Type>> psi
111  ) const;
112 
113  //- Multiply the argument by the volume fraction (if any) and density
114  template<class Type>
115  tmp<SurfaceField<Type>> timesAlphaRho
116  (
117  const tmp<SurfaceField<Type>> psi
118  ) const;
119 
120  //- Return the (dynamic) pressure
121  tmp<volScalarField> p() const;
122 
123  //- Return the surface stress tensor
124  tmp<surfaceVectorField> devTau() const;
125 
126 
127 protected:
128 
129  // Protected Member Functions
130 
131  //- Clear the cached weights
132  virtual void clear();
133 
134  //- Access the primitive patch
135  const indirectPrimitivePatch& patch() const;
136 
137  //- Clear the patch
138  void clearPatch();
139 
140  //- Clear the patch geometry
141  void clearPatchGeom();
142 
143  //- Return the normal to the section planes
144  virtual vector normal() const = 0;
145 
146  //- Return the origin of the plot. This can be an arbitrary point
147  // somewhere along the 1-D 'beam' that the geometry is reduced to.
148  virtual point origin() const = 0;
149 
150  //- Return the distances from the origin to the section planes. This is
151  // the coordinate that we plot against.
152  virtual tmp<scalarField> distances() const = 0;
153 
154  //- Return the distance from the origin to the patch points
155  // in the normal direction
157 
158  //- Access the weights
159  const List<patchCutPlot::weight>& weights() const;
160 
161  //- Return the output path
162  fileName outputPath() const;
163 
164  //- Calculate the forces and moments at the cuts
165  void addFluid
166  (
168  vectorField& moment
169  ) const;
170 
171 
172 public:
173 
174  //- Runtime type information
175  TypeName("sectionalForcesBase");
176 
177 
178  // Constructors
179 
180  //- Construct from Time and dictionary
182  (
183  const word& name,
184  const Time& runTime,
185  const dictionary& dict
186  );
187 
188  //- Disallow default bitwise copy construction
189  sectionalForcesBase(const sectionalForcesBase&) = delete;
190 
191 
192  //- Destructor
193  virtual ~sectionalForcesBase();
194 
195 
196  // Member Functions
197 
198  //- Read the sectionalForcesBase data
199  virtual bool read(const dictionary&);
200 
201  //- Return the list of fields required
202  virtual wordList fields() const;
203 
204  //- Execute, currently does nothing
205  virtual bool execute();
206 
207  //- Execute at the final time-loop, currently does nothing
208  virtual bool end();
209 
210  //- Update for mesh point-motion
211  virtual void movePoints(const polyMesh&);
212 
213  //- Update topology using the given map
214  virtual void topoChange(const polyTopoChangeMap&);
215 
216  //- Update from another mesh using the given map
217  virtual void mapMesh(const polyMeshMap&);
218 
219  //- Redistribute or update using the given distribution map
220  virtual void distribute(const polyDistributionMap&);
221 
222 
223  // Member Operators
224 
225  //- Disallow default bitwise assignment
226  void operator=(const sectionalForcesBase&) = delete;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace functionObjects
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
Pre-declare SubField and related Field type.
Definition: Field.H:83
Generic GeometricField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
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...
Base class for sectional forces function objects.
void operator=(const sectionalForcesBase &)=delete
Disallow default bitwise assignment.
TypeName("sectionalForcesBase")
Runtime type information.
virtual wordList fields() const
Return the list of fields required.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual tmp< scalarField > distances() const =0
Return the distances from the origin to the section planes. This is.
fileName outputPath() const
Return the output path.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
const indirectPrimitivePatch & patch() const
Access the primitive patch.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
void clearPatchGeom()
Clear the patch geometry.
sectionalForcesBase(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
void addFluid(vectorField &force, vectorField &moment) const
Calculate the forces and moments at the cuts.
virtual point origin() const =0
Return the origin of the plot. This can be an arbitrary point.
virtual void clear()
Clear the cached weights.
const List< patchCutPlot::weight > & weights() const
Access the weights.
virtual bool execute()
Execute, currently does nothing.
tmp< scalarField > patchPointDistances() const
Return the distance from the origin to the patch points.
virtual vector normal() const =0
Return the normal to the section planes.
virtual bool end()
Execute at the final time-loop, currently does nothing.
virtual bool read(const dictionary &)
Read the sectionalForcesBase data.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
label patchi
const volScalarField & psi
const dimensionSet force
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