mbsim  4.0.0
MBSim Kernel
mechanical_link.h
1 /* Copyright (C) 2004-2016 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@googlemail.com
18  */
19 
20 #ifndef _MECHANICAL_LINK_H_
21 #define _MECHANICAL_LINK_H_
22 
23 #include "mbsim/links/link.h"
24 
25 namespace MBSim {
26 
27  extern const PlotFeatureEnum force, moment;
28 
33  class MechanicalLink : public Link {
34  public:
39  MechanicalLink(const std::string &name);
40 
41  void resetUpToDate() override;
42 
43  virtual void updatePositions() { }
44  virtual void updateVelocities() { }
45  void updateGeneralizedForces() override;
46  virtual void updateForce() { }
47  virtual void updateMoment() { }
48  virtual void updateForceDirections() { }
49  virtual void updatelaF() { }
50  virtual void updatelaM() { }
51  virtual void updateR() { }
52 
53  const fmatvec::Vec3& evalForce(int i=1) { if(updF) updateForce(); return F[i]; }
54  const fmatvec::Vec3& evalMoment(int i=1) { if(updM) updateMoment(); return M[i]; }
55  const fmatvec::Mat3xV& evalRF(int i=1) { if(updRMV) updateR(); return RF[i]; }
56  const fmatvec::Mat3xV& evalRM(int i=1) { if(updRMV) updateR(); return RM[i]; }
57  const fmatvec::VecV& evallaF() { if(updlaF) updatelaF(); return lambdaF; }
58  const fmatvec::VecV& evallaM() { if(updlaM) updatelaM(); return lambdaM; }
59 
60  fmatvec::Vec3& getForce(int i=1, bool check=true) { assert((not check) or (not updF)); return F[i]; }
61  fmatvec::Vec3& getMoment(int i=1, bool check=true) { assert((not check) or (not updM)); return M[i]; }
62 
63  Frame* getPointOfApplication(int i) { return P[i]; }
64 
65  int getNumberOfForces() { return F.size(); }
66 
67  void init(InitStage stage, const InitConfigSet &config) override;
68  void plot() override;
69 
70  protected:
71  std::vector<Frame*> P;
72 
73  std::vector<fmatvec::Mat3xV> RF, RM;
74 
75  fmatvec::VecV lambdaF, lambdaM;
76 
77  std::vector<fmatvec::Vec3> F, M;
78 
82  fmatvec::RangeV iF, iM;
83 
84  bool updF, updM, updRMV, updlaF, updlaM;
85  };
86 }
87 
88 #endif
InitStage
The stages of the initialization.
Definition: element.h:62
std::string name
name of element
Definition: element.h:249
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
namespace MBSim
Definition: bilateral_constraint.cc:29