mbsimhydraulics  3.0.0
rigid_line_pressureloss.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 _RIGID_LINE_PRESSURELOSS_H_
21 #define _RIGID_LINE_PRESSURELOSS_H_
22 
23 #include "mbsim/link.h"
24 
25 namespace MBSim {
26  class GeneralizedForceLaw;
27  class GeneralizedImpactLaw;
28 }
29 
30 namespace MBSimHydraulics {
31 
32  class RigidHLine;
33  class PressureLoss;
34  class LinePressureLoss;
35  class ClosablePressureLoss;
36  class LeakagePressureLoss;
37  class UnidirectionalPressureLoss;
38 
40  class RigidLinePressureLoss : public MBSim::Link {
41  public:
42  RigidLinePressureLoss(const std::string &name, RigidHLine * line_, PressureLoss * pressureLoss, bool bilateral_=false, bool unilateral_=false);
44  virtual std::string getType() const { return "RigidLinePressureLoss"; }
45  void plot(double t, double dt);
46 
47  bool hasSmoothPart() const {return (bilateral || (unilateral && (fabs(dpMin)>1e-6))); }
48 
49  void init(MBSim::InitStage stage);
50  // ================================
51  // Methods from init-Process
52  // ================================
53  bool isSetValued() const {return (unilateral || bilateral); }
54  void calcgdSize(int j) {gdSize=active?1:0; }
55  void calcsvSize() {svSize=isSetValued()?1:0; }
56  void updatehRef(const fmatvec::Vec& hRef, int i=0);
57  void updaterRef(const fmatvec::Vec& rRef, int i=0);
58  void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0) {};
59  void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
60  void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
61  void updaterRef(const fmatvec::Vec& rRef);
62  void updateWRef(const fmatvec::Mat& WRef, int i=0);
63  void updateVRef(const fmatvec::Mat& VRef, int i=0);
64  // ==== END Methods for init-Process ===
65 
66  // ================================
67  // Methods for update-Process
68  // ================================
69  void updateg(double t); /* zdotStandard */
70  void checkActive(int j); /* update */
71  //void checkActivegdn(); // event-driven
72  bool gActiveChanged(); /* update */
73  bool isActive() const {return active; }
74  //void calcgdSizeActive() {gdSize=1; }
75  void calclaSize(int j) {laSize=active?1:0; }
76  //void calclaSizeForActiveg() {laSize=0; } // event-driven
77  void calcrFactorSize(int j) {rFactorSize=active?1:0; }
78  void updategd(double t); /* zdotStandard */
79  void updateStopVector(double t); // event-driven
80  void updateh(double t, int j); /* zdotStandard */
81  void updateW(double t, int j); /* zdotStandard */
82  void updatedhdz(double t);
83  // ==== END Methods for update-Process ===
84 
85  // ================================
86  // Methods for solve-Process
87  // ================================
88  void checkRoot();
89  void updaterFactors();
90  void solveImpactsFixpointSingle(double dt);
91  void solveConstraintsFixpointSingle();
92  void solveImpactsGaussSeidel(double dt);
93  void solveConstraintsGaussSeidel();
94  void solveImpactsRootFinding(double dt);
95  void solveConstraintsRootFinding();
96  void jacobianImpacts();
97  void jacobianConstraints();
98  void checkImpactsForTermination(double dt);
99  void checkConstraintsForTermination();
100  // ==== END Methods for solve-Process ===
101 
102 
103  private:
104  RigidHLine * line;
105  bool active, active0;
106  bool unilateral, bilateral;
107  double gdn, gdd;
108  double dpMin;
109  double laSmooth;
110 
111  LinePressureLoss * linePressureLoss;
112  ClosablePressureLoss * closablePressureLoss;
113  LeakagePressureLoss * leakagePressureLoss;
114  UnidirectionalPressureLoss * unidirectionalPressureLoss;
115 
116  MBSim::GeneralizedForceLaw * gfl;
117  MBSim::GeneralizedImpactLaw * gil;
118  };
119 
120 }
121 
122 #endif /* ----- #ifndef _HYDLINE_PRESSURELOSS_H_ ----- */
123