mbsimhydraulics  4.0.0
MBSim Hydraulics Module
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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, const fmatvec::Vec &fN, double area, bool considerVolumeChange=true);
64  unsigned int addRotMecArea(MBSim::Frame * f, const 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  void calclaSize(int j) override;
69  void calccorrSize(int j) override;
70 
71  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
72  void initializeUsingXML(xercesc::DOMElement *element) override;
73 
74  void updateWRef(fmatvec::Mat& Wref, int i=0) override;
75  void updateVRef(fmatvec::Mat& Vref, int i=0) override;
76  void updatehRef(fmatvec::Vec& href, int i=0) override;
77  virtual void updatedhdqRef(fmatvec::Mat& dhdqRef, int i=0);
78  virtual void updatedhduRef(fmatvec::SqrMat& dhduRef, int i=0);
79  virtual void updatedhdtRef(fmatvec::Vec& dhdtRef, int i=0);
80  void updaterRef(fmatvec::Vec& ref, int i=0) override;
81 
82  double evalQMec() { if(updQMec) updateQMec(); return QMec; }
83  double evalQMecTrans() { if(updQMec) updateQMec(); return QMecTrans; }
84  double evalQMecRot() { if(updQMec) updateQMec(); return QMecRot; }
85  double getQMec(bool check=true) const { assert((not check) or (not updQMec)); return QMec; }
86  double getQMecTrans(bool check=true) const { assert((not check) or (not updQMec)); return QMecTrans; }
87  double getQMecRot(bool check=true) const { assert((not check) or (not updQMec)); return QMecRot; }
88  virtual void updateQMec();
89 
90  void updateh(int j=0) override;
91  void updater(int j=0) override {}
92  void updategd() override;
93  void updatexd() override;
94  void updatedhdz();
95 
96  void plot() override;
97 
98  void resetUpToDate() override { HNode::resetUpToDate(); updQMec = true; }
99 
100  protected:
101  std::vector<connectedTransFrameStruct> connectedTransFrames;
102  std::vector<connectedRotFrameStruct> connectedRotFrames;
103  double QMecTrans, QMecRot, QMec;
104  double V0;
105  unsigned int nTrans, nRot;
106  bool updQMec;
107  std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVArrows;
108  double openMBVArrowSize;
109 
110  private:
111  std::vector<std::string> saved_translatorial_frameOfReference, saved_rotatorial_frameOfReference, saved_rotatorial_frameOfRotationCenter;
112  std::vector<fmatvec::Vec> saved_translatorial_normal, saved_rotatorial_normal;
113  std::vector<double> saved_translatorial_area, saved_rotatorial_area;
114  std::vector<bool> saved_translatorial_noVolumeChange, saved_rotatorial_noVolumeChange;
115  };
116 
118  class ConstrainedNodeMec : public HNodeMec {
119  public:
120  ConstrainedNodeMec(const std::string &name="") : HNodeMec(name) {}
121  ~ConstrainedNodeMec() override { delete pFun; }
122 
123  void setpFunction(MBSim::Function<double(double)> * pFun_) {
124  pFun=pFun_;
125  pFun->setParent(this);
126  pFun->setName("p");
127  }
128 
129  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
130  void initializeUsingXML(xercesc::DOMElement *element) override;
131 
132  void updateGeneralizedForces() override;
133 
134  bool isSingleValued() const override {return true;}
135 
136  private:
137  MBSim::Function<double(double)> * pFun{nullptr};
138  };
139 
140 
142  class EnvironmentNodeMec : public HNodeMec {
143  public:
144  EnvironmentNodeMec(const std::string &name="") : HNodeMec(name) {}
145 
146  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
147 
148  bool isSingleValued() const override {return true;}
149  };
150 
151 
153  class ElasticNodeMec : public HNodeMec {
154  public:
155  ElasticNodeMec(const std::string &name="") : HNodeMec(name) {}
156  ~ElasticNodeMec() override;
157 
158  void setFracAir(double fracAir_) {fracAir=fracAir_; }
159  void setp0(double p0_) {p0=p0_; }
160 
161  void calcxSize() override {xSize=2; }
162 
163  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
164  void initializeUsingXML(xercesc::DOMElement *element) override;
165 
166  void updateGeneralizedForces() override;
167 
168  void updatexd() override;
169 
170  void plot() override;
171 
172  bool isSingleValued() const override {return true;}
173 
174  private:
175  double E{0};
176  double fracAir{0};
177  double p0{0};
178 
179  OilBulkModulus * bulkModulus{nullptr};
180  };
181 
182 
184  class RigidNodeMec : public HNodeMec {
185  public:
186  RigidNodeMec(const std::string &name="");
187  ~RigidNodeMec() override;
188 
189  bool isSetValued() const override {return true; }
190  bool isActive() const override {return true; }
191 
192  void calclaSize(int j) override {laSize=1; }
193  //void calclaSizeForActiveg() {laSize=0; }
194  void calcrFactorSize(int j) override {rFactorSize=1; }
195 
196  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
197 
198  void updatewbRef(fmatvec::Vec& wbParent) override;
199 
200  void updateGeneralizedForces() override;
201 
202  void updategd() override;
203  void updateW(int j=0) override;
204 
205  void updaterFactors() override;
206  void solveImpactsFixpointSingle() override;
207  void solveConstraintsFixpointSingle() override;
208  void solveImpactsGaussSeidel() override;
209  void solveConstraintsGaussSeidel() override;
210  void solveImpactsRootFinding() override;
211  void solveConstraintsRootFinding() override;
212  void jacobianImpacts() override;
213  void jacobianConstraints() override;
214  void checkImpactsForTermination() override;
215  void checkConstraintsForTermination() override;
216  private:
217  double gdn, gdd;
220  };
221 }
222 
223 #endif /* ----- #ifndef _HYDNODE_MEC_H_ ----- */
224 
Definition: hnode_mec.h:142
Definition: environment.h:95
Definition: hnode_mec.h:53
Definition: hnode.h:57
Definition: hnode_mec.h:118
Definition: hnode_mec.h:184
Definition: hnode_mec.h:153