00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _LINK_H_
00021 #define _LINK_H_
00022
00023 #include "mbsim/element.h"
00024
00025
00026 #include "mbsim/mbsim_event.h"
00027
00028 namespace H5 {
00029 class Group;
00030 }
00031
00032 namespace MBSim {
00033
00034 class Frame;
00035 class Object;
00036 class Contour;
00037 class DynamicSystem;
00038
00052
00053 class Link : public Element {
00054 public:
00059 Link(const std::string &name);
00060
00064 virtual ~Link() {}
00065
00066
00067 virtual void updateg(double t) = 0;
00068 virtual void updategd(double t) = 0;
00069 virtual void updatewb(double t, int i=0) {};
00070 virtual void updateW(double t, int i=0) {};
00071 virtual void updateV(double t, int i=0) {};
00072 virtual void updateh(double t, int i=0) {};
00073 virtual void updateStopVector(double t) {}
00074 virtual void updateLinkStatus(double t) {}
00075 virtual void updateLinkStatusReg(double t) {}
00076 virtual void updateJacobians(double t, int j=0) {}
00077 virtual void updateb(double t) {};
00078
00079
00080
00081 virtual void updatedx(double t, double dt) {}
00082 virtual void updatexd(double t) {}
00083 virtual void calcxSize() { xSize = 0; }
00084 virtual const fmatvec::Vec& getx() const { return x; }
00085 virtual fmatvec::Vec& getx() { return x; }
00086 virtual void setxInd(int xInd_) { xInd = xInd_; };
00087 virtual int getxSize() const { return xSize; }
00088 virtual void updatexRef(const fmatvec::Vec& ref);
00089 virtual void updatexdRef(const fmatvec::Vec& ref);
00090 virtual void updatebRef(const fmatvec::Mat &hRef);
00091 virtual void init(InitStage stage);
00092 virtual void initz();
00093 virtual void writez(const H5::Group & group);
00094 virtual void readz0(const H5::Group & group);
00095
00096
00097 virtual void setbInd(int bInd_) { bInd = bInd_; };
00098
00099
00100 std::string getType() const { return "Link"; }
00101 virtual void plot(double t, double dt = 1);
00102 virtual void closePlot();
00103
00104
00105
00109 virtual void updateWRef(const fmatvec::Mat& ref, int i=0) = 0;
00110
00114 virtual void updateVRef(const fmatvec::Mat& ref, int i=0) = 0;
00115
00119 virtual void updatehRef(const fmatvec::Vec &hRef, int i=0) = 0;
00120
00124 virtual void updaterRef(const fmatvec::Vec &ref, int i=0) = 0;
00125
00129 virtual void updatewbRef(const fmatvec::Vec &ref);
00130
00134 virtual void updatefRef(const fmatvec::Vec &ref) {};
00135
00139 virtual void updatelaRef(const fmatvec::Vec& ref);
00140
00144 virtual void deletelaRef();
00145
00149 virtual void updategRef(const fmatvec::Vec& ref);
00150
00154 virtual void updategdRef(const fmatvec::Vec& ref);
00155
00159 virtual void updateresRef(const fmatvec::Vec& ref);
00160
00164 virtual void updaterFactorRef(const fmatvec::Vec& ref);
00165
00169 virtual void updatesvRef(const fmatvec::Vec &sv);
00170
00174 virtual void updatejsvRef(const fmatvec::VecInt &jsvParent);
00175
00179 virtual void updateLinkStatusRef(const fmatvec::VecInt &LinkStatusParent);
00180
00184 virtual void updateLinkStatusRegRef(const fmatvec::VecInt &LinkStatusRegParent);
00185
00189 virtual void calclaSize(int j) { laSize = 0; }
00190
00194 virtual void calcgSize(int j) { gSize = 0; }
00195
00199 virtual void calcgdSize(int j) { gdSize = 0; }
00200
00204 virtual void calcrFactorSize(int j) { rFactorSize = 0; }
00205
00209 virtual void calcbSize() { bSize = 0; }
00210
00214 virtual void calcsvSize() { svSize = 0; }
00215
00219 virtual void calcLinkStatusSize() { LinkStatusSize =0;}
00220
00224 virtual void calcLinkStatusRegSize() { LinkStatusRegSize =0;}
00225
00231 virtual bool isSetValued() const { return false; }
00232
00238 virtual bool isSingleValued() const { return false; }
00239
00245 virtual bool hasSmoothPart() const { return false; }
00246
00250 virtual bool isActive() const = 0;
00251
00255 virtual bool gActiveChanged() = 0;
00256
00260 virtual void solveImpactsFixpointSingle(double dt) { throw MBSimError("ERROR in "+getName()+" (Link::solveImpactsFixpointSingle): Not implemented."); }
00261
00265 virtual void solveConstraintsFixpointSingle() { throw MBSimError("ERROR in "+getName()+" (Link::solveConstraintsFixpointSingle): Not implemented."); }
00266
00270 virtual void solveImpactsGaussSeidel(double dt) { throw MBSimError("ERROR in "+getName()+" (Link::solveImpactsGaussSeidel): Not implemented."); }
00271
00275 virtual void solveConstraintsGaussSeidel() { throw MBSimError("ERROR in "+getName()+" (Link::solveConstraintsGaussSeidel): Not implemented."); }
00276
00280 virtual void solveImpactsRootFinding(double dt) { throw MBSimError("ERROR in "+getName()+" (Link::solveImpactsRootFinding): Not implemented."); }
00281
00285 virtual void solveConstraintsRootFinding() { throw MBSimError("ERROR in "+getName()+" (Link::solveConstraintsRootFinding): Not implemented."); }
00286
00290 virtual void jacobianConstraints() { throw MBSimError("ERROR in "+getName()+" (Link::jacobianConstraints): Not implemented."); }
00291
00295 virtual void jacobianImpacts() { throw MBSimError("ERROR in "+getName()+" (Link::jacobianImpacts): Not implemented."); }
00296
00300 virtual void updaterFactors() { throw MBSimError("ERROR in "+getName()+" (Link::updaterFactors): Not implemented."); }
00301
00305 virtual void checkImpactsForTermination(double dt) { throw MBSimError("ERROR in "+getName()+" (Link::checkImpactsForTermination): Not implemented."); }
00306
00310 virtual void checkConstraintsForTermination() { throw MBSimError("ERROR in "+getName()+" (Link::checkConstraintsForTermination): Not implemented."); }
00311
00316 virtual void checkActive(int j) {}
00317
00321 virtual double computePotentialEnergy() { return 0; }
00322
00323
00324 virtual void setlaTol(double tol) { laTol = tol; }
00325 virtual void setLaTol(double tol) { LaTol = tol; }
00326 virtual void setgTol(double tol) { gTol = tol; }
00327 virtual void setgdTol(double tol) { gdTol = tol; }
00328 virtual void setgddTol(double tol) { gddTol = tol; }
00329 virtual void setrMax(double rMax_) { rMax = rMax_; }
00330
00331
00332
00333 const std::vector<fmatvec::Mat>& getW(int i=0) const { return W[i]; }
00334 const std::vector<fmatvec::Mat>& getV(int i=0) const { return V[i]; }
00335 const std::vector<fmatvec::Vec>& geth(int i=0) const { return h[i]; }
00336
00337 void setx(const fmatvec::Vec &x_) { x = x_; }
00338 const fmatvec::Vec& getxd() const { return xd; }
00339
00340 void setsvInd(int svInd_) { svInd = svInd_; };
00341 int getsvSize() const { return svSize; }
00342
00343 virtual void setLinkStatusInd(int LinkStatusInd_) { LinkStatusInd = LinkStatusInd_; };
00344 int getLinkStatusSize() const { return LinkStatusSize; }
00345
00346 virtual void setLinkStatusRegInd(int LinkStatusRegInd_) { LinkStatusRegInd = LinkStatusRegInd_; };
00347 int getLinkStatusRegSize() const { return LinkStatusRegSize; }
00348
00349 const fmatvec::Vec& getla() const { return la; }
00350 fmatvec::Vec& getla() { return la; }
00351 virtual void setlaInd(int laInd_) { laInd = laInd_;Ila=fmatvec::Index(laInd,laInd+laSize-1); }
00352 int getlaInd() const { return laInd; }
00353 int getlaSize() const { return laSize; }
00354 int getbSize() const { return bSize; }
00355 const fmatvec::Index& getlaIndex() const { return Ila; }
00356
00357 const fmatvec::Vec& getg() const { return g; }
00358 fmatvec::Vec& getg() { return g; }
00359 virtual void setgInd(int gInd_) { gInd = gInd_; Ig=fmatvec::Index(gInd,gInd+gSize-1); }
00360 const fmatvec::Vec& getgd() const { return gd; }
00361 fmatvec::Vec& getgd() { return gd; }
00362 const fmatvec::Vec& getwb() const { return wb; }
00363 fmatvec::Vec& getwb() { return wb; }
00364 virtual void setgdInd(int gdInd_) { gdInd = gdInd_; }
00365 int getgdInd() const { return gdInd; }
00366 int getgSize() const { return gSize; }
00367 int getgdSize() const { return gdSize; }
00368 const fmatvec::Index& getgIndex() const { return Ig; }
00369
00370 virtual void setrFactorInd(int rFactorInd_) { rFactorInd = rFactorInd_; }
00371 int getrFactorSize() const { return rFactorSize; }
00372
00373 const fmatvec::VecInt& getrFactorUnsure() const { return rFactorUnsure; }
00374
00378 void savela(double dt=1.0);
00379
00383 void initla(double dt=1.0);
00384
00388 void decreaserFactors();
00389
00393 virtual Element* getByPathSearch(std::string path);
00394
00403 virtual void LinearImpactEstimation(fmatvec::Vec &gInActive_,fmatvec::Vec &gdInActive_,int *IndInActive_,fmatvec::Vec &gAct_,int *IndActive_){};
00404
00408 virtual void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) {};
00409
00410 virtual void updatecorr(int j) { corr.init(0); }
00411 virtual void updatecorrRef(const fmatvec::Vec &ref);
00412 virtual void calccorrSize(int j) { corrSize = 0; }
00413 virtual void setcorrInd(int corrInd_) { corrInd = corrInd_; }
00414 int getcorrSize() const { return corrSize; }
00415 virtual void checkRoot() {};
00416
00417 protected:
00421 fmatvec::Vec x;
00422
00426 fmatvec::Vec xd;
00427
00431 fmatvec::Vec x0;
00432
00436 int xSize, xInd;
00437
00441 fmatvec::Vec sv;
00442
00446 fmatvec::VecInt jsv;
00447
00451 int svSize, svInd;
00452
00457 fmatvec::VecInt LinkStatus;
00458
00462 int LinkStatusSize, LinkStatusInd;
00463
00468 fmatvec::VecInt LinkStatusReg;
00469
00473 int LinkStatusRegSize, LinkStatusRegInd;
00474
00478 fmatvec::Vec g, gd, la;
00479
00483 fmatvec::Vec laS;
00484
00488 int gSize, gInd;
00489
00493 int gdSize, gdInd;
00494
00498 int laSize, laInd;
00499
00503 int bSize, bInd;
00504
00508 fmatvec::Index Ig, Ila;
00509
00513 double gTol, gdTol, gddTol, laTol, LaTol;
00514
00518 fmatvec::Vec la0;
00519
00523 fmatvec::Vec rFactor;
00524
00528 fmatvec::VecInt rFactorUnsure;
00529
00533 int rFactorSize, rFactorInd;
00534
00538 double rMax;
00539
00543 fmatvec::Vec res;
00544
00548 std::vector<fmatvec::Mat> W[2];
00549
00553 std::vector<fmatvec::Mat> V[2];
00554
00558 std::vector<fmatvec::Vec> h[2];
00559
00563 std::vector<fmatvec::Mat> dhdq;
00564 std::vector<fmatvec::Mat> dhdu;
00565 std::vector<fmatvec::Vec> dhdt;
00566
00570 std::vector<fmatvec::Vec> r[2];
00571
00575 fmatvec::Vec wb;
00576
00580 fmatvec::Mat b;
00581
00582 int corrSize, corrInd;
00583 fmatvec::Vec corr;
00584 };
00585 }
00586
00587 #endif
00588