MBSim

Project Page
maxwell_contact.h
1 /* Copyright (C) 2004-2012 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  *
18  * Contact: martin.o.foerg@googlemail.com
19  */
20 
21 #ifndef MAXWELL_CONTACT_H_
22 #define MAXWELL_CONTACT_H_
23 
24 #include <mbsim/object.h>
25 #include <mbsim/contour.h>
26 #include <mbsim/contour_pairing.h>
27 #include <mbsim/contact_kinematics/contact_kinematics.h>
28 #include <mbsim/link_mechanics.h>
29 #include <mbsim/utils/function.h>
30 #include <mbsim/utils/nonlinear_algebra.h>
31 #include <mbsim/numerics/linear_complementarity_problem/linear_complementarity_problem.h>
32 
33 #ifdef HAVE_OPENMBVCPPINTERFACE
34 #include <openmbvcppinterface/group.h>
35 #include <openmbvcppinterface/frame.h>
36 #endif
37 
38 #include <fmatvec.h>
39 #include <map>
40 
41 #ifdef HAVE_OPENMBVCPPINTERFACE
42 namespace OpenMBV {
43  class Frame;
44  class Arrow;
45 }
46 #endif
47 
48 namespace MBSim {
49 
50  class GeneralizedForceLaw;
51  class FrictionForceLaw;
52  class GeneralizedImpactLaw;
53  class FrictionImpactLaw;
54  class ContourPointData;
55 
65  public:
66 
71  MaxwellContact(const std::string &name);
72 
76  virtual ~MaxwellContact() {
77  }
78 
79  /* INHERITED INTERFACE OF LINKINTERFACE */
80  virtual void updateh(double t, int k=0);
81  virtual void updateg(double t);
82  virtual void updategd(double t);
83  virtual void updateJacobians(double t, int j=0);
84  /***************************************************/
85 
86  /* INHERITED INTERFACE OF LINK */
87  virtual void updatehRef(const fmatvec::Vec &hRef, int k=0);
88  virtual void init(InitStage stage);
89  virtual bool isSetValued() const {
90  return false; //The MaxwellContact isn't a set valued contact, but also not regularized (single valued) but its kind of multi-valued
91  }
92  virtual bool isActive() const {
93  return true; //the Maxwell contact is always active as the the distances are computed dependent on the forces
94  }
95  virtual bool gActiveChanged() {
96  return false; //gActive (probably) changes every timestep //TODO what does this function?
97  }
98  virtual void checkActiveg();
99  /***************************************************/
100 
101  /*INHERITED INTERFACE OF OBJECT*/
102  void setParent(DynamicSystem *sys);
103  /*******************************/
104 
105  /* INHERITED INTERFACE OF ELEMENT */
106  virtual std::string getType() const {
107  return "MaxwellContact";
108  }
109  virtual void plot(double t, double dt = 1);
110  virtual void closePlot();
111  /***************************************************/
112 
113  /* GETTER / SETTER */
114  ContourPairing* getContourPariing(const int & contactNumber) {
115  return contourPairing[contactNumber];
116  }
117  void setLCPSolvingStrategy(LCPSolvingStrategy strategy) {
118  lcpSolvingStrategy = strategy;
119  }
120 
121  LCPSolvingStrategy getLCPSolvingStrategy(void) {
122  return lcpSolvingStrategy;
123  }
124 
128  void setDebuglevel(const int & Debuglevel_) {
129  DEBUGLEVEL = Debuglevel_;
130  }
131 
132 
142  void addContourPairing(ContourPairing* contourPairing_);// (Contour *contour1, Contour *contour2, std::string name, bool plotContact = true, ContactKinematics* contactKinematics_ = 0);
143 
152  void addContourCoupling(Contour *contour1, Contour *contour2, InfluenceFunction *fct);
153 
154  protected:
158  virtual void updatePossibleContactPoints();
159 
163  virtual void updateInfluenceMatrix(const double t);
164 
168  void updateRigidBodyGap(const double & t);
169 
174  virtual double computeInfluenceCoefficient(const int &currentContactNumber);
175 
181  virtual double computeInfluenceCoefficient(const int &currentContactNumber, const int &couplingContactNumber);
182 
183  /*
184  * \brief computes the "material constant" to have a good guess for the lambda-vector
185  */
186  virtual void computeMaterialConstant(const double & t);
187 
191  virtual void fitSolution0(const double & t);
192 
196  std::vector<ContourPairing*> contourPairing;
197 
201  std::vector<int> possibleContactPoints;
202 
206  fmatvec::SymMat C;
207 
208  /*
209  * \brief vector of rigid body distances(gaps) for the active contacts
210  */
211  fmatvec::Vec rigidBodyGap;
212 
216  std::map<std::pair<Contour*, Contour*>, InfluenceFunction*> influenceFunctions;
217 
221  LCPSolvingStrategy lcpSolvingStrategy;
222 
226  fmatvec::Vec solution0;
227 
231  double matConst;
232 
237 
248  };
249 
250 }
251 #endif /* MAXWELL_CONTACT_H_ */