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-2018 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  //- Disallow copy construct
105 
106  //- Disallow default bitwise assignment
107  void operator=(const rigidBodyMotion&);
108 
109 
110 public:
111 
112  // Constructors
113 
114  //- Construct null
115  rigidBodyMotion();
116 
117  //- Construct from dictionary
119  (
120  const dictionary& dict
121  );
122 
123  //- Construct from constant and state dictionaries
125  (
126  const dictionary& dict,
127  const dictionary& stateDict
128  );
129 
130 
131  //- Destructor
133 
134 
135  // Member Functions
136 
137  // Access
138 
139  //- Return the report Switch
140  inline bool report() const;
141 
142  //- Return the motion state
143  inline const rigidBodyModelState& state() const;
144 
145  //- Return the motion state for modification
146  inline rigidBodyModelState& state();
147 
148  //- Return the initial transform to the global frame for the
149  // given body
150  spatialTransform X00(const label bodyId) const;
151 
152 
153  // Edit
154 
155  //- Store the motion state at the beginning of the time-step
156  inline void newTime();
157 
158 
159  // Update state
160 
161  //- Calculate and optionally relax the joint acceleration qDdot from
162  // the joint state q, velocity qDot, internal force tau (in the
163  // joint frame) and external force fx (in the global frame)
164  void forwardDynamics
165  (
166  rigidBodyModelState& state,
167  const scalarField& tau,
168  const Field<spatialVector>& fx
169  ) const;
170 
171  //- Integrate velocities, orientation and position
172  // for the given time and time-step
173  void solve
174  (
175  const scalar t,
176  const scalar deltaT,
177  const scalarField& tau,
178  const Field<spatialVector>& fx
179  );
180 
181  //- Report the status of the motion of the given body
182  void status(const label bodyID) const;
183 
184 
185  // Transformations
186 
187  //- Transform the given initial pointField of the specified body
188  // to correspond to the current motion state
190  (
191  const label bodyID,
192  const pointField& initialPoints
193  ) const;
194 
195  //- Transform the given initial pointField of the specified body
196  // to correspond to the current motion state scaled using
197  // 'slerp' interpolation
199  (
200  const label bodyID,
201  const scalarField& weight,
202  const pointField& initialPoints
203  ) const;
204 
205  //- Transform the given initial pointField of the specified body
206  // to correspond to the current motion state scaled using
207  // 'slerp' interpolation
209  (
210  const labelList& bodyIDs,
211  const List<const scalarField*>& weights,
212  const pointField& initialPoints
213  ) const;
214 
215 
216  //- Write
217  void write(Ostream&) const;
218 
219  //- Read coefficients dictionary and update system parameters,
220  // constraints and restraints but not the current state
221  bool read(const dictionary& dict);
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace RBD
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #include "rigidBodyMotionI.H"
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
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:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
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.
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.
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.
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.