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 
45  //class Link : public Element, public LinkInterface, public ExtraDynamicInterface {
46  class Link : public Element {
47  public:
52  Link(const std::string &name);
53 
57  virtual ~Link() { }
58 
59  /* INHERITED INTERFACE OF LINKINTERFACE */
60  virtual void updateg() { }
61  virtual void updategd() { }
62  virtual void updatewb() { }
63  virtual void updateW(int i=0) { }
64  virtual void updateV(int i=0) { }
65  virtual void updateh(int i=0) { }
66  virtual void updateStopVector() { }
67  virtual void updateLinkStatus() { }
68  virtual void updateLinkStatusReg() { }
69  virtual void updateJacobians(int j=0) { }
70  virtual void updateb() { }
71  /***************************************************/
72 
73  /* INHERITED INTERFACE OF EXTRADYNAMICINTERFACE */
74  virtual void updatedx() { }
75  virtual void updatexd() { }
76  virtual void calcxSize() { xSize = 0; }
77  virtual const fmatvec::Vec& getx() const { return x; }
78  virtual fmatvec::Vec& getx() { return x; }
79  virtual void setxInd(int xInd_) { xInd = xInd_; };
80  virtual int getxSize() const { return xSize; }
81  virtual void updatexRef(const fmatvec::Vec& ref);
82  virtual void updatexdRef(const fmatvec::Vec& ref);
83  virtual void updatedxRef(const fmatvec::Vec& ref);
84  virtual void updatebRef(const fmatvec::Mat &hRef);
85  virtual void init(InitStage stage);
86  virtual void initz();
87  virtual void writez(H5::GroupBase *group);
88  virtual void readz0(H5::GroupBase *group);
89  /***************************************************/
90 
91  virtual void setbInd(int bInd_) { bInd = bInd_; };
92 
93  /* INHERITED INTERFACE OF ELEMENT */
94  std::string getType() const { return "Link"; }
95  virtual void plot();
96  virtual void closePlot();
97  /***************************************************/
98 
99  /* INTERFACE TO BE DEFINED IN DERIVED CLASS */
103  virtual void updateWRef(const fmatvec::Mat& ref, int i=0) = 0;
104 
108  virtual void updateVRef(const fmatvec::Mat& ref, int i=0) = 0;
109 
113  virtual void updatehRef(const fmatvec::Vec &hRef, int i=0) = 0;
114 
118  virtual void updaterRef(const fmatvec::Vec &ref, int i=0) = 0;
119 
123  virtual void updatewbRef(const fmatvec::Vec &ref);
124 
128  virtual void updatelaRef(const fmatvec::Vec& ref);
129 
133  virtual void updateLaRef(const fmatvec::Vec& ref);
134 
138  virtual void deletelaRef();
139 
143  virtual void updategRef(const fmatvec::Vec& ref);
144 
148  virtual void updategdRef(const fmatvec::Vec& ref);
149 
153  virtual void updateresRef(const fmatvec::Vec& ref);
154 
158  virtual void updaterFactorRef(const fmatvec::Vec& ref);
159 
163  virtual void updatesvRef(const fmatvec::Vec &sv);
164 
168  virtual void updatejsvRef(const fmatvec::VecInt &jsvParent);
169 
173  virtual void updateLinkStatusRef(const fmatvec::VecInt &LinkStatusParent);
174 
178  virtual void updateLinkStatusRegRef(const fmatvec::VecInt &LinkStatusRegParent);
179 
183  virtual void calclaSize(int j) { laSize = 0; }
184 
188  virtual void calcgSize(int j) { gSize = 0; }
189 
196  virtual void calcgdSize(int j) { gdSize = 0; }
197 
201  virtual void calcrFactorSize(int j) { rFactorSize = 0; }
202 
206  virtual void calcbSize() { bSize = 0; }
207 
211  virtual void calcsvSize() { svSize = 0; }
212 
216  virtual void calcLinkStatusSize() { LinkStatusSize =0;}
217 
222 
228  virtual bool isSetValued() const { return false; }
229 
235  virtual bool isSingleValued() const { return false; }
236 
242  virtual bool hasSmoothPart() const { return false; }
243 
247  virtual bool isActive() const = 0;
248 
252  virtual bool gActiveChanged() = 0;
253 
257  virtual bool detectImpact() { return false; }
258 
263  virtual void solveImpactsFixpointSingle() { THROW_MBSIMERROR("(Link::solveImpactsFixpointSingle): Not implemented."); }
264 
268  virtual void solveConstraintsFixpointSingle() { THROW_MBSIMERROR("(Link::solveConstraintsFixpointSingle): Not implemented."); }
269 
274  virtual void solveImpactsGaussSeidel() { THROW_MBSIMERROR("(Link::solveImpactsGaussSeidel): Not implemented."); }
275 
279  virtual void solveConstraintsGaussSeidel() { THROW_MBSIMERROR("(Link::solveConstraintsGaussSeidel): Not implemented."); }
280 
285  virtual void solveImpactsRootFinding() { THROW_MBSIMERROR("(Link::solveImpactsRootFinding): Not implemented."); }
286 
290  virtual void solveConstraintsRootFinding() { THROW_MBSIMERROR("(Link::solveConstraintsRootFinding): Not implemented."); }
291 
295  virtual void jacobianConstraints() { THROW_MBSIMERROR("(Link::jacobianConstraints): Not implemented."); }
296 
300  virtual void jacobianImpacts() { THROW_MBSIMERROR("(Link::jacobianImpacts): Not implemented."); }
301 
305  virtual void updaterFactors() { THROW_MBSIMERROR("(Link::updaterFactors): Not implemented."); }
306 
310  virtual void checkImpactsForTermination() { THROW_MBSIMERROR("(Link::checkImpactsForTermination): Not implemented."); }
311 
315  virtual void checkConstraintsForTermination() { THROW_MBSIMERROR("(Link::checkConstraintsForTermination): Not implemented."); }
316 
323  virtual void checkActive(int j) { }
324 
328  virtual double evalPotentialEnergy() { return 0; }
329 
330  virtual void setlaTol(double tol) { laTol = tol; }
331  virtual void setLaTol(double tol) { LaTol = tol; }
332  virtual void setgTol(double tol) { gTol = tol; }
333  virtual void setgdTol(double tol) { gdTol = tol; }
334  virtual void setgddTol(double tol) { gddTol = tol; }
335  virtual void setrMax(double rMax_) { rMax = rMax_; }
336  virtual void setLinkStatusInd(int LinkStatusInd_) { LinkStatusInd = LinkStatusInd_; };
337  virtual void setLinkStatusRegInd(int LinkStatusRegInd_) { LinkStatusRegInd = LinkStatusRegInd_; };
338  virtual void setlaInd(int laInd_) { laInd = laInd_;Ila=fmatvec::RangeV(laInd,laInd+laSize-1); }
339  virtual void setgInd(int gInd_) { gInd = gInd_; Ig=fmatvec::RangeV(gInd,gInd+gSize-1); }
340  virtual void setgdInd(int gdInd_) { gdInd = gdInd_; }
341  virtual void setrFactorInd(int rFactorInd_) { rFactorInd = rFactorInd_; }
350  virtual void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_,fmatvec::Vec &gdInActive_,int *IndInActive_,fmatvec::Vec &gAct_,int *IndActive_) { }
351 
355  virtual void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) { }
356  virtual void updatecorr(int j) { corr.init(0); }
357  virtual void updatecorrRef(const fmatvec::Vec &ref);
358  virtual void calccorrSize(int j) { corrSize = 0; }
359  virtual void setcorrInd(int corrInd_) { corrInd = corrInd_; }
360  virtual void checkRoot() { }
361  /***************************************************/
362 
363  void setx(const fmatvec::Vec &x_) { x = x_; }
364 
365  virtual void setsvInd(int svInd_) { svInd = svInd_; };
366  int getsvSize() const { return svSize; }
367 
368  int getLinkStatusSize() const { return LinkStatusSize; }
369 
370  int getLinkStatusRegSize() const { return LinkStatusRegSize; }
371 
372  const fmatvec::Vec& getla(bool check=true) const;
373  const fmatvec::Vec& getLa(bool check=true) const;
374  fmatvec::Vec& getla(bool check=true);
375  fmatvec::Vec& getLa(bool check=true);
376 
377  int getlaInd() const { return laInd; }
378  int getlaSize() const { return laSize; }
379  int getbSize() const { return bSize; }
380 
381  const fmatvec::Vec& evalg();
382  const fmatvec::Vec& evalgd();
383  const fmatvec::Vec& evalla();
384  const fmatvec::Vec& evalLa();
385  const fmatvec::Vec& evalwb();
386  const fmatvec::Vec& evalxd();
387 
388  int getgdInd() const { return gdInd; }
389  int getgSize() const { return gSize; }
390  int getgdSize() const { return gdSize; }
391 
392  int getrFactorSize() const { return rFactorSize; }
393 
394  const fmatvec::VecInt& getrFactorUnsure() const { return rFactorUnsure; }
395 
396  void resetUpToDate() { updrrel = true; updvrel = true; updla = true; }
397 
398  virtual void updateGeneralizedPositions() { }
399  virtual void updateGeneralizedVelocities() { }
400  virtual void updateGeneralizedForces() { }
401 
402  const fmatvec::VecV& evalGeneralizedRelativePosition() { if(updrrel) updateGeneralizedPositions(); return rrel; }
403  const fmatvec::VecV& evalGeneralizedRelativeVelocity() { if(updvrel) updateGeneralizedVelocities(); return vrel; }
404  const fmatvec::VecV& evalGeneralizedForce() { if(updla) updateGeneralizedForces(); return lambda; }
405 
406  fmatvec::VecV& getGeneralizedForce(bool check=true) { assert((not check) or (not updla)); return lambda; }
407 
411  void savela();
412 
416  void saveLa();
417 
421  void initla();
422 
426  void initLa();
427 
431  void decreaserFactors();
432 
433 
434  int getcorrSize() const { return corrSize; }
435 
436  protected:
441 
446 
447  fmatvec::Vec dx;
448 
453 
457  int xSize, xInd;
458 
463 
467  fmatvec::VecInt jsv;
468 
472  int svSize, svInd;
473 
478  fmatvec::VecInt LinkStatus;
479 
483  int LinkStatusSize, LinkStatusInd;
484 
489  fmatvec::VecInt LinkStatusReg;
490 
494  int LinkStatusRegSize, LinkStatusRegInd;
495 
499  fmatvec::Vec g, gd, la, La;
500 
505 
509  int gSize, gInd;
510 
514  int gdSize, gdInd;
515 
519  int laSize, laInd;
520 
524  int bSize, bInd;
525 
529  fmatvec::RangeV Ig, Ila;
530 
534  double gTol, gdTol, gddTol, laTol, LaTol;
535 
540 
545 
549  fmatvec::VecInt rFactorUnsure;
550 
554  int rFactorSize, rFactorInd;
555 
559  double rMax;
560 
565 
569  std::vector<fmatvec::Mat> W[2];
570 
574  std::vector<fmatvec::Mat> V[2];
575 
579  std::vector<fmatvec::Vec> h[2];
580 
584  std::vector<fmatvec::Mat> dhdq;
585  std::vector<fmatvec::Mat> dhdu;
586  std::vector<fmatvec::Vec> dhdt;
587 
591  std::vector<fmatvec::Vec> r[2];
592 
597 
602 
603  int corrSize, corrInd;
604  fmatvec::Vec corr;
605 
606  fmatvec::VecV rrel, vrel, lambda;
607 
608  bool updrrel, updvrel, updla;
609  };
610 }
611 
612 #endif /* _LINK_H_ */
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:298

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML