rigidBodyMotion.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-2019 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::RBD::rigidBodyMotion
26 
27 Description
28  Six degree of freedom motion for a rigid body.
29 
30  Angular momentum stored in body fixed reference frame. Reference
31  orientation of the body (where Q = I) must align with the cartesian axes
32  such that the Inertia tensor is in principle component form. Can add
33  restraints (e.g. a spring) and constraints (e.g. motion may only be on a
34  plane).
35 
36  The time-integrator for the motion is run-time selectable with options for
37  symplectic (explicit), Crank-Nicolson and Newmark schemes.
38 
39 SourceFiles
40  rigidBodyMotionI.H
41  rigidBodyMotion.C
42  rigidBodyMotionIO.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef rigidBodyMotion_H
47 #define rigidBodyMotion_H
48 
49 #include "rigidBodyModel.H"
50 #include "rigidBodyModelState.H"
51 #include "pointField.H"
52 #include "Switch.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace RBD
59 {
60 
61 // Forward declarations
62 class rigidBodySolver;
63 
64 /*---------------------------------------------------------------------------*\
65  Class rigidBodyMotion Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class rigidBodyMotion
69 :
70  public rigidBodyModel
71 {
72  friend class rigidBodySolver;
73 
74  // Private Data
75 
76  //- Motion state data object
77  rigidBodyModelState motionState_;
78 
79  //- Motion state data object for previous time-step
80  rigidBodyModelState motionState0_;
81 
82  //- Initial transform for external forces to the bodies reference frame
84 
85  //- Acceleration relaxation coefficient
86  scalar aRelax_;
87 
88  //- Acceleration damping coefficient (for steady-state simulations)
89  scalar aDamp_;
90 
91  //- Switch to turn reporting of motion data on and off
92  Switch report_;
93 
94  //- Motion solver
96 
97 
98  // Private Member Functions
99 
100  //- Initialize the body-state
101  void initialize();
102 
103 
104 public:
105 
106  // Constructors
107 
108  //- Construct null
109  rigidBodyMotion();
110 
111  //- Construct from dictionary
113  (
114  const dictionary& dict
115  );
116 
117  //- Construct from constant and state dictionaries
119  (
120  const dictionary& dict,
121  const dictionary& stateDict
122  );
123 
124  //- Disallow default bitwise copy construction
126 
127 
128  //- Destructor
130 
131 
132  // Member Functions
133 
134  // Access
135 
136  //- Return the report Switch
137  inline bool report() const;
138 
139  //- Return the motion state
140  inline const rigidBodyModelState& state() const;
141 
142  //- Return the motion state for modification
143  inline rigidBodyModelState& state();
144 
145  //- Return the initial transform to the global frame for the
146  // given body
147  spatialTransform X00(const label bodyId) const;
148 
149 
150  // Edit
151 
152  //- Store the motion state at the beginning of the time-step
153  inline void newTime();
154 
155 
156  // Update state
157 
158  //- Calculate and optionally relax the joint acceleration qDdot from
159  // the joint state q, velocity qDot, internal force tau (in the
160  // joint frame) and external force fx (in the global frame)
161  void forwardDynamics
162  (
163  rigidBodyModelState& state,
164  const scalarField& tau,
165  const Field<spatialVector>& fx
166  ) const;
167 
168  //- Integrate velocities, orientation and position
169  // for the given time and time-step
170  void solve
171  (
172  const scalar t,
173  const scalar deltaT,
174  const scalarField& tau,
175  const Field<spatialVector>& fx
176  );
177 
178  //- Report the status of the motion of the given body
179  void status(const label bodyID) const;
180 
181 
182  // Transformations
183 
184  //- Transform the given initial pointField of the specified body
185  // to correspond to the current motion state
187  (
188  const label bodyID,
189  const pointField& initialPoints
190  ) const;
191 
192  //- Transform the given initial pointField of the specified body
193  // to correspond to the current motion state scaled using
194  // 'slerp' interpolation
196  (
197  const label bodyID,
198  const scalarField& weight,
199  const pointField& initialPoints
200  ) const;
201 
202  //- Transform the given initial pointField of the specified body
203  // to correspond to the current motion state scaled using
204  // 'slerp' interpolation
206  (
207  const labelList& bodyIDs,
208  const List<const scalarField*>& weights,
209  const pointField& initialPoints
210  ) const;
211 
212 
213  //- Write
214  virtual void write(Ostream&) const;
215 
216  //- Read coefficients dictionary and update system parameters,
217  // constraints and restraints but not the current state
218  bool read(const dictionary& dict);
219 
220 
221  // Member Operators
222 
223  //- Disallow default bitwise assignment
224  void operator=(const rigidBodyMotion&) = delete;
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace RBD
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #include "rigidBodyMotionI.H"
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #endif
240 
241 // ************************************************************************* //
void newTime()
Store the motion state at the beginning of the time-step.
dictionary dict
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
tmp< pointField > transformPoints(const label bodyID, const pointField &initialPoints) const
Transform the given initial pointField of the specified body.
void status(const label bodyID) const
Report the status of the motion of the given body.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
spatialTransform X00(const label bodyId) const
Return the initial transform to the global frame for the.
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
const rigidBodyModelState & state() const
Return the motion state.
Holds the motion state of rigid-body model.
virtual void write(Ostream &) const
Write.
Six degree of freedom motion for a rigid body.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void solve(const scalar t, const scalar deltaT, const scalarField &tau, const Field< spatialVector > &fx)
Integrate velocities, orientation and position.
rigidBodyMotion()
Construct null.
void operator=(const rigidBodyMotion &)=delete
Disallow default bitwise assignment.
Compact representation of the Pl├╝cker spatial transformation tensor in terms of the rotation tensor E...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
label bodyID(const word &name) const
Return the ID of the body with the given name.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
A class for managing temporary objects.
Definition: PtrList.H:53
bool report() const
Return the report Switch.
void forwardDynamics(rigidBodyModelState &state, const scalarField &tau, const Field< spatialVector > &fx) const
Calculate and optionally relax the joint acceleration qDdot from.
Namespace for OpenFOAM.