mbsimhydraulics  3.2.0
checkvalve.h
00001 /* Copyright (C) 2004-2009 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  * Contact: markus.ms.schneider@gmail.com
00018  */
00019 
00020 #ifndef  _CHECKVALVE_H_
00021 #define  _CHECKVALVE_H_
00022 
00023 #include "mbsim/group.h"
00024 #include "mbsim/utils/function.h"
00025 
00026 namespace MBSim {
00027   class Frame;
00028   class RigidBody;
00029   class Contact;
00030   class SpringDamper;
00031   class GeneralizedImpactLaw;
00032   class GeneralizedForceLaw;
00033 }
00034 
00035 namespace MBSimControl {
00036   class GeneralizedCoordinateSensor;
00037 }
00038 
00039 namespace MBSimHydraulics {
00040 
00041   class ClosableRigidLine;
00042   class CheckvalveClosablePressureLoss;
00043   
00045   class Checkvalve : public MBSim::Group {
00046     public:
00047       Checkvalve(const std::string &name="");
00048       
00049       void setFrameOfReference(MBSim::Frame * ref);
00050       void setLineLength(double lLine);
00051       void setLineDiameter(double lDiameter);
00052       void setLinePressureLoss(CheckvalveClosablePressureLoss * ccpl);
00053       void setLineMinimalXOpen(double xMin);
00054       void setLineSetValued(bool setValued=true);
00055       void setBallMass(double mBall_);
00056       void setBallInitialPosition(double x0Ball_);
00057       void setSpringForceFunction(MBSim::Function2<double,double,double> *func);
00058       void setSeatContactImpactLaw(MBSim::GeneralizedImpactLaw * seatGIL_);
00059       void setSeatContactForceLaw(MBSim::GeneralizedForceLaw * seatGFL_);
00060       void setMaximalOpening(double hMax_) {hMax=hMax_; }
00061       void setMaximalContactImpactLaw(MBSim::GeneralizedImpactLaw * seatGIL_);
00062       void setMaximalContactForceLaw(MBSim::GeneralizedForceLaw * seatGFL_);
00063 #ifdef HAVE_OPENMBVCPPINTERFACE
00064       void enableOpenMBVFrames(bool openMBVFrames_=true) {openMBVFrames=openMBVFrames_; }
00065       void enableOpenMBVArrows(bool openMBVArrows_=true) {openMBVArrows=openMBVArrows_; }
00066       void enableOpenMBVBodies(bool openMBVBodies_=true) {openMBVBodies=openMBVBodies_; }
00067 #endif
00068 
00069       ClosableRigidLine * getLine() {return line; }
00070       MBSim::RigidBody * getBallSeat() {return ballSeat; }
00071       MBSim::RigidBody * getBall() {return ball; }
00072       MBSim::Contact * getSeatContact() {return seatContact; }
00073       MBSim::Contact * getMaximalContact() {return maxContact; }
00074       MBSim::SpringDamper * getSpring() {return spring; }
00075       MBSimControl::GeneralizedCoordinateSensor * getXOpen() {return xOpen; }
00076       
00077       void init(MBSim::InitStage stage);
00078       
00079       void initializeUsingXML(MBXMLUtils::TiXmlElement * element);
00080 
00081     private:
00082       ClosableRigidLine * line;
00083       MBSim::RigidBody * ballSeat;
00084       MBSim::RigidBody * ball;
00085       MBSim::Contact * seatContact;
00086       MBSim::Contact * maxContact;
00087       MBSim::SpringDamper * spring;
00088       MBSimControl::GeneralizedCoordinateSensor * xOpen;
00089       unsigned int fromNodeAreaIndex, toNodeAreaIndex;
00090       double hMax, mBall;
00091       std::string refFrameString;
00092 #ifdef HAVE_OPENMBVCPPINTERFACE
00093       bool openMBVBodies, openMBVArrows, openMBVFrames;
00094 #endif
00095   };
00096 
00097 }
00098 
00099 #endif   /* ----- #ifndef _CHECKVALVE_H_ ----- */