mbsimhydraulics  3.0.0
dimensionless_line.h
1 /* Copyright (C) 2004-2009 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: markus.ms.schneider@gmail.com
18  */
19 
20 #ifndef _DIMENSIONLESS_LINE_H_
21 #define _DIMENSIONLESS_LINE_H_
22 
23 #include "mbsimHydraulics/hline.h"
24 
25 namespace MBSimHydraulics {
26 
28  class DimensionlessLine : public HLine {
29  public:
30  DimensionlessLine(const std::string &name) : HLine(name), Q(1), length(0) {}
31  virtual std::string getType() const { return "DimensionlessLine"; }
32 
33  void setLength(double length_) {length=length_; }
34  double getLength() const {return length; }
35 
36  virtual fmatvec::Vec getQIn() {return Q; }
37  virtual fmatvec::Vec getQOut() {return -Q; }
38  virtual fmatvec::Vec getInflowFactor() {return fmatvec::Vec(1, fmatvec::INIT, -1.); }
39  virtual fmatvec::Vec getOutflowFactor() {return fmatvec::Vec(1, fmatvec::INIT, 1.); }
40  void calcqSize() {qSize=0; }
41  void calcuSize(int j) {uSize[j]=0; }
42 
43  void initializeUsingXML(TiXmlElement *element);
44  void init(MBSim::InitStage stage);
45  void plot(double t, double dt);
46  protected:
47  fmatvec::Vec Q;
48  double length;
49  };
50 
51  class LeakagePressureLoss;
54 
55  class Leakage0DOF : public DimensionlessLine {
56  public:
57  Leakage0DOF(const std::string &name) : DimensionlessLine(name), lpl(NULL), s1vSignal(NULL), s2vSignal(NULL), glSignal(NULL), s1vPath(""), s2vPath(""), glPath("") {}
58  virtual std::string getType() const { return "Leakage0DOF"; }
59 
60  void setGapLengthSignal(MBSimControl::Signal * s) {glSignal=s; }
61  double getGapLength() const;
62  void setSurface1VelocitySignal(MBSimControl::Signal * s) {s1vSignal=s; }
63  double getSurface1Velocity() const;
64  void setSurface2VelocitySignal(MBSimControl::Signal * s) {s2vSignal=s; }
65  double getSurface2Velocity() const;
66 
67  void init(MBSim::InitStage stage);
68 
69  void updateStateDependentVariables(double t);
70 
71  void initializeUsingXML(TiXmlElement * element);
72  protected:
73  LeakagePressureLoss * lpl;
74  private:
75  MBSimControl::Signal *s1vSignal, *s2vSignal, *glSignal;
76  std::string s1vPath, s2vPath, glPath;
77  };
78 
79  class PlaneLeakage0DOF : public Leakage0DOF {
80  public:
81  PlaneLeakage0DOF(const std::string &name) : Leakage0DOF(name), hGap(0), wGap(0) {}
82  virtual std::string getType() const { return "PlaneLeakage0DOF"; }
83 
84  void setGapWidth(double wGap_) {wGap=wGap_; }
85  double getGapWidth() const {return wGap; }
86  void setGapHeight(double hGap_) {hGap=hGap_; }
87  double getGapHeight() const {return hGap; }
88  void setPlaneLeakagePressureLoss(PlaneLeakagePressureLoss * plpl);
89 
90  void initializeUsingXML(TiXmlElement * element);
91  private:
92  double hGap, wGap;
93  };
94 
96  public:
97  CircularLeakage0DOF(const std::string &name) : Leakage0DOF(name), rI(0), rO(0), hGap(0) {}
98  virtual std::string getType() const { return "CircularLeakage0DOF"; }
99 
100  void setInnerRadius(double rI_) {rI=rI_; }
101  double getInnerRadius() const {return rI; }
102  void setGapHeight(double hGap_) {hGap=hGap_; }
103  double getGapHeight() const {return hGap; }
104  double getOuterRadius() const {return rO; }
105  void setCircularLeakagePressureLoss(CircularLeakagePressureLoss * clpl);
106 
107  void init(MBSim::InitStage stage);
108 
109  void initializeUsingXML(TiXmlElement * element);
110  private:
111  double rI, rO, hGap;
112  };
113 
114 }
115 
116 #endif /* ----- #ifndef _DIMENSIONLESS_LINE_H_ ----- */
117