mbsimhydraulics  4.0.0
rigid_line_pressureloss.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  _RIGID_LINE_PRESSURELOSS_H_
00021 #define  _RIGID_LINE_PRESSURELOSS_H_
00022 
00023 #include "mbsim/link.h"
00024 
00025 namespace MBSim {
00026   class GeneralizedForceLaw;
00027   class GeneralizedImpactLaw;
00028 }
00029 
00030 namespace MBSimHydraulics {
00031 
00032   class RigidHLine; 
00033   class PressureLoss;
00034   class LinePressureLoss;
00035   class ClosablePressureLoss;
00036   class LeakagePressureLoss;
00037   class UnidirectionalPressureLoss;
00038 
00040   class RigidLinePressureLoss : public MBSim::Link {
00041     public:
00042       RigidLinePressureLoss(const std::string &name, RigidHLine * line_, PressureLoss * pressureLoss, bool bilateral_=false, bool unilateral_=false);
00043       ~RigidLinePressureLoss();
00044       virtual std::string getType() const { return "RigidLinePressureLoss"; }
00045       void plot(double t, double dt);
00046 
00047       bool hasSmoothPart() const {return (bilateral || (unilateral && (fabs(dpMin)>1e-6))); }
00048 
00049       void init(InitStage stage);
00050       // ================================
00051       // Methods from init-Process
00052       // ================================
00053       bool isSetValued() const {return (unilateral || bilateral); }
00054       bool isSingleValued() const { return not isSetValued(); }
00055       void calcgdSize(int j) {gdSize=active?1:0; }
00056       void calcsvSize() {svSize=isSetValued()?1:0; }
00057       void updatehRef(const fmatvec::Vec& hRef, int i=0);
00058       void updaterRef(const fmatvec::Vec& rRef, int i=0);
00059       void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0) {};
00060       void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
00061       void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
00062       void updaterRef(const fmatvec::Vec& rRef);
00063       void updateWRef(const fmatvec::Mat& WRef, int i=0);
00064       void updateVRef(const fmatvec::Mat& VRef, int i=0);
00065       // ==== END Methods for init-Process ===
00066 
00067       // ================================
00068       // Methods for update-Process
00069       // ================================
00070       void updateg(double t); /* zdotStandard */
00071       void checkActive(int j); /* update */
00072       //void checkActivegdn(); // event-driven
00073       bool gActiveChanged(); /* update */
00074       bool isActive() const {return active; }
00075       //void calcgdSizeActive() {gdSize=1; }
00076       void calclaSize(int j) {laSize=active?1:0; }
00077       //void calclaSizeForActiveg() {laSize=0; } // event-driven
00078       void calcrFactorSize(int j) {rFactorSize=active?1:0; }
00079       void updategd(double t); /* zdotStandard */
00080       void updateStopVector(double t); // event-driven
00081       void updateh(double t, int j); /* zdotStandard */
00082       void updateW(double t, int j); /* zdotStandard */
00083       void updatedhdz(double t);
00084       // ==== END Methods for update-Process ===
00085 
00086       // ================================
00087       // Methods for solve-Process
00088       // ================================
00089       void checkRoot();
00090       void updaterFactors();
00091       void solveImpactsFixpointSingle(double dt);
00092       void solveConstraintsFixpointSingle();
00093       void solveImpactsGaussSeidel(double dt);
00094       void solveConstraintsGaussSeidel();
00095       void solveImpactsRootFinding(double dt);
00096       void solveConstraintsRootFinding();
00097       void jacobianImpacts();
00098       void jacobianConstraints();
00099       void checkImpactsForTermination(double dt);
00100       void checkConstraintsForTermination();
00101       // ==== END Methods for solve-Process ===
00102 
00103 
00104     private:
00105       RigidHLine * line;
00106       bool active, active0;
00107       bool unilateral, bilateral;
00108       double gdn, gdd;
00109       double dpMin;
00110       double laSmooth;
00111 
00112       LinePressureLoss * linePressureLoss;
00113       ClosablePressureLoss * closablePressureLoss;
00114       LeakagePressureLoss * leakagePressureLoss;
00115       UnidirectionalPressureLoss * unidirectionalPressureLoss;
00116 
00117       MBSim::GeneralizedForceLaw * gfl;
00118       MBSim::GeneralizedImpactLaw * gil;
00119   };
00120 
00121 }
00122 
00123 #endif   /* ----- #ifndef _HYDLINE_PRESSURELOSS_H_  ----- */
00124