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

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML