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  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::RBD::rigidBodyMotion
29 
30 Description
31  Six degree of freedom motion for a rigid body.
32 
33  Angular momentum stored in body fixed reference frame. Reference
34  orientation of the body (where Q = I) must align with the cartesian axes
35  such that the Inertia tensor is in principle component form. Can add
36  restraints (e.g. a spring) and constraints (e.g. motion may only be on a
37  plane).
38 
39  The time-integrator for the motion is run-time selectable with options for
40  symplectic (explicit), Crank-Nicolson and Newmark schemes.
41 
42 SourceFiles
43  rigidBodyMotionI.H
44  rigidBodyMotion.C
45  rigidBodyMotionIO.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef rigidBodyMotion_H
50 #define rigidBodyMotion_H
51 
52 #include "rigidBodyModel.H"
53 #include "rigidBodyModelState.H"
54 #include "pointField.H"
55 #include "Switch.H"
56 #include "Function1.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 // Forward declarations
64 class Time;
65 
66 namespace RBD
67 {
68 
69 // Forward declarations
70 class rigidBodySolver;
71 
72 /*---------------------------------------------------------------------------*\
73  Class rigidBodyMotion Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class rigidBodyMotion
77 :
78  public rigidBodyModel
79 {
80  friend class rigidBodySolver;
81 
82  // Private data
83 
84  //- Motion state data object
85  rigidBodyModelState motionState_;
86 
87  //- Motion state data object for previous time-step
88  rigidBodyModelState motionState0_;
89 
90  //- Initial transform for external forces to the bodies reference frame
92 
93  //- Acceleration relaxation coefficient
95 
96  //- Acceleration damping coefficient (for steady-state simulations)
97  scalar aDamp_;
98 
99  //- Switch to turn reporting of motion data on and off
100  Switch report_;
101 
102  //- Motion solver
103  autoPtr<rigidBodySolver> solver_;
104 
105 
106  // Private Member Functions
107 
108  //- Initialize the body-state
109  void initialize();
110 
111  //- No copy construct
112  rigidBodyMotion(const rigidBodyMotion&) = delete;
113 
114  //- No copy assignment
115  void operator=(const rigidBodyMotion&) = delete;
116 
117 
118 public:
119 
120  // Constructors
121 
122  //- Construct null
123  rigidBodyMotion(const Time& time);
124 
125  //- Construct from dictionary
127  (
128  const Time& time,
129  const dictionary& dict
130  );
131 
132  //- Construct from constant and state dictionaries
134  (
135  const Time& time,
136  const dictionary& dict,
137  const dictionary& stateDict
138  );
139 
140 
141  //- Destructor
143 
144 
145  // Member Functions
146 
147  // Access
148 
149  //- Return the report Switch
150  inline bool report() const;
151 
152  //- Return the motion state
153  inline const rigidBodyModelState& state() const;
154 
155  //- Return the motion state for modification
156  inline rigidBodyModelState& state();
157 
158  //- Return the initial transform to the global frame for the
159  // given body
160  spatialTransform X00(const label bodyId) const;
161 
162 
163  // Edit
164 
165  //- Store the motion state at the beginning of the time-step
166  inline void newTime();
167 
168 
169  // Update state
170 
171  //- Calculate and optionally relax the joint acceleration qDdot from
172  // the joint state q, velocity qDot, internal force tau (in the
173  // joint frame) and external force fx (in the global frame)
174  void forwardDynamics
175  (
177  const scalarField& tau,
178  const Field<spatialVector>& fx
179  ) const;
180 
181  //- Integrate velocities, orientation and position
182  // for the given time and time-step
183  void solve
184  (
185  const scalar t,
186  const scalar deltaT,
187  const scalarField& tau,
188  const Field<spatialVector>& fx
189  );
190 
191  //- Report the status of the motion of the given body
192  void status(const label bodyID) const;
193 
194  //- Report linear velocity of the given body
195  const vector vCofR(const label bodyID) const;
196 
197  //- Report CofR of the given body
198  const vector cCofR(const label bodyID) const;
199 
200 
201  // Transformations
202 
203  //- Transform the given initial pointField of the specified body
204  // to correspond to the current motion state
206  (
207  const label bodyID,
208  const pointField& initialPoints
209  ) const;
210 
211  //- Transform the given initial pointField of the specified body
212  // to correspond to the current motion state scaled using
213  // 'slerp' interpolation
215  (
216  const label bodyID,
217  const scalarField& weight,
218  const pointField& initialPoints
219  ) const;
220 
221  //- Transform the given initial pointField of the specified body
222  // to correspond to the current motion state scaled using
223  // 'slerp' interpolation
225  (
226  const labelList& bodyIDs,
227  const List<const scalarField*>& weights,
228  const pointField& initialPoints
229  ) const;
230 
231 
232  //- Write
233  void write(Ostream&) const;
234 
235  //- Read coefficients dictionary and update system parameters,
236  // constraints and restraints but not the current state
237  bool read(const dictionary& dict);
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace RBD
244 } // End namespace Foam
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #include "rigidBodyMotionI.H"
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #endif
253 
254 // ************************************************************************* //
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:172
Foam::RBD::rigidBodyMotion::cCofR
const vector cCofR(const label bodyID) const
Report CofR of the given body.
Definition: rigidBodyMotion.C:222
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
Function1.H
Foam::RBD::rigidBodyMotion::status
void status(const label bodyID) const
Report the status of the motion of the given body.
Definition: rigidBodyMotion.C:200
Foam::RBD::rigidBodyMotion
Six degree of freedom motion for a rigid body.
Definition: rigidBodyMotion.H:75
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:56
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
Foam::RBD::rigidBodyMotion::vCofR
const vector vCofR(const label bodyID) const
Report linear velocity of the given body.
Definition: rigidBodyMotion.C:214
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:123
Foam::RBD::rigidBodyMotion::X00
spatialTransform X00(const label bodyId) const
Return the initial transform to the global frame for the.
Definition: rigidBodyMotion.C:135
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::Vector< scalar >
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:128
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:232
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:152