mbsim 4.0.0 MBSim Kernel

rigid_body_link.h
1 /* Copyright (C) 2004-2015 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@gmail.com
18 */
19
20 #ifndef _RIGID_BODY_LINK_H_
21 #define _RIGID_BODY_LINK_H_
22
23 #include "mbsim/links/mechanical_link.h"
24 #include "mbsim/frames/floating_relative_frame.h"
25
26 namespace MBSim {
27
28 class RigidBody;
29
30 class RigidBodyLink : public MechanicalLink {
31 protected:
32 std::vector<RigidBody*> body;
33 std::vector<double> ratio;
34 std::vector<FloatingRelativeFrame> C;
35 bool updPos{true};
36 bool updVel{true};
37 bool updFD{true};
38 std::vector<fmatvec::Mat3xV> DF, DM;
39 Frame *support;
40
41 public:
42 RigidBodyLink(const std::string &name="");
43
44 void calcSize() override;
45 void calclaSize(int j) override { laSize = 1; }
46 void calcgSize(int j) override { gSize = 1; }
47 void calcgdSize(int j) override { gdSize = 1; }
48
49 void updateh(int i=0) override;
50 void updateW(int i=0) override;
51 void updateg() override;
52 void updategd() override;
53 void updatePositions(Frame *frame) override;
54 void updateGeneralizedPositions() override;
55 void updateGeneralizedVelocities() override;
56 void updateForce() override;
57 void updateMoment() override;
58 void updateForceDirections() override;
59 void updateR() override;
60 void updatewb() override;
61
62 const fmatvec::Mat3xV& evalGlobalForceDirection(int i) { if(updFD) updateForceDirections(); return DF[i]; }
63 const fmatvec::Mat3xV& evalGlobalMomentDirection(int i) { if(updFD) updateForceDirections(); return DM[i]; }
64
65 fmatvec::Mat3xV& getGlobalForceDirection(int i, bool check=true) { assert((not check) or (not updFD)); return DF[i]; }
66 fmatvec::Mat3xV& getGlobalMomentDirection(int i, bool check=true) { assert((not check) or (not updFD)); return DM[i]; }
67
68 void updatehRef(fmatvec::Vec &hParent, int j=0) override;
69 void updaterRef(fmatvec::Vec &hParent, int j=0) override {}
70 void updateWRef(fmatvec::Mat &WParent, int j=0) override;
71 void updateVRef(fmatvec::Mat &WParent, int j=0) override;
72
73 void init(InitStage stage, const InitConfigSet &config) override;
74
75 void initializeUsingXML(xercesc::DOMElement * element) override;
76
77 void resetUpToDate() override;
78
79 virtual void setSupportFrame(Frame *frame) { support = frame; }
80
81 private:
82 std::string saved_supportFrame;
83 };
84
85 }
86
87 #endif
MBSim::RigidBodyLink::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: rigid_body_link.cc:166
MBSim::RigidBodyLink::updatehRef
void updatehRef(fmatvec::Vec &hParent, int j=0) override
references to complete and link smooth force vector of dynamic system parent
Definition: rigid_body_link.cc:35
MBSim::RigidBodyLink::updateVRef
void updateVRef(fmatvec::Mat &WParent, int j=0) override
references to condensed contact force direction matrix of dynamic system parent
Definition: rigid_body_link.cc:54
MBSim::Link::laSize
int laSize
size and local index of contact force parameters
Definition: link.h:545
MBSim::Link::gdSize
int gdSize
size and local index of relative velocities
Definition: link.h:540
MBSim::RigidBodyLink::updaterRef
void updaterRef(fmatvec::Vec &hParent, int j=0) override
references to nonsmooth force vector of dynamic system parent
Definition: rigid_body_link.h:69
MBSim::RigidBodyLink
Definition: rigid_body_link.h:30
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::RigidBodyLink::calcgdSize
void calcgdSize(int j) override
calculates size of gap velocities
Definition: rigid_body_link.h:47
MBSim::RigidBodyLink::calcgSize
void calcgSize(int j) override
calculates size of relative distances
Definition: rigid_body_link.h:46
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::Frame
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
MBSim::RigidBodyLink::calclaSize
void calclaSize(int j) override
calculates size of contact force parameters
Definition: rigid_body_link.h:45
MBSim::Link::gSize
int gSize
size and local index of relative distances
Definition: link.h:535
MBSim::MechanicalLink
mechanical link
Definition: mechanical_link.h:33
MBSim::RigidBodyLink::updateWRef
void updateWRef(fmatvec::Mat &WParent, int j=0) override
references to contact force direction matrix of dynamic system parent
Definition: rigid_body_link.cc:44
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30