All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
generalized_force_law.h
1 /* Copyright (C) 2004-2014 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 _GENERALIZED_FORCE_LAW_H_
21 #define _GENERALIZED_FORCE_LAW_H_
22 
23 #include "mbsim/functions/function.h"
24 
25 namespace MBSim {
26 
32  class GeneralizedForceLaw : public Element {
33  public:
37  GeneralizedForceLaw(Function<double(double,double)> *forceFunc_=NULL) : Element(uniqueDummyName(this)), forceFunc(forceFunc_) {
38  if(forceFunc)
39  forceFunc->setParent(this);
40  }
41 
45  virtual ~GeneralizedForceLaw() { if(forceFunc) delete forceFunc; forceFunc = NULL; };
46 
47  void init(Element::InitStage stage) {
48  Element::init(stage);
49  if(forceFunc)
50  forceFunc->init(stage);
51  }
52 
53  /* INTERFACE FOR DERIVED CLASSES */
60  virtual bool isClosed(double g, double gTol) { return true; }
61  virtual bool remainsClosed(double s, double sTol) { return true; }
62 
71  virtual double project(double la, double gdn, double r, double laMin=0) { return 0; }
72  virtual fmatvec::Vec diff(double la, double gdn, double r, double laMin=0) { return fmatvec::Vec(2, fmatvec::INIT, 0); }
73  virtual double solve(double G, double gdn) { return 0; }
74 
82  virtual bool isFulfilled(double la, double gdn, double tolla, double tolgd, double laMin=0) { return true; }
83 
87  virtual bool isSetValued() const = 0;
88 
93  virtual void initializeUsingXML(xercesc::DOMElement *element) {}
94 
98  virtual std::string getType() const { return "GeneralizedForceLaw"; }
99  /***************************************************/
100 
108  double operator()(double g, double gd) { assert(forceFunc); return (*forceFunc)(g,gd); }
109 
115  void setForceFunction(Function<double(double,double)> *forceFunc_) {
116  forceFunc=forceFunc_;
117  forceFunc->setParent(this);
118  }
119 
120  protected:
125  };
126 
127 }
128 
129 #endif
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:32
virtual bool isFulfilled(double la, double gdn, double tolla, double tolgd, double laMin=0)
Definition: generalized_force_law.h:82
virtual double project(double la, double gdn, double r, double laMin=0)
prox function evaluation
Definition: generalized_force_law.h:71
Vector< Ref, double > Vec
Function< double(double, double)> * forceFunc
force function for a regularized contact law
Definition: generalized_force_law.h:124
GeneralizedForceLaw(Function< double(double, double)> *forceFunc_=NULL)
constructor
Definition: generalized_force_law.h:37
basic class of MBSim mainly for plotting
Definition: element.h:58
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize the force law using XML
Definition: generalized_force_law.h:93
void init(Element::InitStage stage)
plots time series header
Definition: generalized_force_law.h:47
InitStage
The stages of the initialization.
Definition: element.h:97
virtual bool isClosed(double g, double gTol)
decides, if force law is active
Definition: generalized_force_law.h:60
virtual ~GeneralizedForceLaw()
destructor
Definition: generalized_force_law.h:45
Definition: planar_contour.h:31
double operator()(double g, double gd)
Definition: generalized_force_law.h:108
virtual void init(InitStage stage)
plots time series header
Definition: element.cc:70
virtual std::string getType() const
Definition: generalized_force_law.h:98
virtual bool isSetValued() const =0
void setForceFunction(Function< double(double, double)> *forceFunc_)
Set the force function for use in regularisized constitutive laws The first input parameter to the fo...
Definition: generalized_force_law.h:115

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML