All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
link.h
1 /* Copyright (C) 2004-2014 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: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef _LINK_H_
21 #define _LINK_H_
22 
23 #include "mbsim/element.h"
24 #include "mbsim/mbsim_event.h"
25 
26 namespace H5 {
27  class Group;
28 }
29 
30 namespace MBSim {
31 
32  class Frame;
33  class Object;
34  class Contour;
35  class DynamicSystem;
36 
50  //class Link : public Element, public LinkInterface, public ExtraDynamicInterface {
51  class Link : public Element {
52  public:
57  Link(const std::string &name);
58 
62  virtual ~Link() {}
63 
64  /* INHERITED INTERFACE OF LINKINTERFACE */
65  virtual void updateg(double t) = 0;
66  virtual void updategd(double t) = 0;
67  virtual void updatewb(double t, int i=0) {};
68  virtual void updateW(double t, int i=0) {};
69  virtual void updateV(double t, int i=0) {};
70  virtual void updateh(double t, int i=0) {};
71  virtual void updateStopVector(double t) {}
72  virtual void updateLinkStatus(double t) {}
73  virtual void updateLinkStatusReg(double t) {}
74  virtual void updateJacobians(double t, int j=0) {}
75  virtual void updateb(double t) {};
76  /***************************************************/
77 
78  /* INHERITED INTERFACE OF EXTRADYNAMICINTERFACE */
79  virtual void updatedx(double t, double dt) {}
80  virtual void updatexd(double t) {}
81  virtual void calcxSize() { xSize = 0; }
82  virtual const fmatvec::Vec& getx() const { return x; }
83  virtual fmatvec::Vec& getx() { return x; }
84  virtual void setxInd(int xInd_) { xInd = xInd_; };
85  virtual int getxSize() const { return xSize; }
86  virtual void updatexRef(const fmatvec::Vec& ref);
87  virtual void updatexdRef(const fmatvec::Vec& ref);
88  virtual void updatebRef(const fmatvec::Mat &hRef);
89  virtual void init(InitStage stage);
90  virtual void initz();
91  virtual void writez(H5::GroupBase *group);
92  virtual void readz0(H5::GroupBase *group);
93  /***************************************************/
94 
95  virtual void setbInd(int bInd_) { bInd = bInd_; };
96 
97  /* INHERITED INTERFACE OF ELEMENT */
98  std::string getType() const { return "Link"; }
99  virtual void plot(double t, double dt = 1);
100  virtual void closePlot();
101  /***************************************************/
102 
103  /* INTERFACE TO BE DEFINED IN DERIVED CLASS */
107  virtual void updateWRef(const fmatvec::Mat& ref, int i=0) = 0;
108 
112  virtual void updateVRef(const fmatvec::Mat& ref, int i=0) = 0;
113 
117  virtual void updatehRef(const fmatvec::Vec &hRef, int i=0) = 0;
118 
122  virtual void updaterRef(const fmatvec::Vec &ref, int i=0) = 0;
123 
127  virtual void updatewbRef(const fmatvec::Vec &ref);
128 
132  virtual void updatelaRef(const fmatvec::Vec& ref);
133 
137  virtual void deletelaRef();
138 
142  virtual void updategRef(const fmatvec::Vec& ref);
143 
147  virtual void updategdRef(const fmatvec::Vec& ref);
148 
152  virtual void updateresRef(const fmatvec::Vec& ref);
153 
157  virtual void updaterFactorRef(const fmatvec::Vec& ref);
158 
162  virtual void updatesvRef(const fmatvec::Vec &sv);
163 
167  virtual void updatejsvRef(const fmatvec::VecInt &jsvParent);
168 
172  virtual void updateLinkStatusRef(const fmatvec::VecInt &LinkStatusParent);
173 
177  virtual void updateLinkStatusRegRef(const fmatvec::VecInt &LinkStatusRegParent);
178 
182  virtual void calclaSize(int j) { laSize = 0; }
183 
187  virtual void calcgSize(int j) { gSize = 0; }
188 
195  virtual void calcgdSize(int j) { gdSize = 0; }
196 
200  virtual void calcrFactorSize(int j) { rFactorSize = 0; }
201 
205  virtual void calcbSize() { bSize = 0; }
206 
210  virtual void calcsvSize() { svSize = 0; }
211 
215  virtual void calcLinkStatusSize() { LinkStatusSize =0;}
216 
221 
227  virtual bool isSetValued() const { return false; }
228 
234  virtual bool isSingleValued() const { return false; }
235 
241  virtual bool hasSmoothPart() const { return false; }
242 
246  virtual bool isActive() const = 0;
247 
251  virtual bool gActiveChanged() = 0;
252 
256  virtual bool detectImpact() { return false; }
257 
262  virtual void solveImpactsFixpointSingle(double dt) { THROW_MBSIMERROR("(Link::solveImpactsFixpointSingle): Not implemented."); }
263 
267  virtual void solveConstraintsFixpointSingle() { THROW_MBSIMERROR("(Link::solveConstraintsFixpointSingle): Not implemented."); }
268 
273  virtual void solveImpactsGaussSeidel(double dt) { THROW_MBSIMERROR("(Link::solveImpactsGaussSeidel): Not implemented."); }
274 
278  virtual void solveConstraintsGaussSeidel() { THROW_MBSIMERROR("(Link::solveConstraintsGaussSeidel): Not implemented."); }
279 
284  virtual void solveImpactsRootFinding(double dt) { THROW_MBSIMERROR("(Link::solveImpactsRootFinding): Not implemented."); }
285 
289  virtual void solveConstraintsRootFinding() { THROW_MBSIMERROR("(Link::solveConstraintsRootFinding): Not implemented."); }
290 
294  virtual void jacobianConstraints() { THROW_MBSIMERROR("(Link::jacobianConstraints): Not implemented."); }
295 
299  virtual void jacobianImpacts() { THROW_MBSIMERROR("(Link::jacobianImpacts): Not implemented."); }
300 
304  virtual void updaterFactors() { THROW_MBSIMERROR("(Link::updaterFactors): Not implemented."); }
305 
309  virtual void checkImpactsForTermination(double dt) { THROW_MBSIMERROR("(Link::checkImpactsForTermination): Not implemented."); }
310 
314  virtual void checkConstraintsForTermination() { THROW_MBSIMERROR("(Link::checkConstraintsForTermination): Not implemented."); }
315 
322  virtual void checkActive(int j) {}
323 
327  virtual double computePotentialEnergy() { return 0; }
328 
329  virtual void setlaTol(double tol) { laTol = tol; }
330  virtual void setLaTol(double tol) { LaTol = tol; }
331  virtual void setgTol(double tol) { gTol = tol; }
332  virtual void setgdTol(double tol) { gdTol = tol; }
333  virtual void setgddTol(double tol) { gddTol = tol; }
334  virtual void setrMax(double rMax_) { rMax = rMax_; }
335  virtual void setLinkStatusInd(int LinkStatusInd_) { LinkStatusInd = LinkStatusInd_; };
336  virtual void setLinkStatusRegInd(int LinkStatusRegInd_) { LinkStatusRegInd = LinkStatusRegInd_; };
337  virtual void setlaInd(int laInd_) { laInd = laInd_;Ila=fmatvec::Index(laInd,laInd+laSize-1); }
338  virtual void setgInd(int gInd_) { gInd = gInd_; Ig=fmatvec::Index(gInd,gInd+gSize-1); }
339  virtual void setgdInd(int gdInd_) { gdInd = gdInd_; }
340  virtual void setrFactorInd(int rFactorInd_) { rFactorInd = rFactorInd_; }
349  virtual void LinearImpactEstimation(fmatvec::Vec &gInActive_,fmatvec::Vec &gdInActive_,int *IndInActive_,fmatvec::Vec &gAct_,int *IndActive_){};
350 
354  virtual void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) {};
355  virtual void updatecorr(int j) { corr.init(0); }
356  virtual void updatecorrRef(const fmatvec::Vec &ref);
357  virtual void calccorrSize(int j) { corrSize = 0; }
358  virtual void setcorrInd(int corrInd_) { corrInd = corrInd_; }
359  virtual void checkRoot() {};
360  /***************************************************/
361 
362  /* GETTER / SETTER */
363  const std::vector<fmatvec::Mat>& getW(int i=0) const { return W[i]; }
364  const std::vector<fmatvec::Mat>& getV(int i=0) const { return V[i]; }
365  const std::vector<fmatvec::Vec>& geth(int i=0) const { return h[i]; }
366 
367  void setx(const fmatvec::Vec &x_) { x = x_; }
368  const fmatvec::Vec& getxd() const { return xd; }
369 
370  virtual void setsvInd(int svInd_) { svInd = svInd_; };
371  int getsvSize() const { return svSize; }
372 
373  int getLinkStatusSize() const { return LinkStatusSize; }
374 
375  int getLinkStatusRegSize() const { return LinkStatusRegSize; }
376 
377  const fmatvec::Vec& getla() const { return la; }
378  fmatvec::Vec& getla() { return la; }
379  int getlaInd() const { return laInd; }
380  int getlaSize() const { return laSize; }
381  int getbSize() const { return bSize; }
382  const fmatvec::Index& getlaIndex() const { return Ila; }
383 
384  const fmatvec::Vec& getg() const { return g; }
385  fmatvec::Vec& getg() { return g; }
386  const fmatvec::Vec& getgd() const { return gd; }
387  fmatvec::Vec& getgd() { return gd; }
388  const fmatvec::Vec& getwb() const { return wb; }
389  fmatvec::Vec& getwb() { return wb; }
390  int getgdInd() const { return gdInd; }
391  int getgSize() const { return gSize; }
392  int getgdSize() const { return gdSize; }
393  const fmatvec::Index& getgIndex() const { return Ig; }
394 
395  int getrFactorSize() const { return rFactorSize; }
396 
397  const fmatvec::VecInt& getrFactorUnsure() const { return rFactorUnsure; }
398 
402  void savela(double dt=1.0);
403 
407  void initla(double dt=1.0);
408 
412  void decreaserFactors();
413 
414 
415  int getcorrSize() const { return corrSize; }
416 
417  protected:
422 
427 
432 
436  int xSize, xInd;
437 
442 
446  fmatvec::VecInt jsv;
447 
451  int svSize, svInd;
452 
457  fmatvec::VecInt LinkStatus;
458 
462  int LinkStatusSize, LinkStatusInd;
463 
468  fmatvec::VecInt LinkStatusReg;
469 
473  int LinkStatusRegSize, LinkStatusRegInd;
474 
478  fmatvec::Vec g, gd, la;
479 
484 
488  int gSize, gInd;
489 
493  int gdSize, gdInd;
494 
498  int laSize, laInd;
499 
503  int bSize, bInd;
504 
509 
513  double gTol, gdTol, gddTol, laTol, LaTol;
514 
519 
524 
528  fmatvec::VecInt rFactorUnsure;
529 
533  int rFactorSize, rFactorInd;
534 
538  double rMax;
539 
544 
548  std::vector<fmatvec::Mat> W[2];
549 
553  std::vector<fmatvec::Mat> V[2];
554 
558  std::vector<fmatvec::Vec> h[2];
559 
563  std::vector<fmatvec::Mat> dhdq;
564  std::vector<fmatvec::Mat> dhdu;
565  std::vector<fmatvec::Vec> dhdt;
566 
570  std::vector<fmatvec::Vec> r[2];
571 
576 
581 
582  int corrSize, corrInd;
583  fmatvec::Vec corr;
584  };
585 }
586 
587 #endif /* _LINK_H_ */
588 
basic class of MBSim mainly for plotting
Definition: element.h:58
InitStage
The stages of the initialization.
Definition: element.h:97
std::string name
name of element
Definition: element.h:290

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML