All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
hnode.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_H_
21 #define _HNODE_H_
22 
23 #include "mbsim/link.h"
24 #include <mbsim/functions/function.h>
25 
26 #ifdef HAVE_OPENMBVCPPINTERFACE
27 #include <mbsim/utils/boost_parameters.h>
28 #include <mbsim/utils/openmbv_utils.h>
29 namespace OpenMBV {
30  class Group;
31  class Sphere;
32 }
33 #endif
34 
35 namespace MBSim {
36  class GeneralizedForceLaw;
37  class GeneralizedImpactLaw;
38 }
39 
40 namespace MBSimControl {
41  class Signal;
42 }
43 
44 namespace MBSimHydraulics {
45 
46  BOOST_PARAMETER_NAME(size)
47  BOOST_PARAMETER_NAME(minimalPressure)
48  BOOST_PARAMETER_NAME(maximalPressure)
49  BOOST_PARAMETER_NAME(position)
50 
51  class HLine;
52  class HydFluid;
53  class OilBulkModulus;
54 
56  HLine * line;
57  fmatvec::Vec sign;
58  bool inflow;
59  };
60 
62  class HNode : public MBSim::Link {
63  public:
64  HNode(const std::string &name);
65  ~HNode() {};
66  virtual std::string getType() const { return "HNode"; }
67 
68 #ifdef HAVE_OPENMBVCPPINTERFACE
69  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVSphere, tag, (optional (size,(double),1)(minimalPressure,(double),0e5)(maximalPressure,(double),10e5)(position,(const fmatvec::Vec3&),fmatvec::Vec3()))) {
70  enableOpenMBV(size,minimalPressure,maximalPressure,position);
71  }
72  virtual void enableOpenMBV(double size, double pMin, double pMax, const fmatvec::Vec3 &WrON);
73 #endif
74 
75  void addInFlow(HLine * in);
76  void addOutFlow(HLine * out);
77 
78  void calcgdSize(int j) {gdSize=1; }
79 
80  void init(InitStage stage);
81 
82  virtual void updateWRef(const fmatvec::Mat& WRef, int i=0);
83  virtual void updateVRef(const fmatvec::Mat& VRef, int i=0);
84  virtual void updatehRef(const fmatvec::Vec& hRef, int i=0);
85  virtual void updaterRef(const fmatvec::Vec& rRef, int i=0);
86  virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0);
87  virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
88  virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
89 
90  void updateh(double t, int j=0);
91  void updatedhdz(double t);
92  virtual void updater(double t, int j);
93  virtual void updateg(double t) {};
94  virtual void updategd(double t);
95  virtual bool isActive() const {return false; }
96  virtual bool gActiveChanged() {return false; }
97 
98 
99  void plot(double t, double dt);
100 
101  void initializeUsingXML(xercesc::DOMElement *element);
102 
103  protected:
104  std::vector<connectedLinesStruct> connectedLines;
105  std::vector<connectedLinesStruct> connected0DOFLines;
106  std::vector<std::string> refInflowString;
107  std::vector<std::string> refOutflowString;
108  double QHyd;
109  unsigned int nLines;
110 #ifdef HAVE_OPENMBVCPPINTERFACE
111  boost::shared_ptr<OpenMBV::Group> openMBVGrp;
112  boost::shared_ptr<OpenMBV::Sphere> openMBVSphere;
113  fmatvec::Vec3 WrON;
114 #endif
115  };
116 
117 
119  class ConstrainedNode : public HNode {
120  public:
121  ConstrainedNode(const std::string &name="") : HNode(name), pFun(NULL) {}
122  ~ConstrainedNode() { delete pFun; }
123  virtual std::string getType() const { return "ConstrainedNode"; }
124 
125  void setpFunction(MBSim::Function<double(double)> * pFun_) {
126  pFun=pFun_;
127  pFun->setParent(this);
128  pFun->setName("p");
129  }
130 
131  void updateg(double t);
132  void init(InitStage stage);
133  void initializeUsingXML(xercesc::DOMElement *element);
134  virtual bool isSingleValued() const {return true;}
135 
136  private:
137  MBSim::Function<double(double)> * pFun;
138  };
139 
140 
142  class EnvironmentNode : public HNode {
143  public:
144  EnvironmentNode(const std::string &name="") : HNode(name) {}
145  virtual std::string getType() const { return "EnvironmentNode"; }
146 
147  void init(InitStage stage);
148 
149  virtual bool isSingleValued() const {return true;}
150  };
151 
152 
154  class ElasticNode : public HNode {
155  public:
156  ElasticNode(const std::string &name="") : HNode(name), V(0), E(0), fracAir(0), p0(0), bulkModulus(NULL) {}
157  ~ElasticNode();
158  virtual std::string getType() const { return "ElasticNode"; }
159 
160  void setVolume(double V_) {V=V_; }
161  void setFracAir(double fracAir_) {fracAir=fracAir_; }
162  void setp0(double p0_) {p0=p0_; }
163 
164  void calcxSize() {xSize=1; }
165 
166  void init(InitStage stage);
167  void initializeUsingXML(xercesc::DOMElement *element);
168 
169  void updatexRef(const fmatvec::Vec &xParent);
170 
171  void updatexd(double t);
172  void updatedx(double t, double dt);
173 
174  void plot(double t, double dt);
175 
176  virtual bool isSingleValued() const {return true;}
177 
178  private:
179  double V, E;
180  double fracAir;
181  double p0;
182  OilBulkModulus * bulkModulus;
183  };
184 
185 
187  class RigidNode : public HNode {
188  public:
189  RigidNode(const std::string &name="");
190  ~RigidNode();
191  virtual std::string getType() const { return "RigidNode"; }
192 
193  bool isSetValued() const {return true; }
194  virtual bool isActive() const {return true; }
195 
196  void calclaSize(int j) {laSize=1; }
197  //void calclaSizeForActiveg() {laSize=0; }
198  void calcrFactorSize(int j) {rFactorSize=1; }
199 
200  void updategd(double t);
201  void updateW(double t, int j=0);
202 
203  void updaterFactors();
204  void solveImpactsFixpointSingle(double dt);
205  void solveConstraintsFixpointSingle();
206  void solveImpactsGaussSeidel(double dt);
207  void solveConstraintsGaussSeidel();
208  void solveImpactsRootFinding(double dt);
209  void solveConstraintsRootFinding();
210  void jacobianImpacts();
211  void jacobianConstraints();
212  void checkImpactsForTermination(double dt);
213  void checkConstraintsForTermination();
214  private:
215  double gdn, gdd;
218  };
219 
220 
222  class RigidCavitationNode : public HNode {
223  public:
224  RigidCavitationNode(const std::string &name="");
226  virtual std::string getType() const { return "RigidCavitationNode"; }
227 
228  void setCavitationPressure(double pCav_) {pCav=pCav_; }
229 
230  bool isSetValued() const {return true; }
231  bool hasSmoothPart() const {return true; }
232  virtual bool isActive() const {return active; }
233 
234  void calcxSize() {xSize=1; }
235  void calcgSize(int j) {gSize=1; }
236  //void calcgSizeActive() {gSize=0; }
237  void calclaSize(int j) {laSize=1; }
238  //void calclaSizeForActiveg() {laSize=0; }
239  void calcrFactorSize(int j) {rFactorSize=1; }
240  void calcsvSize() {svSize=1; }
241 
242  void init(InitStage stage);
243  void initializeUsingXML(xercesc::DOMElement *element);
244  void plot(double t, double dt);
245 
246  void checkActive(int j);
247  //void checkActivegdn();
248  bool gActiveChanged();
249 
250  void updateg(double t);
251  void updateh(double t, int j=0);
252  void updateStopVector(double t);
253  void updateW(double t, int j=0);
254  void updatexd(double t);
255  void updatedx(double t, double dt);
256  void checkRoot();
257 
258  void updaterFactors();
259  void solveImpactsFixpointSingle(double dt);
260  void solveConstraintsFixpointSingle();
261  void solveImpactsGaussSeidel(double dt);
262  void solveConstraintsGaussSeidel();
263  void solveImpactsRootFinding(double dt);
264  void solveConstraintsRootFinding();
265  void jacobianImpacts();
266  void jacobianConstraints();
267  void checkImpactsForTermination(double dt);
268  void checkConstraintsForTermination();
269  protected:
270  double pCav;
271  private:
272  bool active, active0;
273  double gdn, gdd;
276  };
277 
278 
280  class PressurePump : public HNode {
281  public:
282  PressurePump(const std::string &name="") : HNode(name), pSignal(NULL), pSignalString("") {}
283  virtual std::string getType() const { return "PressurePump"; }
284 
285  void setpSignal(MBSimControl::Signal * pSignal_) {pSignal=pSignal_; }
286 
287  void updateg(double t);
288  void init(InitStage stage);
289  void initializeUsingXML(xercesc::DOMElement *element);
290 
291  private:
292  MBSimControl::Signal * pSignal;
293  std::string pSignalString;
294  };
295 
296 }
297 
298 #endif /* ----- #ifndef _HYDNODE_H_ ----- */
299 
Definition: hnode.h:142
Definition: hnode.h:187
Definition: hnode.h:119
Definition: hline.h:41
Definition: environment.h:98
Definition: hnode.h:62
Definition: hnode.h:280
Definition: hnode.h:154

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML