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 
60  void calcSize() override;
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) override {gdSize=1; }
71 
72  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
73 
74  void updateWRef(const fmatvec::Mat& WRef, int i=0) override;
75  void updateVRef(const fmatvec::Mat& VRef, int i=0) override;
76  void updatehRef(const fmatvec::Vec& hRef, int i=0) override;
77  void updaterRef(const fmatvec::Vec& rRef, int i=0) override;
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) override;
87  void updatedhdz();
88  void updategd() override;
89  bool isActive() const override {return false; }
90  bool gActiveChanged() override {return false; }
91 
92  void plot() override;
93 
94  void initializeUsingXML(xercesc::DOMElement *element) override;
95 
96  void resetUpToDate() override { 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) {}
116  ~ConstrainedNode() override { delete pFun; }
117 
118  void setpFunction(MBSim::Function<double(double)> * pFun_) {
119  pFun=pFun_;
120  pFun->setParent(this);
121  pFun->setName("p");
122  }
123 
124  void updateGeneralizedForces() override;
125  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
126  void initializeUsingXML(xercesc::DOMElement *element) override;
127  bool isSingleValued() const override {return true;}
128 
129  private:
130  MBSim::Function<double(double)> * pFun{nullptr};
131  };
132 
133 
135  class EnvironmentNode : public HNode {
136  public:
137  EnvironmentNode(const std::string &name="") : HNode(name) {}
138 
139  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
140 
141  bool isSingleValued() const override {return true;}
142  };
143 
144 
146  class ElasticNode : public HNode {
147  public:
148  ElasticNode(const std::string &name="") : HNode(name) {}
149  ~ElasticNode() override;
150 
151  void setVolume(double V_) {V=V_; }
152  void setFracAir(double fracAir_) {fracAir=fracAir_; }
153  void setp0(double p0_) {p0=p0_; }
154 
155  void calcxSize() override {xSize=1; }
156 
157  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
158  void initializeUsingXML(xercesc::DOMElement *element) override;
159 
160  void updateGeneralizedForces() override;
161 
162  void updatexd() override;
163 
164  void plot() override;
165 
166  bool isSingleValued() const override {return true;}
167 
168  private:
169  double V{0};
170  double fracAir{0};
171  double p0{0};
172  OilBulkModulus * bulkModulus{nullptr};
173  };
174 
175 
177  class RigidNode : public HNode {
178  public:
179  RigidNode(const std::string &name="");
180  ~RigidNode() override;
181 
182  bool isSetValued() const override {return true; }
183  bool isActive() const override {return true; }
184 
185  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
186 
187  void calclaSize(int j) override {laSize=1; }
188  //void calclaSizeForActiveg() {laSize=0; }
189  void calcrFactorSize(int j) override {rFactorSize=1; }
190 
191  void updateGeneralizedForces() override;
192 
193  void updategd() override;
194  void updateW(int j=0) override;
195 
196  void updaterFactors() override;
197  void solveImpactsFixpointSingle() override;
198  void solveConstraintsFixpointSingle() override;
199  void solveImpactsGaussSeidel() override;
200  void solveConstraintsGaussSeidel() override;
201  void solveImpactsRootFinding() override;
202  void solveConstraintsRootFinding() override;
203  void jacobianImpacts() override;
204  void jacobianConstraints() override;
205  void checkImpactsForTermination() override;
206  void checkConstraintsForTermination() override;
207  const double& evalgdn();
208  const double& evalgdd();
209  private:
210  double gdn, gdd;
213  };
214 
215 
217  class RigidCavitationNode : public HNode {
218  public:
219  RigidCavitationNode(const std::string &name="");
220  ~RigidCavitationNode() override;
221 
222  void setCavitationPressure(double pCav_) {pCav=pCav_; }
223 
224  bool isSetValued() const override {return true; }
225  bool isSingleValued() const override {return true; }
226  bool isActive() const override {return active; }
227 
228  void calcxSize() override {xSize=1; }
229  void calcgSize(int j) override {gSize=1; }
230  //void calcgSizeActive() {gSize=0; }
231  void calclaSize(int j) override {laSize=1; }
232  //void calclaSizeForActiveg() {laSize=0; }
233  void calcrFactorSize(int j) override {rFactorSize=1; }
234  void calcsvSize() override {svSize=1; }
235 
236  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
237  void initializeUsingXML(xercesc::DOMElement *element) override;
238  void plot() override;
239 
240  void checkActive(int j) override;
241  //void checkActivegdn();
242  bool gActiveChanged() override;
243 
244  void updateGeneralizedForces() override;
245  void updateg() override;
246  void updateW(int j=0) override;
247  void updatexd() override;
248  void updateStopVector() override;
249  void checkRoot() override;
250 
251  void updaterFactors() override;
252  void solveImpactsFixpointSingle() override;
253  void solveConstraintsFixpointSingle() override;
254  void solveImpactsGaussSeidel() override;
255  void solveConstraintsGaussSeidel() override;
256  void solveImpactsRootFinding() override;
257  void solveConstraintsRootFinding() override;
258  void jacobianImpacts() override;
259  void jacobianConstraints() override;
260  void checkImpactsForTermination() override;
261  void checkConstraintsForTermination() override;
262  const double& evalgdn();
263  const double& evalgdd();
264 
265  protected:
266  double pCav;
267  private:
268  bool active, active0;
269  double gdn, gdd;
272  };
273 
274 
276  class PressurePump : public HNode {
277  public:
278  PressurePump(const std::string &name="") : HNode(name) { }
279 
280  void setpFunction(MBSim::Function<double(double)> *pFunction_) { pFunction=pFunction_; }
281 
282  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
283 
284  void updateGeneralizedForces() override;
285  void initializeUsingXML(xercesc::DOMElement *element) override;
286 
287  private:
288  MBSim::Function<double(double)> *pFunction{nullptr};
289  };
290 
291 }
292 
293 #endif /* ----- #ifndef _HYDNODE_H_ ----- */
294 
Definition: hnode.h:135
Definition: hnode.h:177
Definition: hnode.h:113
Definition: hline.h:39
Definition: environment.h:97
Definition: hnode.h:56
Definition: hnode.h:276
Definition: hnode.h:146

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Home