rigidBodyMeshMotion.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) 2016-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::rigidBodyMeshMotion
26 
27 Description
28  Rigid-body mesh motion solver for fvMesh.
29 
30  Applies septernion interpolation of movement as function of distance to the
31  object surface.
32 
33 SourceFiles
34  rigidBodyMeshMotion.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef rigidBodyMeshMotion_H
39 #define rigidBodyMeshMotion_H
40 
42 #include "rigidBodyMotion.H"
43 #include "Function1.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class rigidBodyMeshMotion Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
58 {
59  //- Class containing the patches and point motion weighting for each body
60  class bodyMesh
61  {
62  //- Name of the body
63  const word name_;
64 
65  //- ID of the body in the RBD::rigidBodyMotion
66  const label bodyIndex_;
67 
68  //- List of mesh patch names associated with this body
69  const wordReList patches_;
70 
71  //- Set of mesh patches associated with this body
72  const labelHashSet patchSet_;
73 
74  //- Names of the pointZones which move with the body
75  wordReList pointZones_;
76 
77  //- pointZones which move with the body
78  labelHashSet pointZoneSet_;
79 
80  //- Inner morphing distance (limit of solid-body region)
81  const scalar di_;
82 
83  //- Outer morphing distance (limit of linear interpolation region)
84  const scalar do_;
85 
86  //- Current interpolation weight
87  // (1 at patches and within di_, 0 at do_ and beyond)
88  pointScalarField weight_;
89 
90 
91  public:
92 
93  friend class rigidBodyMeshMotion;
94 
95  bodyMesh
96  (
97  const polyMesh& mesh,
98  const word& name,
99  const label bodyID,
100  const dictionary& dict
101  );
102 
103  template<class Type>
104  inline Type weight(const Type& pDist) const;
105  };
106 
107 
108  // Private Data
109 
110  //- List of the bodyMeshes containing the patches and point motion
111  // weighting for each body
112  PtrList<bodyMesh> bodyMeshes_;
113 
114  //- Switch for test-mode in which only the
115  // gravitational body-force is applied
116  Switch test_;
117 
118  //- Number of iterations in test-mode
119  label nIter_;
120 
121  //- Reference density required by the forces object for
122  // incompressible calculations, required if rho == rhoInf
123  scalar rhoInf_;
124 
125  //- Name of density field, optional unless used for an
126  // incompressible simulation, when this needs to be specified
127  // as rhoInf
128  word rhoName_;
129 
130  //- Ramp the forces according to the specified function and period
132 
133  //- Current time index (used for updating)
134  label curTimeIndex_;
135 
136 
137  // Private Member Functions
138 
139  //- To avoid warning from clang
141 
142  //- Return the list of transformation for each body from time 0
143  List<septernion> transforms0() const;
144 
145  //- Return the list of weights for each body to pointi
146  // w is used as the work-space for the weights and returned
147  List<scalar>& weights(const label pointi, List<scalar>& w) const;
148 
149 
150 public:
151 
152  //- Runtime type information
153  TypeName("rigidBodyMotion");
154 
155 
156  // Constructors
157 
158  //- Construct from polyMesh and dictionary
160  (
161  const word& name,
162  const polyMesh&,
163  const dictionary& dict
164  );
165 
166  //- Disallow default bitwise copy construction
168  (
169  const rigidBodyMeshMotion&
170  ) = delete;
171 
172 
173  //- Destructor
175 
176 
177  // Member Functions
178 
179  //- Return point location obtained from the current motion field
180  virtual tmp<pointField> curPoints() const;
181 
182  //- Solve for motion
183  virtual void solve();
184 
185  //- Update local data for topology changes
186  virtual void topoChange(const polyTopoChangeMap&);
187 
188  //- Write motion state information for restart
189  virtual bool write() const;
190 
191 
192  // Member Operators
193 
194  //- Disallow default bitwise assignment
195  void operator=(const rigidBodyMeshMotion&) = delete;
196 };
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
virtual void write(Ostream &) const
Write.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
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
Virtual base class for displacement motion solver.
const word & name() const
Return name.
Definition: motionSolver.H:121
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:133
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Rigid-body mesh motion solver for fvMesh.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
TypeName("rigidBodyMotion")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update local data for topology changes.
void operator=(const rigidBodyMeshMotion &)=delete
Disallow default bitwise assignment.
rigidBodyMeshMotion(const word &name, const polyMesh &, const dictionary &dict)
Construct from polyMesh and dictionary.
virtual bool write() const
Write motion state information for restart.
virtual void solve()
Solve for motion.
A class for managing temporary objects.
Definition: tmp.H:55
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