mbsimhydraulics  4.0.0
MBSim Hydraulics Module
hnode_mec.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 _HNODE_MEC_H_
21 #define _HNODE_MEC_H_
22 
23 #include "hnode.h"
24 #include <mbsim/functions/function.h>
25 
26 namespace MBSim {
27  class Frame;
28  class GeneralizedForceLaw;
29  class GeneralizedImpactLaw;
30 }
31 
32 namespace MBSimHydraulics {
33 
34  class HydFluid;
35  class OilBulkModulus;
36 
38  MBSim::Frame * frame;
39  fmatvec::Vec normal;
40  double area;
41  bool considerVolumeChange;
42  };
43 
45  MBSim::Frame * frame;
46  fmatvec::Vec normal;
47  MBSim::Frame * fref;
48  double area;
49  bool considerVolumeChange;
50  };
51 
53  class HNodeMec : public HNode {
54  public:
55  HNodeMec(const std::string &name);
56  ~HNodeMec() override;
57 
58  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVArrows, tag, (optional (size,(double),1))) {
59  openMBVArrowSize=(size>.0)?size:.0;
60  }
61 
62  void setInitialVolume(double V0_) {V0=V0_; }
63  unsigned int addTransMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, bool considerVolumeChange=true);
64  unsigned int addRotMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, MBSim::Frame * frameOfReference, bool considerVolumeChange=true);
65  void setTransMecArea(unsigned int i, double area) {connectedTransFrames[i].area=area; }
66 
67  void calcxSize() override {xSize=1; }
68 
69  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
70  void initializeUsingXML(xercesc::DOMElement *element) override;
71 
72  void updateWRef(fmatvec::Mat& Wref, int i=0) override;
73  void updateVRef(fmatvec::Mat& Vref, int i=0) override;
74  void updatehRef(fmatvec::Vec& href, int i=0) override;
75  virtual void updatedhdqRef(fmatvec::Mat& dhdqRef, int i=0);
76  virtual void updatedhduRef(fmatvec::SqrMat& dhduRef, int i=0);
77  virtual void updatedhdtRef(fmatvec::Vec& dhdtRef, int i=0);
78  void updaterRef(fmatvec::Vec& ref, int i=0) override;
79 
80  double evalQMec() { if(updQMec) updateQMec(); return QMec; }
81  double evalQMecTrans() { if(updQMec) updateQMec(); return QMecTrans; }
82  double evalQMecRot() { if(updQMec) updateQMec(); return QMecRot; }
83  double getQMec(bool check=true) const { assert((not check) or (not updQMec)); return QMec; }
84  double getQMecTrans(bool check=true) const { assert((not check) or (not updQMec)); return QMecTrans; }
85  double getQMecRot(bool check=true) const { assert((not check) or (not updQMec)); return QMecRot; }
86  virtual void updateQMec();
87 
88  void updateh(int j=0) override;
89  void updater(int j=0);
90  void updategd() override;
91  void updatexd() override;
92  void updatedhdz();
93 
94  void plot() override;
95 
96  void resetUpToDate() override { HNode::resetUpToDate(); updQMec = true; }
97 
98  protected:
99  std::vector<connectedTransFrameStruct> connectedTransFrames;
100  std::vector<connectedRotFrameStruct> connectedRotFrames;
101  double QMecTrans, QMecRot, QMec;
102  double V0;
103  unsigned int nTrans, nRot;
104  bool updQMec;
105  std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVArrows;
106  double openMBVArrowSize;
107 
108  private:
109  std::vector<std::string> saved_translatorial_frameOfReference, saved_rotatorial_frameOfReference, saved_rotatorial_frameOfRotationCenter;
110  std::vector<fmatvec::Vec> saved_translatorial_normal, saved_rotatorial_normal;
111  std::vector<double> saved_translatorial_area, saved_rotatorial_area;
112  std::vector<bool> saved_translatorial_noVolumeChange, saved_rotatorial_noVolumeChange;
113  };
114 
116  class ConstrainedNodeMec : public HNodeMec {
117  public:
118  ConstrainedNodeMec(const std::string &name="") : HNodeMec(name) {}
119  ~ConstrainedNodeMec() override { delete pFun; }
120 
121  void setpFunction(MBSim::Function<double(double)> * pFun_) {
122  pFun=pFun_;
123  pFun->setParent(this);
124  pFun->setName("p");
125  }
126 
127  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
128  void initializeUsingXML(xercesc::DOMElement *element) override;
129 
130  void updateGeneralizedForces() override;
131 
132  bool isSingleValued() const override {return true;}
133 
134  private:
135  MBSim::Function<double(double)> * pFun{nullptr};
136  };
137 
138 
140  class EnvironmentNodeMec : public HNodeMec {
141  public:
142  EnvironmentNodeMec(const std::string &name="") : HNodeMec(name) {}
143 
144  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
145 
146  bool isSingleValued() const override {return true;}
147  };
148 
149 
151  class ElasticNodeMec : public HNodeMec {
152  public:
153  ElasticNodeMec(const std::string &name="") : HNodeMec(name) {}
154  ~ElasticNodeMec() override;
155 
156  void setFracAir(double fracAir_) {fracAir=fracAir_; }
157  void setp0(double p0_) {p0=p0_; }
158 
159  void calcxSize() override {xSize=2; }
160 
161  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
162  void initializeUsingXML(xercesc::DOMElement *element) override;
163 
164  void updateGeneralizedForces() override;
165 
166  void updatexd() override;
167 
168  void plot() override;
169 
170  bool isSingleValued() const override {return true;}
171 
172  private:
173  double E{0};
174  double fracAir{0};
175  double p0{0};
176 
177  OilBulkModulus * bulkModulus{nullptr};
178  };
179 
180 
182  class RigidNodeMec : public HNodeMec {
183  public:
184  RigidNodeMec(const std::string &name="");
185  ~RigidNodeMec() override;
186 
187  bool isSetValued() const override {return true; }
188  bool isActive() const override {return true; }
189 
190  void calclaSize(int j) override {laSize=1; }
191  //void calclaSizeForActiveg() {laSize=0; }
192  void calcrFactorSize(int j) override {rFactorSize=1; }
193 
194  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
195 
196  void updatewbRef(fmatvec::Vec& wbParent) override;
197 
198  void updateGeneralizedForces() override;
199 
200  void updategd() override;
201  void updateW(int j=0) override;
202 
203  void updaterFactors() override;
204  void solveImpactsFixpointSingle() override;
205  void solveConstraintsFixpointSingle() override;
206  void solveImpactsGaussSeidel() override;
207  void solveConstraintsGaussSeidel() override;
208  void solveImpactsRootFinding() override;
209  void solveConstraintsRootFinding() override;
210  void jacobianImpacts() override;
211  void jacobianConstraints() override;
212  void checkImpactsForTermination() override;
213  void checkConstraintsForTermination() override;
214  private:
215  double gdn, gdd;
218  };
219 }
220 
221 #endif /* ----- #ifndef _HYDNODE_MEC_H_ ----- */
222 
Definition: hnode_mec.h:140
Definition: environment.h:95
Definition: hnode_mec.h:53
std::string name
Definition: hnode.h:57
Definition: hnode_mec.h:116
void setName(const std::string &str)
Definition: hnode_mec.h:182
Definition: hnode_mec.h:151