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 template<typename Sig> class Function;
33
41 class ContactKinematics : virtual public fmatvec::Atom {
42 public:
46 ContactKinematics(int maxNumContacts_=1) : maxNumContacts(maxNumContacts_) { }
47
51 ~ContactKinematics() override = default;
52
53 /* INTERFACE FOR DERIVED CLASSES */
58 virtual void assignContours(const std::vector<Contour*> &contour_) { contour = contour_; }
59
60 virtual void calcisSize() { isSize = 0; }
61 void setisInd(int ind) { isInd = ind; }
62 int getisSize() { return isSize; }
63 virtual void updateInternalStateRef(fmatvec::Vec &curisParent, fmatvec::Vec &nextisParent) {
64 curis.ref(curisParent, fmatvec::RangeV(isInd,isInd+isSize-1));
65 nextis.ref(nextisParent, fmatvec::RangeV(isInd,isInd+isSize-1));
66 }
67
68 virtual void search() { }
69
75 virtual void updateg(std::vector<SingleContact> &contact);
76
82 virtual void updateg(SingleContact &contact, int i=0) { }
83
89 virtual void updatewb(std::vector<SingleContact> &contact) { for(int i=0; i<maxNumContacts; i++) updatewb(contact[i],i); }
90
96 virtual void updatewb(SingleContact &contact, int i=0);
97
103 void assignContours(Contour *contour1, Contour *contour2) { std::vector<Contour*> c; c.push_back(contour1);c.push_back(contour2); assignContours(c); }
104
108 int getMaximumNumberOfContacts() const { return maxNumContacts; }
109
110 void setGlobalSearch(bool gS_=true) { gS = gS_; }
111 void setInitialGlobalSearch(bool iGS_=true) { iGS = iGS_; }
112
116 virtual void setInitialGuess(const fmatvec::MatV &zeta0_) { }
117
121 void setTolerance(double tol_) { tol = tol_; }
122
126 void setMaximumNumberOfContacts(int maxNumContacts_) { maxNumContacts = maxNumContacts_; }
127
128 static std::vector<double> searchPossibleContactPoints(Function<double(double)> *func, double eta, const std::vector<double> &nodes, double tol);
129
130 static std::vector<double> searchPossibleContactPoints(Function<fmatvec::Vec(fmatvec::Vec)> *func, int i, fmatvec::Vec &zeta, const std::vector<double> &nodes, double tol);
131
132 protected:
136 double tol{1e-10};
137
141 int maxNumContacts{1};
142
143 fmatvec::Vec curis, nextis;
144 int isInd { 0 };
145 int isSize { 0 };
146
147 std::vector<Contour*> contour;
148
149 bool gS{false};
150 bool iGS{false};
151 };
152
153 }
154
155 #endif /* _CONTACT_KINEMATICS_H_ */
MBSim::ContactKinematics::setMaximumNumberOfContacts
void setMaximumNumberOfContacts(int maxNumContacts_)
set maximum number of contacts
Definition: contact_kinematics.h:126
MBSim::ContactKinematics::getMaximumNumberOfContacts
int getMaximumNumberOfContacts() const
Definition: contact_kinematics.h:108
MBSim::ContactKinematics::setInitialGuess
virtual void setInitialGuess(const fmatvec::MatV &zeta0_)
set initial guess for root-finding
Definition: contact_kinematics.h:116
MBSim::ContactKinematics::updateg
virtual void updateg(SingleContact &contact, int i=0)
compute contact kinematics for a single contact
Definition: contact_kinematics.h:82
MBSim::Contour
basic class for contour definition for rigid (which do not know about their shape) and flexible (they...
Definition: contour.h:40
MBSim::ContactKinematics::maxNumContacts
int maxNumContacts
maximum number of contacts
Definition: contact_kinematics.h:141
MBSim::ContactKinematics::assignContours
virtual void assignContours(const std::vector< Contour * > &contour_)
treats ordering of contours
Definition: contact_kinematics.h:58
MBSim::ContactKinematics::setTolerance
void setTolerance(double tol_)
set tolerance for root-finding
Definition: contact_kinematics.h:121
MBSim::ContactKinematics::~ContactKinematics
~ContactKinematics() override=default
destructor
MBSim::Function
Definition: contact_kinematics.h:32
MBSim::ContactKinematics::updatewb
virtual void updatewb(std::vector< SingleContact > &contact)
compute contact kinematics on acceleration level for all contacts
Definition: contact_kinematics.h:89
MBSim::ContactKinematics::assignContours
void assignContours(Contour *contour1, Contour *contour2)
treats ordering of contours
Definition: contact_kinematics.h:103
MBSim::ContactKinematics::tol
double tol
tolerance for root-finding
Definition: contact_kinematics.h:136
MBSim::SingleContact
class for contacts
Definition: single_contact.h:46
MBSim::ContactKinematics
basic class for contact kinematical calculations
Definition: contact_kinematics.h:41
MBSim::ContactKinematics::ContactKinematics
ContactKinematics(int maxNumContacts_=1)
constructor
Definition: contact_kinematics.h:46
MBSim::ContactKinematics::updateg
virtual void updateg(std::vector< SingleContact > &contact)
compute contact kinematics for all contacts
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30