All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
spring_damper.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * Contact: martin.o.foerg@googlemail.com
17  */
18 
19 #ifndef _SPRING_DAMPER_H_
20 #define _SPRING_DAMPER_H_
21 
22 #include "mbsim/links/frame_link.h"
23 #include "mbsim/functions/function.h"
24 
25 #include "mbsim/utils/boost_parameters.h"
26 #include "mbsim/utils/openmbv_utils.h"
27 
28 namespace MBSim {
29 
34  class SpringDamper : public FrameLink {
35  protected:
37  double l0;
38  std::shared_ptr<OpenMBV::CoilSpring> coilspringOpenMBV;
39  public:
40  SpringDamper(const std::string &name="");
41  ~SpringDamper();
42  void updatelaF();
43 
44  /*INHERITED INTERFACE OF LINK*/
45  bool isActive() const { return true; }
46  bool gActiveChanged() { return false; }
47  bool isSingleValued() const { return true; }
48  std::string getType() const { return "SpringDamper"; }
49  void init(InitStage stage);
50  /*****************************/
51 
57  void setForceFunction(Function<double(double,double)> *func_) {
58  func=func_;
59  func->setParent(this);
60  func->setName("Force");
61  }
62 
64  void setUnloadedLength(double l0_) { l0 = l0_; }
65 
66  void plot();
67  void initializeUsingXML(xercesc::DOMElement *element);
68 
70  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVCoilSpring, tag, (optional (numberOfCoils,(int),3)(springRadius,(double),1)(crossSectionRadius,(double),-1)(nominalLength,(double),-1)(type,(OpenMBV::CoilSpring::Type),OpenMBV::CoilSpring::tube)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0)(minimalColorValue,(double),0)(maximalColorValue,(double),1))) {
71  OpenMBVCoilSpring ombv(springRadius,crossSectionRadius,1,numberOfCoils,nominalLength,type,diffuseColor,transparency,minimalColorValue,maximalColorValue);
72  coilspringOpenMBV=ombv.createOpenMBV();
73  }
74  };
75 
76 }
77 
78 #endif
bool gActiveChanged()
Definition: spring_damper.h:46
void setUnloadedLength(double l0_)
Set unloaded length.
Definition: spring_damper.h:64
Definition: openmbv_utils.h:147
void setForceFunction(Function< double(double, double)> *func_)
Set function for the force calculation. The first input parameter to that function is the distance re...
Definition: spring_damper.h:57
InitStage
The stages of the initialization.
Definition: element.h:97
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBVCoilSpring, tag,(optional(numberOfCoils,(int), 3)(springRadius,(double), 1)(crossSectionRadius,(double),-1)(nominalLength,(double),-1)(type,(OpenMBV::CoilSpring::Type), OpenMBV::CoilSpring::tube)(diffuseColor,(const fmatvec::Vec3 &),"[-1;1;1]")(transparency,(double), 0)(minimalColorValue,(double), 0)(maximalColorValue,(double), 1)))
Visualise the SpringDamper using a OpenMBV::CoilSpring.
Definition: spring_damper.h:70
std::string name
name of element
Definition: element.h:298
bool isActive() const
Definition: spring_damper.h:45
void plot()
plots time dependent data
Definition: spring_damper.cc:69
std::string getType() const
Definition: spring_damper.h:48
bool isSingleValued() const
asks the link if it contains single valued force laws that contribute to the right-hand side vector h...
Definition: spring_damper.h:47
void setName(const std::string &str)
Definition: element.h:163
void init(InitStage stage)
plots time series header
Definition: spring_damper.cc:50
A spring damper force law. This class connects two frames and applies a force in it, which depends in the distance and relative velocity between the two frames.
Definition: spring_damper.h:34

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML