MBSim

Project Page
maxwell_contact.h
00001 /* Copyright (C) 2004-2012  MBSim Development Team
00002 
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Lesser General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2.1 of the License, or (at your option) any later version.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Lesser General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016 
00017  *
00018  * Contact: martin.o.foerg@googlemail.com
00019  */
00020 
00021 #ifndef MAXWELL_CONTACT_H_
00022 #define MAXWELL_CONTACT_H_
00023 
00024 #include <mbsim/object.h>
00025 #include <mbsim/contour.h>
00026 #include <mbsim/contour_pairing.h>
00027 #include <mbsim/contact_kinematics/contact_kinematics.h>
00028 #include <mbsim/link_mechanics.h>
00029 #include <mbsim/utils/function.h>
00030 #include <mbsim/utils/nonlinear_algebra.h>
00031 #include <mbsim/numerics/linear_complementarity_problem/linear_complementarity_problem.h>
00032 
00033 #ifdef HAVE_OPENMBVCPPINTERFACE
00034 #include <openmbvcppinterface/group.h>
00035 #include <openmbvcppinterface/frame.h>
00036 #endif
00037 
00038 #include <fmatvec.h>
00039 #include <map>
00040 
00041 #ifdef HAVE_OPENMBVCPPINTERFACE
00042 namespace OpenMBV {
00043   class Frame;
00044   class Arrow;
00045 }
00046 #endif
00047 
00048 namespace MBSim {
00049 
00050   class GeneralizedForceLaw;
00051   class FrictionForceLaw;
00052   class GeneralizedImpactLaw;
00053   class FrictionImpactLaw;
00054   class ContourPointData;
00055 
00064   class MaxwellContact : public MBSim::LinkMechanics {
00065     public:
00066 
00071       MaxwellContact(const std::string &name);
00072 
00076       virtual ~MaxwellContact() {
00077       }
00078 
00079       /* INHERITED INTERFACE OF LINKINTERFACE */
00080       virtual void updateh(double t, int k=0);
00081       virtual void updateg(double t);
00082       virtual void updategd(double t);
00083       virtual void updateJacobians(double t, int j=0);
00084       /***************************************************/
00085 
00086       /* INHERITED INTERFACE OF LINK */
00087       virtual void updatehRef(const fmatvec::Vec &hRef, int k=0);
00088       virtual void init(InitStage stage);
00089       virtual bool isSetValued() const {
00090         return false; //The MaxwellContact isn't a set valued contact, but also not regularized (single valued) but its kind of multi-valued
00091       }
00092       virtual bool isActive() const {
00093         return true; //the Maxwell contact is always active as the the distances are computed dependent on the forces
00094       }
00095       virtual bool gActiveChanged() {
00096         return false; //gActive (probably) changes every timestep //TODO what does this function?
00097       }
00098       virtual void checkActiveg();
00099       /***************************************************/
00100 
00101       /*INHERITED INTERFACE OF OBJECT*/
00102       void setParent(DynamicSystem *sys);
00103       /*******************************/
00104 
00105       /* INHERITED INTERFACE OF ELEMENT */
00106       virtual std::string getType() const {
00107         return "MaxwellContact";
00108       }
00109       virtual void plot(double t, double dt = 1);
00110       virtual void closePlot();
00111       /***************************************************/
00112 
00113       /* GETTER / SETTER */
00114       ContourPairing* getContourPariing(const int & contactNumber) {
00115         return contourPairing[contactNumber];
00116       }
00117       void setLCPSolvingStrategy(LCPSolvingStrategy strategy) {
00118         lcpSolvingStrategy = strategy;
00119       }
00120 
00121       LCPSolvingStrategy getLCPSolvingStrategy(void) {
00122         return lcpSolvingStrategy;
00123       }
00124 
00128       void setDebuglevel(const int & Debuglevel_) {
00129         DEBUGLEVEL = Debuglevel_;
00130       }
00131 
00132 
00142       void addContourPairing(ContourPairing* contourPairing_);// (Contour *contour1, Contour *contour2, std::string name, bool plotContact = true, ContactKinematics* contactKinematics_ = 0);
00143 
00152       void addContourCoupling(Contour *contour1, Contour *contour2, InfluenceFunction *fct);
00153 
00154     protected:
00158       virtual void updatePossibleContactPoints();
00159 
00163       virtual void updateInfluenceMatrix(const double t);
00164 
00168       void updateRigidBodyGap(const double & t);
00169 
00174       virtual double computeInfluenceCoefficient(const int &currentContactNumber);
00175 
00181       virtual double computeInfluenceCoefficient(const int &currentContactNumber, const int &couplingContactNumber);
00182 
00183       /*
00184        * \brief computes the "material constant" to have a good guess for the lambda-vector
00185        */
00186       virtual void computeMaterialConstant(const double & t);
00187 
00191       virtual void fitSolution0(const double & t);
00192 
00196       std::vector<ContourPairing*> contourPairing;
00197 
00201       std::vector<int> possibleContactPoints;
00202 
00206       fmatvec::SymMat C;
00207 
00208       /*
00209        * \brief vector of rigid body distances(gaps) for the active contacts
00210        */
00211       fmatvec::Vec rigidBodyGap;
00212 
00216       std::map<std::pair<Contour*, Contour*>, InfluenceFunction*> influenceFunctions;
00217 
00221       LCPSolvingStrategy lcpSolvingStrategy;
00222 
00226       fmatvec::Vec solution0;
00227 
00231       double matConst;
00232 
00236       bool matConstSetted;
00237 
00247       int DEBUGLEVEL;
00248   };
00249 
00250 }
00251 #endif /* MAXWELL_CONTACT_H_ */