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();
57  virtual std::string getType() const { return "HNodeMec"; }
58 
59  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVArrows, tag, (optional (size,(double),1))) {
60  openMBVArrowSize=(size>.0)?size:.0;
61  }
62 
63  void setInitialVolume(double V0_) {V0=V0_; }
64  unsigned int addTransMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, bool considerVolumeChange=true);
65  unsigned int addRotMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, MBSim::Frame * frameOfReference, bool considerVolumeChange=true);
66  void setTransMecArea(unsigned int i, double area) {connectedTransFrames[i].area=area; }
67 
68  void calcxSize() {xSize=1; }
69 
70  void init(InitStage stage);
71  void initializeUsingXML(xercesc::DOMElement *element);
72 
73  virtual void updateWRef(const fmatvec::Mat& Wref, int i=0);
74  virtual void updateVRef(const fmatvec::Mat& Vref, int i=0);
75  virtual void updatehRef(const fmatvec::Vec& href, int i=0);
76  virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0);
77  virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
78  virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
79  virtual void updaterRef(const fmatvec::Vec& ref, int i=0);
80 
81  double evalQMec() { if(updQMec) updateQMec(); return QMec; }
82  double evalQMecTrans() { if(updQMec) updateQMec(); return QMecTrans; }
83  double evalQMecRot() { if(updQMec) updateQMec(); return QMecRot; }
84  double getQMec(bool check=true) const { assert((not check) or (not updQMec)); return QMec; }
85  double getQMecTrans(bool check=true) const { assert((not check) or (not updQMec)); return QMecTrans; }
86  double getQMecRot(bool check=true) const { assert((not check) or (not updQMec)); return QMecRot; }
87  virtual void updateQMec();
88 
89  void updateh(int j=0);
90  void updater(int j=0);
91  void updategd();
92  void updatexd();
93  void updatedx();
94  void updatedhdz();
95 
96  void plot();
97 
98  void resetUpToDate() { 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), pFun(NULL) {}
121  ~ConstrainedNodeMec() { delete pFun; }
122  virtual std::string getType() const { return "ConstrainedNodeMec"; }
123 
124  void setpFunction(MBSim::Function<double(double)> * pFun_) {
125  pFun=pFun_;
126  pFun->setParent(this);
127  pFun->setName("p");
128  }
129 
130  void init(InitStage stage);
131  void initializeUsingXML(xercesc::DOMElement *element);
132 
133  void updateGeneralizedForces();
134 
135  virtual bool isSingleValued() const {return true;}
136 
137  private:
139  };
140 
141 
143  class EnvironmentNodeMec : public HNodeMec {
144  public:
145  EnvironmentNodeMec(const std::string &name="") : HNodeMec(name) {}
146  virtual std::string getType() const { return "EnvironmentNodeMec"; }
147 
148  void init(InitStage stage);
149 
150  virtual bool isSingleValued() const {return true;}
151  };
152 
153 
155  class ElasticNodeMec : public HNodeMec {
156  public:
157  ElasticNodeMec(const std::string &name="") : HNodeMec(name), E(0), fracAir(0), p0(0), bulkModulus(NULL) {}
158  ~ElasticNodeMec();
159  virtual std::string getType() const { return "ElasticNode"; }
160 
161  void setFracAir(double fracAir_) {fracAir=fracAir_; }
162  void setp0(double p0_) {p0=p0_; }
163 
164  void calcxSize() {xSize=2; }
165 
166  void init(InitStage stage);
167  void initializeUsingXML(xercesc::DOMElement *element);
168 
169  void updateGeneralizedForces();
170 
171  void updatexd();
172  void updatedx();
173 
174  void plot();
175 
176  virtual bool isSingleValued() const {return true;}
177 
178  private:
179  double E;
180  double fracAir;
181  double p0;
182 
183  OilBulkModulus * bulkModulus;
184  };
185 
186 
188  class RigidNodeMec : public HNodeMec {
189  public:
190  RigidNodeMec(const std::string &name="");
191  ~RigidNodeMec();
192  virtual std::string getType() const { return "RigidNodeMec"; }
193 
194  bool isSetValued() const {return true; }
195  bool isActive() const {return true; }
196 
197  void calclaSize(int j) {laSize=1; }
198  //void calclaSizeForActiveg() {laSize=0; }
199  void calcrFactorSize(int j) {rFactorSize=1; }
200 
201  void init(InitStage stage);
202 
203  void updatewbRef(const fmatvec::Vec& wbParent);
204 
205  void updateGeneralizedForces();
206 
207  void updategd();
208  void updateW(int j=0);
209 
210  void updaterFactors();
211  void solveImpactsFixpointSingle();
212  void solveConstraintsFixpointSingle();
213  void solveImpactsGaussSeidel();
214  void solveConstraintsGaussSeidel();
215  void solveImpactsRootFinding();
216  void solveConstraintsRootFinding();
217  void jacobianImpacts();
218  void jacobianConstraints();
219  void checkImpactsForTermination();
220  void checkConstraintsForTermination();
221  private:
222  double gdn, gdd;
225  };
226 }
227 
228 #endif /* ----- #ifndef _HYDNODE_MEC_H_ ----- */
229 
Definition: hnode_mec.h:143
Definition: environment.h:98
Definition: hnode_mec.h:53
Definition: hnode.h:56
Definition: hnode_mec.h:118
Definition: hnode_mec.h:188
Definition: hnode_mec.h:155

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML