mbsim  4.0.0
MBSim Kernel
contact_kinematics.h
1 /* Copyright (C) 2004-2009 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 _CONTACT_KINEMATICS_H_
21 #define _CONTACT_KINEMATICS_H_
22 
23 #include "mbsim/links/single_contact.h"
24 #include "fmatvec/fmatvec.h"
25 #include "fmatvec/atom.h"
26 #include <vector>
27 
28 namespace MBSim {
29 
30  class ContourFrame;
31  class Contour;
32 
40  class ContactKinematics : virtual public fmatvec::Atom {
41  public:
45  ContactKinematics(int maxNumContacts_=1) : maxNumContacts(maxNumContacts_) { }
46 
50  ~ContactKinematics() override = default;
51 
52  /* INTERFACE FOR DERIVED CLASSES */
57  virtual void assignContours(const std::vector<Contour*> &contour) = 0;
58 
64  virtual void updateg(std::vector<SingleContact> &contact) { for(int i=0; i<maxNumContacts; i++) updateg(contact[i],i); }
65 
71  virtual void updateg(SingleContact &contact, int i=0) { }
72 
78  virtual void updatewb(std::vector<SingleContact> &contact) { for(int i=0; i<maxNumContacts; i++) updatewb(contact[i],i); }
79 
85  virtual void updatewb(SingleContact &contact, int i=0) { throw std::runtime_error("(ContactKinematics:updatewb): Not implemented!"); }
86 
92  void assignContours(Contour *contour1, Contour *contour2) { std::vector<Contour*> c; c.push_back(contour1);c.push_back(contour2); assignContours(c); }
93 
98 
99  virtual void setSearchAllContactPoints(bool searchAllCP_=true) { }
100 
104  virtual void setInitialGuess(const fmatvec::MatV &zeta0_) { }
105 
109  void setTolerance(double tol_) { tol = tol_; }
110 
114  void setMaximumNumberOfContacts(int maxNumContacts_) { maxNumContacts = maxNumContacts_; }
115 
116  protected:
120  double tol{1e-10};
121 
126  };
127 
128 }
129 
130 #endif /* _CONTACT_KINEMATICS_H_ */
void setMaximumNumberOfContacts(int maxNumContacts_)
set maximum number of contacts
Definition: contact_kinematics.h:114
int getMaximumNumberOfContacts() const
Definition: contact_kinematics.h:97
virtual void setInitialGuess(const fmatvec::MatV &zeta0_)
set initial guess for root-finding
Definition: contact_kinematics.h:104
virtual void updateg(SingleContact &contact, int i=0)
compute contact kinematics for a single contact
Definition: contact_kinematics.h:71
virtual void updatewb(SingleContact &contact, int i=0)
compute contact kinematics on acceleration level for a single contact
Definition: contact_kinematics.h:85
basic class for contour definition for rigid (which do not know about their shape) and flexible (they...
Definition: contour.h:40
int maxNumContacts
maximum number of contacts
Definition: contact_kinematics.h:125
virtual void assignContours(const std::vector< Contour * > &contour)=0
treats ordering of contours
void setTolerance(double tol_)
set tolerance for root-finding
Definition: contact_kinematics.h:109
~ContactKinematics() override=default
destructor
virtual void updatewb(std::vector< SingleContact > &contact)
compute contact kinematics on acceleration level for all contacts
Definition: contact_kinematics.h:78
void assignContours(Contour *contour1, Contour *contour2)
treats ordering of contours
Definition: contact_kinematics.h:92
double tol
tolerance for root-finding
Definition: contact_kinematics.h:120
class for contacts
Definition: single_contact.h:46
basic class for contact kinematical calculations
Definition: contact_kinematics.h:40
ContactKinematics(int maxNumContacts_=1)
constructor
Definition: contact_kinematics.h:45
virtual void updateg(std::vector< SingleContact > &contact)
compute contact kinematics for all contacts
Definition: contact_kinematics.h:64
namespace MBSim
Definition: eigenanalyzer.cc:47