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  extern const PlotFeatureEnum generalizedRelativePosition, generalizedRelativeVelocity, generalizedForce;
33 
47  //class Link : public Element, public LinkInterface, public ExtraDynamicInterface {
48  class Link : public Element {
49  public:
54  Link(const std::string &name);
55 
56  virtual void calcSize() { }
57  int getGeneralizedRelativePositionSize() { if(updSize) calcSize(); return ng; }
58  int getGeneralizedRelativeVelocitySize() { if(updSize) calcSize(); return ngd; }
59  int getGeneralizedForceSize() { if(updSize) calcSize(); return nla; }
60 
61  virtual void updateg() { }
62  virtual void updategd() { }
63  virtual void updatewb() { }
64  virtual void updateW(int i=0) { }
65  virtual void updateV(int i=0) { }
66  virtual void updateh(int i=0) { }
67  virtual void updateStopVector() { }
68  virtual void updateStopVectorParameters() { }
69  virtual void updateLinkStatus() { }
70  virtual void updateLinkStatusReg() { }
71  virtual void updateJacobians(int j=0) { }
72  virtual void updateb() { }
73 
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  void init(InitStage stage, const InitConfigSet &config) override;
86  virtual void initz();
87  virtual void writez(H5::GroupBase *group);
88  virtual void readz0(H5::GroupBase *group);
89 
90  virtual void setbInd(int bInd_) { bInd = bInd_; };
91 
92  /* INHERITED INTERFACE OF ELEMENT */
93  void plot() override;
94  /***************************************************/
95 
96  /* INTERFACE TO BE DEFINED IN DERIVED CLASS */
100  virtual void updateWRef(const fmatvec::Mat& ref, int i=0) = 0;
101 
105  virtual void updateVRef(const fmatvec::Mat& ref, int i=0) = 0;
106 
110  virtual void updatehRef(const fmatvec::Vec &hRef, int i=0) = 0;
111 
115  virtual void updaterRef(const fmatvec::Vec &ref, int i=0) = 0;
116 
120  virtual void updatewbRef(const fmatvec::Vec &ref);
121 
125  virtual void updatelaRef(const fmatvec::Vec& ref);
126 
130  virtual void updateLaRef(const fmatvec::Vec& ref);
131 
135  virtual void deletelaRef();
136 
140  virtual void updategRef(const fmatvec::Vec& ref);
141 
145  virtual void updategdRef(const fmatvec::Vec& ref);
146 
150  virtual void updateresRef(const fmatvec::Vec& ref);
151 
155  virtual void updaterFactorRef(const fmatvec::Vec& ref);
156 
160  virtual void updatesvRef(const fmatvec::Vec &sv);
161 
165  virtual void updatejsvRef(const fmatvec::VecInt &jsvParent);
166 
170  virtual void updateLinkStatusRef(const fmatvec::VecInt &LinkStatusParent);
171 
175  virtual void updateLinkStatusRegRef(const fmatvec::VecInt &LinkStatusRegParent);
176 
180  virtual void calclaSize(int j) { laSize = 0; }
181 
185  virtual void calcgSize(int j) { gSize = 0; }
186 
193  virtual void calcgdSize(int j) { gdSize = 0; }
194 
198  virtual void calcrFactorSize(int j) { rFactorSize = 0; }
199 
203  virtual void calcbSize() { bSize = 0; }
204 
208  virtual void calcsvSize() { svSize = 0; }
209 
213  virtual void calcLinkStatusSize() { LinkStatusSize =0;}
214 
219 
225  virtual bool isSetValued() const { return false; }
226 
232  virtual bool isSingleValued() const { return false; }
233 
237  virtual bool isActive() const = 0;
238 
242  virtual bool gActiveChanged() = 0;
243 
247  virtual bool detectImpact() { return false; }
248 
253  virtual void solveImpactsFixpointSingle() { throwError("(Link::solveImpactsFixpointSingle): Not implemented."); }
254 
258  virtual void solveConstraintsFixpointSingle() { throwError("(Link::solveConstraintsFixpointSingle): Not implemented."); }
259 
264  virtual void solveImpactsGaussSeidel() { throwError("(Link::solveImpactsGaussSeidel): Not implemented."); }
265 
269  virtual void solveConstraintsGaussSeidel() { throwError("(Link::solveConstraintsGaussSeidel): Not implemented."); }
270 
275  virtual void solveImpactsRootFinding() { throwError("(Link::solveImpactsRootFinding): Not implemented."); }
276 
280  virtual void solveConstraintsRootFinding() { throwError("(Link::solveConstraintsRootFinding): Not implemented."); }
281 
285  virtual void jacobianConstraints() { throwError("(Link::jacobianConstraints): Not implemented."); }
286 
290  virtual void jacobianImpacts() { throwError("(Link::jacobianImpacts): Not implemented."); }
291 
295  virtual void updaterFactors() { throwError("(Link::updaterFactors): Not implemented."); }
296 
300  virtual void checkImpactsForTermination() { throwError("(Link::checkImpactsForTermination): Not implemented."); }
301 
305  virtual void checkConstraintsForTermination() { throwError("(Link::checkConstraintsForTermination): Not implemented."); }
306 
313  virtual void checkActive(int j) { }
314 
318  virtual double evalPotentialEnergy() { return 0; }
319 
320  virtual void setGeneralizedForceTolerance(double tol) { laTol = tol; }
321  virtual void setGeneralizedImpulseTolerance(double tol) { LaTol = tol; }
322  virtual void setGeneralizedRelativePositionTolerance(double tol) { gTol = tol; }
323  virtual void setGeneralizedRelativeVelocityTolerance(double tol) { gdTol = tol; }
324  virtual void setGeneralizedRelativeAccelerationTolerance(double tol) { gddTol = tol; }
325  virtual void setGeneralizedRelativePositionCorrectionValue(double corr) { gCorr = corr; }
326  virtual void setGeneralizedRelativeVelocityCorrectionValue(double corr) { gdCorr = corr; }
327  virtual void setrMax(double rMax_) { rMax = rMax_; }
328  virtual void setLinkStatusInd(int LinkStatusInd_) { LinkStatusInd = LinkStatusInd_; };
329  virtual void setLinkStatusRegInd(int LinkStatusRegInd_) { LinkStatusRegInd = LinkStatusRegInd_; };
330  virtual void setlaInd(int laInd_) { laInd = laInd_;Ila=fmatvec::RangeV(laInd,laInd+laSize-1); }
331  virtual void setgInd(int gInd_) { gInd = gInd_; Ig=fmatvec::RangeV(gInd,gInd+gSize-1); }
332  virtual void setgdInd(int gdInd_) { gdInd = gdInd_; }
333  virtual void setrFactorInd(int rFactorInd_) { rFactorInd = rFactorInd_; }
342  virtual void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_,fmatvec::Vec &gdInActive_,int *IndInActive_,fmatvec::Vec &gAct_,int *IndActive_) { }
343 
347  virtual void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) { }
348  virtual void updatecorr(int j) { corr.init(0); }
349  virtual void updatecorrRef(const fmatvec::Vec &ref);
350  virtual void calccorrSize(int j) { corrSize = 0; }
351  virtual void setcorrInd(int corrInd_) { corrInd = corrInd_; }
352  virtual void checkRoot() { }
353  /***************************************************/
354 
355  void setx(const fmatvec::Vec &x_) { x = x_; }
356 
357  virtual void setsvInd(int svInd_) { svInd = svInd_; };
358  int getsvSize() const { return svSize; }
359 
360  int getLinkStatusSize() const { return LinkStatusSize; }
361 
362  int getLinkStatusRegSize() const { return LinkStatusRegSize; }
363 
364  const fmatvec::Vec& getla(bool check=true) const;
365  const fmatvec::Vec& getLa(bool check=true) const;
366  fmatvec::Vec& getla(bool check=true);
367  fmatvec::Vec& getLa(bool check=true);
368  fmatvec::Vec& getwb(bool check=true);
369 
370  int getlaInd() const { return laInd; }
371  int getlaSize() const { return laSize; }
372  int getbSize() const { return bSize; }
373 
374  const fmatvec::Vec& evalg();
375  const fmatvec::Vec& evalgd();
376  const fmatvec::Vec& evalla();
377  const fmatvec::Vec& evalLa();
378  const fmatvec::Vec& evalwb();
379  const fmatvec::Vec& evalxd();
380 
381  int getgdInd() const { return gdInd; }
382  int getgSize() const { return gSize; }
383  int getgdSize() const { return gdSize; }
384 
385  int getrFactorSize() const { return rFactorSize; }
386 
387  const fmatvec::VecInt& getrFactorUnsure() const { return rFactorUnsure; }
388 
389  void resetUpToDate() override { updrrel = true; updvrel = true; updla = true; }
390 
391  virtual void updateGeneralizedPositions() { updrrel = false; }
392  virtual void updateGeneralizedVelocities() { updvrel = false; }
393  virtual void updateGeneralizedForces() { updla = false; }
394 
395  const fmatvec::VecV& evalGeneralizedRelativePosition() { if(updrrel) updateGeneralizedPositions(); return rrel; }
396  const fmatvec::VecV& evalGeneralizedRelativeVelocity() { if(updvrel) updateGeneralizedVelocities(); return vrel; }
397  const fmatvec::VecV& evalGeneralizedForce() { if(updla) updateGeneralizedForces(); return lambda; }
398 
399  fmatvec::VecV& getGeneralizedRelativePosition(bool check=true) { assert((not check) or (not updrrel)); return rrel; }
400  fmatvec::VecV& getGeneralizedRelativeVelocity(bool check=true) { assert((not check) or (not updvrel)); return vrel; }
401  fmatvec::VecV& getGeneralizedForce(bool check=true) { assert((not check) or (not updla)); return lambda; }
402 
406  void savela();
407 
411  void saveLa();
412 
416  void initla();
417 
421  void initLa();
422 
426  void decreaserFactors();
427 
428 
429  int getcorrSize() const { return corrSize; }
430 
431  bool getUpdaterrel() const { return updrrel; }
432 
433  protected:
434  int ng, ngd, nla;
435 
440 
445 
446  fmatvec::Vec dx;
447 
452 
456  int xSize, xInd;
457 
462 
466  fmatvec::VecInt jsv;
467 
471  int svSize, svInd;
472 
477  fmatvec::VecInt LinkStatus;
478 
482  int LinkStatusSize, LinkStatusInd;
483 
488  fmatvec::VecInt LinkStatusReg;
489 
493  int LinkStatusRegSize, LinkStatusRegInd;
494 
498  fmatvec::Vec g, gd, la, La;
499 
504 
508  int gSize, gInd;
509 
513  int gdSize, gdInd;
514 
518  int laSize, laInd;
519 
523  int bSize, bInd;
524 
528  fmatvec::RangeV Ig, Ila;
529 
533  double gTol, gdTol, gddTol, laTol, LaTol;
534 
538  double gCorr, gdCorr;
539 
544 
549 
553  fmatvec::VecInt rFactorUnsure;
554 
558  int rFactorSize, rFactorInd;
559 
563  double rMax;
564 
569 
573  std::vector<fmatvec::Mat> W[2];
574 
578  std::vector<fmatvec::Mat> V[2];
579 
583  std::vector<fmatvec::Vec> h[2];
584 
588  std::vector<fmatvec::Mat> dhdq;
589  std::vector<fmatvec::Mat> dhdu;
590  std::vector<fmatvec::Vec> dhdt;
591 
595  std::vector<fmatvec::Vec> r[2];
596 
601 
606 
607  int corrSize, corrInd;
608  fmatvec::Vec corr;
609 
610  fmatvec::VecV rrel, vrel, lambda;
611 
612  bool updSize, updrrel, updvrel, updla;
613  };
614 }
615 
616 #endif /* _LINK_H_ */
basic class of MBSim mainly for plotting
Definition: element.h:56
InitStage
The stages of the initialization.
Definition: element.h:62
std::string name
name of element
Definition: element.h:235

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Home