rigidBodyMotion.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::RBD::rigidBodyMotion
28 
29 Description
30  Six degree of freedom motion for a rigid body.
31 
32  Angular momentum stored in body fixed reference frame. Reference
33  orientation of the body (where Q = I) must align with the cartesian axes
34  such that the Inertia tensor is in principle component form. Can add
35  restraints (e.g. a spring) and constraints (e.g. motion may only be on a
36  plane).
37 
38  The time-integrator for the motion is run-time selectable with options for
39  symplectic (explicit), Crank-Nicolson and Newmark schemes.
40 
41 SourceFiles
42  rigidBodyMotionI.H
43  rigidBodyMotion.C
44  rigidBodyMotionIO.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef rigidBodyMotion_H
49 #define rigidBodyMotion_H
50 
51 #include "rigidBodyModel.H"
52 #include "rigidBodyModelState.H"
53 #include "pointField.H"
54 #include "Switch.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward declarations
62 class Time;
63 
64 namespace RBD
65 {
66 
67 // Forward declarations
68 class rigidBodySolver;
69 
70 /*---------------------------------------------------------------------------*\
71  Class rigidBodyMotion Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class rigidBodyMotion
75 :
76  public rigidBodyModel
77 {
78  friend class rigidBodySolver;
79 
80  // Private data
81 
82  //- Motion state data object
83  rigidBodyModelState motionState_;
84 
85  //- Motion state data object for previous time-step
86  rigidBodyModelState motionState0_;
87 
88  //- Initial transform for external forces to the bodies reference frame
90 
91  //- Acceleration relaxation coefficient
92  scalar aRelax_;
93 
94  //- Acceleration damping coefficient (for steady-state simulations)
95  scalar aDamp_;
96 
97  //- Switch to turn reporting of motion data on and off
98  Switch report_;
99 
100  //- Motion solver
101  autoPtr<rigidBodySolver> solver_;
102 
103 
104  // Private Member Functions
105 
106  //- Initialize the body-state
107  void initialize();
108 
109  //- No copy construct
110  rigidBodyMotion(const rigidBodyMotion&) = delete;
111 
112  //- No copy assignment
113  void operator=(const rigidBodyMotion&) = delete;
114 
115 
116 public:
117 
118  // Constructors
119 
120  //- Construct null
121  rigidBodyMotion(const Time& time);
122 
123  //- Construct from dictionary
125  (
126  const Time& time,
127  const dictionary& dict
128  );
129 
130  //- Construct from constant and state dictionaries
132  (
133  const Time& time,
134  const dictionary& dict,
135  const dictionary& stateDict
136  );
137 
138 
139  //- Destructor
141 
142 
143  // Member Functions
144 
145  // Access
146 
147  //- Return the report Switch
148  inline bool report() const;
149 
150  //- Return the motion state
151  inline const rigidBodyModelState& state() const;
152 
153  //- Return the motion state for modification
154  inline rigidBodyModelState& state();
155 
156  //- Return the initial transform to the global frame for the
157  // given body
158  spatialTransform X00(const label bodyId) const;
159 
160 
161  // Edit
162 
163  //- Store the motion state at the beginning of the time-step
164  inline void newTime();
165 
166 
167  // Update state
168 
169  //- Calculate and optionally relax the joint acceleration qDdot from
170  // the joint state q, velocity qDot, internal force tau (in the
171  // joint frame) and external force fx (in the global frame)
172  void forwardDynamics
173  (
175  const scalarField& tau,
176  const Field<spatialVector>& fx
177  ) const;
178 
179  //- Integrate velocities, orientation and position
180  // for the given time and time-step
181  void solve
182  (
183  const scalar t,
184  const scalar deltaT,
185  const scalarField& tau,
186  const Field<spatialVector>& fx
187  );
188 
189  //- Report the status of the motion of the given body
190  void status(const label bodyID) const;
191 
192 
193  // Transformations
194 
195  //- Transform the given initial pointField of the specified body
196  // to correspond to the current motion state
198  (
199  const label bodyID,
200  const pointField& initialPoints
201  ) const;
202 
203  //- Transform the given initial pointField of the specified body
204  // to correspond to the current motion state scaled using
205  // 'slerp' interpolation
207  (
208  const label bodyID,
209  const scalarField& weight,
210  const pointField& initialPoints
211  ) const;
212 
213  //- Transform the given initial pointField of the specified body
214  // to correspond to the current motion state scaled using
215  // 'slerp' interpolation
217  (
218  const labelList& bodyIDs,
219  const List<const scalarField*>& weights,
220  const pointField& initialPoints
221  ) const;
222 
223 
224  //- Write
225  void write(Ostream&) const;
226 
227  //- Read coefficients dictionary and update system parameters,
228  // constraints and restraints but not the current state
229  bool read(const dictionary& dict);
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace RBD
236 } // End namespace Foam
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #include "rigidBodyMotionI.H"
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************************************************************* //
Foam::RBD::rigidBodyMotion::solve
void solve(const scalar t, const scalar deltaT, const scalarField &tau, const Field< spatialVector > &fx)
Integrate velocities, orientation and position.
Definition: rigidBodyMotion.C:147
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::RBD::rigidBodyModelState
Holds the motion state of rigid-body model.
Definition: rigidBodyModelState.H:67
Foam::spatialTransform
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
Definition: spatialTransform.H:70
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::RBD::rigidBodyMotion::status
void status(const label bodyID) const
Report the status of the motion of the given body.
Definition: rigidBodyMotion.C:175
Foam::RBD::rigidBodyMotion
Six degree of freedom motion for a rigid body.
Definition: rigidBodyMotion.H:73
Foam::RBD::rigidBodyMotion::state
const rigidBodyModelState & state() const
Return the motion state.
Definition: rigidBodyMotionI.H:37
Foam::RBD::rigidBodyMotion::write
void write(Ostream &) const
Write.
Definition: rigidBodyMotionIO.C:46
Foam::RBD::rigidBodyMotion::read
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
Definition: rigidBodyMotionIO.C:34
rigidBodyModel.H
Foam::Field< scalar >
Foam::RBD::rigidBodyModel::time
const Time & time() const
Return the time.
Definition: rigidBodyModelI.H:31
Switch.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::RBD::rigidBodyModel
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
Definition: rigidBodyModel.H:83
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::RBD::rigidBodyMotion::X00
spatialTransform X00(const label bodyId) const
Return the initial transform to the global frame for the.
Definition: rigidBodyMotion.C:117
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::RBD::rigidBodyMotion::report
bool report() const
Return the report Switch.
Definition: rigidBodyMotionI.H:30
Foam::RBD::rigidBodyModel::bodyID
label bodyID(const word &name) const
Return the ID of the body with the given name.
Definition: rigidBodyModelI.H:170
rigidBodyModelState.H
pointField.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::RBD::rigidBodySolver
Definition: rigidBodySolver.H:53
rigidBodyMotionI.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::RBD::rigidBodyMotion::~rigidBodyMotion
~rigidBodyMotion()
Destructor.
Definition: rigidBodyMotion.C:110
Foam::RBD::rigidBodyMotion::newTime
void newTime()
Store the motion state at the beginning of the time-step.
Definition: rigidBodyMotionI.H:50
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::RBD::rigidBodyMotion::transformPoints
tmp< pointField > transformPoints(const label bodyID, const pointField &initialPoints) const
Transform the given initial pointField of the specified body.
Definition: rigidBodyMotion.C:190
Foam::RBD::rigidBodyMotion::forwardDynamics
void forwardDynamics(rigidBodyModelState &state, const scalarField &tau, const Field< spatialVector > &fx) const
Calculate and optionally relax the joint acceleration qDdot from.
Definition: rigidBodyMotion.C:134