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 #ifdef HAVE_OPENMBVCPPINTERFACE
60  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVArrows, tag, (optional (size,(double),1))) {
61  openMBVArrowSize=(size>.0)?size:.0;
62  }
63 #endif
64 
65  void setInitialVolume(double V0_) {V0=V0_; }
66  unsigned int addTransMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, bool considerVolumeChange=true);
67  unsigned int addRotMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, MBSim::Frame * frameOfReference, bool considerVolumeChange=true);
68  void setTransMecArea(unsigned int i, double area) {connectedTransFrames[i].area=area; }
69 
70  void calcxSize() {xSize=1; }
71 
72  void init(InitStage stage);
73  void initializeUsingXML(xercesc::DOMElement *element);
74 
75  virtual void updateWRef(const fmatvec::Mat& Wref, int i=0);
76  virtual void updateVRef(const fmatvec::Mat& Vref, int i=0);
77  virtual void updatehRef(const fmatvec::Vec& href, int i=0);
78  virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0);
79  virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
80  virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
81  virtual void updaterRef(const fmatvec::Vec& ref, int i=0);
82 
83  void updateh(double t, int j=0);
84  void updatedhdz(double t);
85  virtual void updater(double t, int j=0);
86  void updategd(double t);
87  void updatexd(double t);
88  void updatedx(double t, double dt);
89 
90  void plot(double t, double dt);
91 
92  protected:
93  std::vector<connectedTransFrameStruct> connectedTransFrames;
94  std::vector<connectedRotFrameStruct> connectedRotFrames;
95  double QMecTrans, QMecRot, QMec;
96  double V0;
97  unsigned int nTrans, nRot;
98 #ifdef HAVE_OPENMBVCPPINTERFACE
99  std::vector<boost::shared_ptr<OpenMBV::Arrow> > openMBVArrows;
100  double openMBVArrowSize;
101 #endif
102 
103  private:
104  std::vector<std::string> saved_translatorial_frameOfReference, saved_rotatorial_frameOfReference, saved_rotatorial_frameOfRotationCenter;
105  std::vector<fmatvec::Vec> saved_translatorial_normal, saved_rotatorial_normal;
106  std::vector<double> saved_translatorial_area, saved_rotatorial_area;
107  std::vector<bool> saved_translatorial_noVolumeChange, saved_rotatorial_noVolumeChange;
108  };
109 
111  class ConstrainedNodeMec : public HNodeMec {
112  public:
113  ConstrainedNodeMec(const std::string &name="") : HNodeMec(name), pFun(NULL) {}
114  ~ConstrainedNodeMec() { delete pFun; }
115  virtual std::string getType() const { return "ConstrainedNodeMec"; }
116 
117  void setpFunction(MBSim::Function<double(double)> * pFun_) {
118  pFun=pFun_;
119  pFun->setParent(this);
120  pFun->setName("p");
121  }
122 
123  void init(InitStage stage);
124  void initializeUsingXML(xercesc::DOMElement *element);
125 
126  void updateg(double t);
127 
128  virtual bool isSingleValued() const {return true;}
129 
130  private:
131  MBSim::Function<double(double)> * pFun;
132  };
133 
134 
136  class EnvironmentNodeMec : public HNodeMec {
137  public:
138  EnvironmentNodeMec(const std::string &name="") : HNodeMec(name) {}
139  virtual std::string getType() const { return "EnvironmentNodeMec"; }
140 
141  void init(InitStage stage);
142 
143  virtual bool isSingleValued() const {return true;}
144  };
145 
146 
148  class ElasticNodeMec : public HNodeMec {
149  public:
150  ElasticNodeMec(const std::string &name="") : HNodeMec(name), E(0), fracAir(0), p0(0), bulkModulus(NULL) {}
151  ~ElasticNodeMec();
152  virtual std::string getType() const { return "ElasticNode"; }
153 
154  void setFracAir(double fracAir_) {fracAir=fracAir_; }
155  void setp0(double p0_) {p0=p0_; }
156 
157  void calcxSize() {xSize=2; }
158 
159  void init(InitStage stage);
160  void initializeUsingXML(xercesc::DOMElement *element);
161 
162  void updatexRef(const fmatvec::Vec &xParent);
163 
164  void updatexd(double t);
165  void updatedx(double t, double dt);
166 
167  void plot(double t, double dt);
168 
169  virtual bool isSingleValued() const {return true;}
170 
171 
172  private:
173  double E;
174  double fracAir;
175  double p0;
176 
177  OilBulkModulus * bulkModulus;
178  };
179 
180 
182  class RigidNodeMec : public HNodeMec {
183  public:
184  RigidNodeMec(const std::string &name="");
185  ~RigidNodeMec();
186  virtual std::string getType() const { return "RigidNodeMec"; }
187 
188  bool isSetValued() const {return true; }
189  bool isActive() const {return true; }
190 
191  void calclaSize(int j) {laSize=1; }
192  //void calclaSizeForActiveg() {laSize=0; }
193  void calcrFactorSize(int j) {rFactorSize=1; }
194 
195  void init(InitStage stage);
196 
197  void updatewbRef(const fmatvec::Vec& wbParent);
198 
199  void updategd(double t);
200  void updateW(double t, int j=0);
201 
202  void updaterFactors();
203  void solveImpactsFixpointSingle(double dt);
204  void solveConstraintsFixpointSingle();
205  void solveImpactsGaussSeidel(double dt);
206  void solveConstraintsGaussSeidel();
207  void solveImpactsRootFinding(double dt);
208  void solveConstraintsRootFinding();
209  void jacobianImpacts();
210  void jacobianConstraints();
211  void checkImpactsForTermination(double dt);
212  void checkConstraintsForTermination();
213  private:
214  double gdn, gdd;
217  };
218 }
219 
220 #endif /* ----- #ifndef _HYDNODE_MEC_H_ ----- */
221 
Definition: hnode_mec.h:136
Definition: environment.h:98
Definition: hnode_mec.h:53
Definition: hnode.h:62
Definition: hnode_mec.h:111
Definition: hnode_mec.h:182
Definition: hnode_mec.h:148

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML