mbsim  4.0.0
MBSim Kernel
dynamic_system_solver.h
1 /* Copyright (C) 2004-2018 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 _DYNAMIC_SYSTEM_SOLVER_H_
21 #define _DYNAMIC_SYSTEM_SOLVER_H_
22 
23 #include "mbsim/group.h"
24 #include "fmatvec/sparse_matrix.h"
25 #include "mbsim/functions/function.h"
26 #include "mbsim/environment.h"
27 
28 #include <atomic>
29 
30 namespace MBSim {
31 
32  class Graph;
33  class MBSimEnvironment;
34 
35  struct StateTable {
36  std::string name;
37  char label;
38  int number;
39  StateTable() = default;
40  StateTable(const std::string &name_, char label_, int number_) : name(name_), label(label_), number(number_) { }
41  };
42 
58  class DynamicSystemSolver : public Group {
59 
60  class Residuum : public MBSim::Function<fmatvec::Vec(fmatvec::Vec)> {
61  public:
62  Residuum(MBSim::DynamicSystemSolver *sys_) : sys(sys_) { }
63  fmatvec::Vec operator()(const fmatvec::Vec &z);
64  private:
66  };
67 
68  public:
69 
73  enum Solver { fixedpoint, GaussSeidel, direct, rootfinding, unknownSolver };
74 
79  DynamicSystemSolver(const std::string &name="");
80 
84  ~DynamicSystemSolver() override;
85 
124  void initialize();
125 
126  /*
127  * If true (the default) then
128  * the simulation output files (h5 files) are deleted/truncated/regenerated.
129  * If false, then these files left are untouched from a previous run.
130  * This is useful to regenerate the
131  * e.g. OpenMBV XML files without doing a new integration.
132  */
133  void setTruncateSimulationFiles(bool trunc) { truncateSimulationFiles=trunc; }
134 
135  /* INHERITED INTERFACE OF GROUP */
136  void init(InitStage stage, const InitConfigSet &config) override;
137  using Group::plot;
138  /***************************************************/
139 
140  /* INHERITED INTERFACE OF DYNAMICSYSTEM */
141  int solveConstraintsFixpointSingle() override;
142  int solveImpactsFixpointSingle() override;
143  int solveConstraintsGaussSeidel() override;
144  int solveImpactsGaussSeidel() override;
145  int solveConstraintsRootFinding() override;
146  int solveImpactsRootFinding() override;
147  void checkConstraintsForTermination() override;
148  void checkImpactsForTermination() override;
149  /***************************************************/
150 
151  /* INHERITED INTERFACE OF OBJECTINTERFACE */
152  void updateT() override;
153  void updateh(int i=0) override;
154  void updateM() override;
155  void updateLLM() override;
156  void updatezd() override;
157  /***************************************************/
158 
159  /* INHERITED INTERFACE OF LINKINTERFACE */
160 
171  virtual void updater(int j=0);
172  virtual void updaterdt();
173  void updatewb() override;
174  void updateg() override;
175  void updategd() override;
176  void updateW(int j=0) override;
177  void updateV(int j=0) override;
178  virtual void updatebc();
179  virtual void updatebi();
180  virtual void updatela();
181  virtual void updateLa();
182  /***************************************************/
183 
184  /* INHERITED INTERFACE OF ELEMENT */
185  /***************************************************/
186 
187  /* GETTER / SETTER */
188 
189  void setConstraintSolver(Solver solver_) { contactSolver = solver_; }
190  void setImpactSolver(Solver solver_) { impactSolver = solver_; }
191  const Solver& getConstraintSolver() { return contactSolver; }
192  const Solver& getImpactSolver() { return impactSolver; }
193  void setTermination(bool term_) { term = term_; }
194  void setMaximumNumberOfIterations(int iter) { maxIter = iter; }
195  void setHighNumberOfIterations(int iter) { highIter = iter; }
196  void setNumericalJacobian(bool numJac_) { numJac = numJac_; }
197  void setMaximumDampingSteps(int maxDSteps) { maxDampingSteps = maxDSteps; }
198  void setLevenbergMarquardtParamater(double lmParm_) { lmParm = lmParm_; }
199 
200  void setUseOldla(bool flag) { useOldla = flag; }
201  void setDecreaseLevels(const fmatvec::VecInt &decreaseLevels_) { decreaseLevels = decreaseLevels_; }
202  void setCheckTermLevels(const fmatvec::VecInt &checkTermLevels_) { checkTermLevels = checkTermLevels_; }
203  void setCheckGSize(bool checkGSize_) { checkGSize = checkGSize_; }
204  void setLimitGSize(int limitGSize_) { limitGSize = limitGSize_; checkGSize = false; }
205 
206  double& getTime() { return t; }
207  const double& getTime() const { return t; }
208  void setTime(double t_) { t = t_; }
209 
210  double getStepSize() const { return dt; }
211  void setStepSize(double dt_) { dt = dt_; }
212 
213  int getzSize() const { return zSize; }
214 
215  fmatvec::Vec& getState() { return z; }
216  const fmatvec::Vec& getState() const { return z; }
217  void setState(const fmatvec::Vec &z_) { z = z_; }
218 
219  void setzd(const fmatvec::Vec &zd_) { zd = zd_; }
220 
221  const fmatvec::SqrMat& getG(bool check=true) const { assert((not check) or (not updG)); return G; }
222  const fmatvec::SparseMat& getGs(bool check=true) const { assert((not check) or (not updG)); return Gs; }
223  const fmatvec::Vec& getbc(bool check=true) const { assert((not check) or (not updbc)); return bc; }
224  const fmatvec::Vec& getbi(bool check=true) const { assert((not check) or (not updbi)); return bi; }
225  const fmatvec::SqrMat& getJprox() const { return Jprox; }
226  fmatvec::SqrMat& getG(bool check=true) { assert((not check) or (not updG)); return G; }
227  fmatvec::SparseMat& getGs(bool check=true) { assert((not check) or (not updG)); return Gs; }
228  fmatvec::Vec& getbc(bool check=true) { assert((not check) or (not updbc)); return bc; }
229  fmatvec::Vec& getbi(bool check=true) { assert((not check) or (not updbi)); return bi; }
230  fmatvec::SqrMat& getJprox() { return Jprox; }
231 
232  const fmatvec::Vec& evaldq() { if(upddq) updatedq(); return dq; }
233  const fmatvec::Vec& evaldu() { if(upddu) updatedu(); return du; }
234  const fmatvec::Vec& evaldx() { if(upddx) updatedx(); return dx; }
235  const fmatvec::Vec& evalzd();
236  const fmatvec::SqrMat& evalG() { if(updG) updateG(); return G; }
237  const fmatvec::SparseMat& evalGs() { if(updG) updateG(); return Gs; }
238  const fmatvec::Vec& evalbc() { if(updbc) updatebc(); return bc; }
239  const fmatvec::Vec& evalbi() { if(updbi) updatebi(); return bi; }
240  const fmatvec::Vec& evalsv();
241  const fmatvec::Vec& evalz0();
242  const fmatvec::Vec& evalla() { if(updla) updatela(); return la; }
243  const fmatvec::Vec& evalLa() { if(updLa) updateLa(); return La; }
244 
245  fmatvec::Vec& getzParent() { return zParent; }
246  fmatvec::Vec& getzdParent() { return zdParent; }
247  fmatvec::Vec& getlaParent() { return laParent; }
248  fmatvec::Vec& getLaParent() { return LaParent; }
249 // const fmatvec::Vec& getzParent() const { return zParent; }
250 // const fmatvec::Vec& getzdParent() const { return zdParent; }
251 // const fmatvec::Mat& getWParent(int i=0) const { return WParent[i]; }
252  fmatvec::Mat& getWParent(int i=0) { return WParent[i]; }
253  fmatvec::Mat& getVParent(int i=0) { return VParent[i]; }
254 // fmatvec::Vec& getlaParent() { return laParent; }
255 // fmatvec::Vec& getLaParent() { return LaParent; }
256 // const fmatvec::Vec& getgParent() const { return gParent; }
257  fmatvec::Vec& getgParent() { return gParent; }
258 // const fmatvec::Vec& getgdParent() const { return gdParent; }
259  fmatvec::Vec& getgdParent() { return gdParent; }
260  fmatvec::Vec& getresParent() { return resParent; }
261  fmatvec::Vec& getrFactorParent() { return rFactorParent; }
262 
263  void resizezParent(int nz) { zParent.resize(nz); }
264  void resizezdParent(int nz) { zdParent.resize(nz); }
265 
266  DynamicSystemSolver* getDynamicSystemSolver() { return this; }
267  bool getIntegratorExitRequest() { return integratorExitRequest; }
268  int getMaxIter() {return maxIter;}
269  int getIterC() {return iterc;}
270  int getIterI() {return iteri;}
271  /***************************************************/
272 
277 
283 
290 
297 
305 
310  virtual void updateG();
311 
315  void decreaserFactors();
316 
323  virtual const fmatvec::Vec& shift();
324 
329  void getLinkStatus(fmatvec::VecInt &LinkStatusExt);
330 
335  void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt);
336 
340  bool positionDriftCompensationNeeded(double gmax);
341 
345  bool velocityDriftCompensationNeeded(double gdmax);
346 
350  void projectGeneralizedPositions(int mode, bool fullUpdate=false);
351 
355  void projectGeneralizedVelocities(int mode);
356 
361  void savela();
362 
367  void initla();
368 
373  void saveLa();
374 
379  void initLa();
380 
385  void addElement(Element *element_);
386 
392  Element* getElement(const std::string &name);
393 
397  std::string getSolverInfo();
398 
403  void setStopIfNoConvergence(bool flag, bool dropInfo = false) { stopIfNoConvergence = flag; dropContactInfo=dropInfo; }
404 
405  bool getStopIfNoConvergence() { return stopIfNoConvergence; }
406 
410  void dropContactMatrices();
411 
412  // MBSim signal handler
413 #ifndef SWIG
415  public:
416  SignalHandler();
417  ~SignalHandler();
418  private:
419  #ifdef HAVE_ANSICSIGNAL
420  using SigHandle = void (*)(int);
421  SigHandle oldSigInt;
422  SigHandle oldSigTerm;
423  #endif
424  };
425 #endif
426 
430  static void sigInterruptHandler(int);
431 
432  void checkExitRequest();
433 
434  // TODO just for testing
435  void setPartialEventDrivenSolver(bool peds_) { peds = peds_; }
436 
442  void writez(std::string fileName, bool formatH5=true);
443 
449  void writeStateTable(std::string fileName);
450 
455  void readz0(std::string fileName);
456 
457  void initializeUsingXML(xercesc::DOMElement *element) override;
458 
463  void setProjectionTolerance(double tol) { tolProj = tol; }
464 
469  void updatezRef(fmatvec::Vec &ext);
470 
475  void updatezdRef(fmatvec::Vec &ext);
476 
477  void setAlwaysConsiderContact(bool alwaysConsiderContact_) { alwaysConsiderContact = alwaysConsiderContact_; }
478 
479  void setInverseKinetics(bool inverseKinetics_) { inverseKinetics = inverseKinetics_; }
480  bool getInverseKinetics() const { return inverseKinetics; }
481 
482  void setInitialProjection(bool initialProjection_) { initialProjection = initialProjection_; }
483  bool getInitialProjection() const { return initialProjection; }
484 
485  void setDetermineEquilibriumState(bool determineEquilibriumState_) { determineEquilibriumState = determineEquilibriumState_; }
486  bool getDetermineEquilibriumState() const { return determineEquilibriumState; }
487 
488  void setUseConstraintSolverForSmoothMotion(bool useConstraintSolverForSmoothMotion_) { useConstraintSolverForSmoothMotion = useConstraintSolverForSmoothMotion_; }
489  bool getUseConstraintSolverForSmoothMotion() const { return useConstraintSolverForSmoothMotion; }
490 
491  void setUseConstraintSolverForPlot(bool useConstraintSolverForPlot_) { useConstraintSolverForPlot = useConstraintSolverForPlot_; }
492  bool getUseConstraintSolverForPlot() const { return useConstraintSolverForPlot; }
493 
494  fmatvec::Mat dhdq(int lb=0, int ub=0);
495  fmatvec::Mat dhdu(int lb=0, int ub=0);
496  fmatvec::Mat dhdx();
497  fmatvec::Vec dhdt();
498 
499  void setRootID(int ID) {rootID = ID;}
500  int getRootID() const {return rootID;}
501 
502  void resetUpToDate() override;
503 
504  bool getUpdateT() { return updT; }
505  bool getUpdateM() { return updM; }
506  bool getUpdateLLM() { return updLLM; }
507  bool getUpdateh(int j) { return updh[j]; }
508  bool getUpdater(int j) { return updr[j]; }
509  bool getUpdaterdt() { return updrdt; }
510  bool getUpdateW(int j) { return updW[j]; }
511  bool getUpdateV(int j) { return updV[j]; }
512  bool getUpdatewb() { return updwb; }
513  bool getUpdateg() { return updg; }
514  bool getUpdategd() { return updgd; }
515  bool getUpdatela() { return updla; }
516  bool getUpdateLa() { return updLa; }
517  bool getUpdatezd() { return updzd; }
518  bool getUpdatedq() { return upddq; }
519  bool getUpdatedu() { return upddu; }
520  bool getUpdatedx() { return upddx; }
521  void setUpdatela(bool updla_) { updla = updla_; }
522  void setUpdateLa(bool updLa_) { updLa = updLa_; }
523  void setUpdateG(bool updG_) { updG = updG_; }
524  void setUpdatebi(bool updbi_) { updbi = updbi_; }
525  void setUpdatebc(bool updbc_) { updbc = updbc_; }
526  void setUpdatezd(bool updzd_) { updzd = updzd_; }
527  void setUpdateW(bool updW_, int i=0) { updW[i] = updW_; }
528 
533  void updategRef(fmatvec::Vec &ref) override { Group::updategRef(ref); updg = true; }
534 
539  void updategdRef(fmatvec::Vec &ref) override { Group::updategdRef(ref); updgd = true; }
540 
545  void updatewbRef(fmatvec::Vec &ref) override { Group::updatewbRef(ref); updwb = true; }
546 
552  void updateWRef(fmatvec::Mat &ref, int i=0) override { Group::updateWRef(ref,i); updW[i] = true; }
553 
559  void updateVRef(fmatvec::Mat &ref, int i=0) override { Group::updateVRef(ref,i); updV[i] = true; }
560 
564  virtual void updatelaInverseKinetics();
565 
566  void updatedq() override;
567  void updatedu() override;
568  void updatedx() override;
569 
570  void updateStopVector() override;
571 
572  void updateInternalState();
573 
574  void plot() override;
575 
576  void addEnvironment(Environment* env);
577 
582  template<class Env>
583  Env* getEnvironment();
584 
588 
589  std::vector<StateTable>& getStateTable() { return tabz; }
590 
591  void setCompressionLevel(int level) { compressionLevel=level; }
592  void setChunkSize(int size) { chunkSize=size; }
593  void setCacheSize(int size) { cacheSize=size; }
594 
595  protected:
599  double t;
600 
604  double dt;
605 
609  int zSize;
610 
614  fmatvec::Vec z;
615 
619  fmatvec::Vec zd;
620 
624  fmatvec::SymMat MParent;
625 
629  fmatvec::SymMat LLMParent;
630 
634  fmatvec::Mat TParent;
635 
639  fmatvec::Mat WParent[2];
640 
644  fmatvec::Mat VParent[2];
645 
649  fmatvec::Vec wbParent;
650 
654  fmatvec::Vec laParent, LaParent;
655 
659  fmatvec::Vec rFactorParent;
660 
664  fmatvec::Vec sParent;
665 
669  fmatvec::Vec resParent;
670 
671  fmatvec::Vec curisParent, nextisParent;
672 
676  fmatvec::Vec gParent;
677 
681  fmatvec::Vec gdParent;
682 
686  fmatvec::Vec zParent;
687 
691  fmatvec::Vec zdParent;
692 
693  fmatvec::Vec dxParent, dqParent, duParent;
694 
698  fmatvec::Vec hParent[2];
699 
703  fmatvec::Vec rParent[2], rdtParent;
704 
708  fmatvec::Vec svParent;
709 
713  fmatvec::VecInt jsvParent;
714 
718  fmatvec::VecInt LinkStatusParent;
719 
724  fmatvec::VecInt LinkStatusRegParent;
725 
729  fmatvec::SparseMat Gs;
730 
734  fmatvec::SqrMat Jprox;
735 
739  fmatvec::SqrMat G;
740 
744  fmatvec::Vec bc, bi;
745 
749  bool term;
750 
754  int maxIter, highIter, maxDampingSteps, iterc, iteri;
755 
759  double lmParm;
760 
764  Solver contactSolver, impactSolver;
765 
770 
775 
779  bool useOldla;
780 
784  bool numJac;
785 
789  fmatvec::VecInt decreaseLevels;
790 
794  fmatvec::VecInt checkTermLevels;
795 
800 
805 
809  bool peds;
810 
814  double tolProj;
815 
819  fmatvec::Vec laInverseKineticsParent;
820  fmatvec::Mat bInverseKineticsParent;
821 
825  fmatvec::Mat WInverseKineticsParent;
826 
827  bool alwaysConsiderContact;
828  bool inverseKinetics;
829  bool initialProjection;
830  bool determineEquilibriumState;
831  bool useConstraintSolverForSmoothMotion;
832  bool useConstraintSolverForPlot;
833 
834  fmatvec::Vec corrParent;
835 
836  int rootID;
837 
838  double gTol, gdTol, gddTol, laTol, LaTol;
839 
840  bool updT, updh[2], updr[2], updrdt, updM, updLLM, updW[2], updV[2], updwb, updg, updgd, updG, updbc, updbi, updsv, updzd, updla, updLa, upddq, upddu, upddx;
841 
842  bool solveDirectly;
843 
844  std::vector<StateTable> tabz;
845 
846  int compressionLevel { H5::File::getDefaultCompression() };
847  int chunkSize { H5::File::getDefaultChunkSize() };
848  int cacheSize { H5::File::getDefaultCacheSize() };
849 
850  private:
854  void constructor();
855 
860 
864  static std::atomic<bool> exitRequest;
865  static_assert(decltype(exitRequest)::is_always_lock_free);
866 
870  bool READZ0;
871 
880  void addToGraph(Graph* graph, fmatvec::SqrMat &A, int i, std::vector<Element*> &objList);
881 
882  bool truncateSimulationFiles;
883 
884  // Holds the dynamic systems before the "reorganize hierarchy" takes place.
885  // This is required since all elements of all other containers from DynamicSystem are readded to DynamicSystemSolver,
886  // except this container (which is a "pure" container = no calculation is done in DynamicSystem)
887  // However, we must hold this container until the dtor of DynamicSystemSolver is called to avoid the deallocation of other
888  // elements hold by DynamicSystem elements (especially (currently only) hdf5File)
889  std::vector<DynamicSystem*> dynamicsystemPreReorganize;
890 
891  double facSizeGs;
892 
893  std::vector<std::unique_ptr<Environment>> environments;
894  MBSimEnvironment *mbsimEnvironment = nullptr;
895 
896  bool firstPlot { true };
897  };
898 
899  template<class Env>
901  // get the Environment of type Env
902  auto &reqType=typeid(Env);
903  for(auto &e : environments) {
904  auto &e_=*e;
905  if(reqType==typeid(e_))
906  return static_cast<Env*>(e.get());
907  }
908  auto newEnv=new Env;
909  addEnvironment(newEnv);
910  return newEnv;
911  }
912 
913 }
914 
915 #endif /* _DYNAMIC_SYSTEM_SOLVER_H_ */
bool useOldla
flag if contac force parameter of last time step should be used
Definition: dynamic_system_solver.h:779
Definition: dynamic_system_solver.h:35
void plot() override
plots time dependent data
Definition: dynamic_system_solver.cc:1610
int solveImpactsGaussSeidel() override
solve impact equations with Gauss-Seidel scheme on velocity level
Definition: dynamic_system_solver.cc:528
int(DynamicSystemSolver::* solveConstraints_)()
Definition: dynamic_system_solver.h:282
int solveConstraintsLinearEquations()
solution of contact equations with Cholesky decomposition
Definition: dynamic_system_solver.cc:887
fmatvec::Vec gParent
relative distances
Definition: dynamic_system_solver.h:676
int zSize
size of state vector
Definition: dynamic_system_solver.h:609
double t
time
Definition: dynamic_system_solver.h:599
bool checkGSize
boolean if force action matrix should be resized in each step
Definition: dynamic_system_solver.h:799
int solveImpactsLinearEquations()
solution of contact equations with Cholesky decomposition on velocity level
Definition: dynamic_system_solver.cc:892
fmatvec::Vec rParent[2]
nonsmooth right hand side
Definition: dynamic_system_solver.h:703
int solveConstraintsGaussSeidel() override
solve contact equations with Gauss-Seidel scheme
Definition: dynamic_system_solver.cc:508
void initLa()
load contact impulses for use as starting value
Definition: dynamic_system_solver.cc:1157
bool term
boolean to check for termination of contact equations solution
Definition: dynamic_system_solver.h:749
void readz0(std::string fileName)
reads state from a file
Definition: dynamic_system_solver.cc:1298
Env * getEnvironment()
Definition: dynamic_system_solver.h:900
bool dropContactInfo
flag if contact matrices for debugging should be dropped in no-convergence case
Definition: dynamic_system_solver.h:774
int solveConstraintsFixpointSingle() override
solve contact equations with single step fixed point scheme
Definition: dynamic_system_solver.cc:448
double tolProj
Tolerance for projection of generalized position.
Definition: dynamic_system_solver.h:814
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:58
void initla()
load contact forces for use as starting value
Definition: dynamic_system_solver.cc:1147
virtual void updateVRef(fmatvec::Mat &VParent, int j=0)
references to condensed contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:832
fmatvec::SparseMat Gs
sparse mass action matrix
Definition: dynamic_system_solver.h:729
fmatvec::VecInt checkTermLevels
TODO.
Definition: dynamic_system_solver.h:794
DynamicSystemSolver(const std::string &name="")
constructor
Definition: dynamic_system_solver.cc:73
Solver contactSolver
solver for contact equations and impact equations
Definition: dynamic_system_solver.h:764
void updategRef(fmatvec::Vec &ref) override
references to relative distances of dynamic system parent
Definition: dynamic_system_solver.h:533
fmatvec::Vec bc
TODO.
Definition: dynamic_system_solver.h:744
bool stopIfNoConvergence
flag if the contact equations should be stopped if there is no convergence
Definition: dynamic_system_solver.h:769
virtual const fmatvec::Vec & shift()
update for event driven integrator for event
Definition: dynamic_system_solver.cc:1444
void updateVRef(fmatvec::Mat &ref, int i=0) override
references to condensed contact force direction matrix of dynamic system parent
Definition: dynamic_system_solver.h:559
fmatvec::Mat TParent
matrix of linear relation between differentiated positions and velocities
Definition: dynamic_system_solver.h:634
fmatvec::Vec sParent
TODO.
Definition: dynamic_system_solver.h:664
fmatvec::VecInt LinkStatusRegParent
status vector of single valued links
Definition: dynamic_system_solver.h:724
Definition: environment.h:37
fmatvec::Vec zd
derivative of state vector
Definition: dynamic_system_solver.h:619
void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt)
Definition: dynamic_system_solver.cc:1004
void updateWRef(fmatvec::Mat &ref, int i=0) override
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system_solver.h:552
fmatvec::Vec gdParent
relative velocities
Definition: dynamic_system_solver.h:681
void projectGeneralizedVelocities(int mode)
drift projection for positions
Definition: dynamic_system_solver.cc:1102
fmatvec::VecInt LinkStatusParent
status vector of set valued links with piecewise link equation (which piece is valid)
Definition: dynamic_system_solver.h:718
virtual void updatewbRef(fmatvec::Vec &wbParent)
references to TODO of dynamic system parent
Definition: dynamic_system.cc:804
group ingredients do not depend on each other
Definition: group.h:35
void checkImpactsForTermination() override
validate force laws concerning given tolerances on velocity level
Definition: dynamic_system_solver.cc:691
std::string getSolverInfo()
Definition: dynamic_system_solver.cc:1201
fmatvec::Vec z
state vector
Definition: dynamic_system_solver.h:614
basic class of MBSim mainly for plotting
Definition: element.h:58
static void sigInterruptHandler(int)
handler for user interrupt signal
Definition: dynamic_system_solver.cc:1251
double lmParm
Levenberg-Marquard parameter.
Definition: dynamic_system_solver.h:759
int solveImpactsFixpointSingle() override
solve impact equations with single step fixed point scheme on velocity level
Definition: dynamic_system_solver.cc:478
void addElement(Element *element_)
Definition: dynamic_system_solver.cc:1162
fmatvec::Vec rFactorParent
relaxation parameters for contact equations
Definition: dynamic_system_solver.h:659
void checkConstraintsForTermination() override
validate force laws concerning given tolerances
Definition: dynamic_system_solver.cc:680
virtual void updateWRef(fmatvec::Mat &WParent, int j=0)
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:811
fmatvec::VecInt decreaseLevels
decreasing relaxation factors is done in levels containing the number of contact iterations as condit...
Definition: dynamic_system_solver.h:789
virtual void updatelaInverseKinetics()
update inverse kinetics constraint forces
Definition: dynamic_system_solver.cc:1534
void setStopIfNoConvergence(bool flag, bool dropInfo=false)
Definition: dynamic_system_solver.h:403
Definition: dynamic_system_solver.h:60
Definition: environment.h:59
virtual void updater(int j=0)
update smooth link force law
Definition: dynamic_system_solver.cc:805
void dropContactMatrices()
Definition: dynamic_system_solver.cc:1216
void updatezdRef(fmatvec::Vec &ext)
references to differentiated external state
Definition: dynamic_system_solver.cc:1318
void initialize()
Initialize the system.
Definition: dynamic_system_solver.cc:91
virtual void updateG()
updates mass action matrix
Definition: dynamic_system_solver.cc:897
~DynamicSystemSolver() override
destructor
Definition: dynamic_system_solver.cc:83
bool numJac
flag if Jacobian for Newton scheme should be calculated numerically
Definition: dynamic_system_solver.h:784
fmatvec::Mat WParent[2]
contact force directions
Definition: dynamic_system_solver.h:639
void plot() override
plots time dependent data
Definition: dynamic_system.cc:332
class for tree-structured mechanical systems with recursive and flat memory mechanism
Definition: graph.h:36
InitStage
The stages of the initialization.
Definition: element.h:64
void setProjectionTolerance(double tol)
set tolerance for projection of generalized position
Definition: dynamic_system_solver.h:463
int(DynamicSystemSolver::* solveImpacts_)()
function pointer for election of prox-solver for impact equations on velocity level
Definition: dynamic_system_solver.h:289
Element * getElement(const std::string &name)
Definition: dynamic_system_solver.cc:1174
bool positionDriftCompensationNeeded(double gmax)
check if drift compensation on position level is needed
Definition: dynamic_system_solver.cc:1012
fmatvec::VecInt jsvParent
boolean evaluation of stopvector
Definition: dynamic_system_solver.h:713
void savela()
save contact forces for use as starting value in next time step
Definition: dynamic_system_solver.cc:1142
Definition: contact_kinematics.h:32
void projectGeneralizedPositions(int mode, bool fullUpdate=false)
drift projection for positions
Definition: dynamic_system_solver.cc:1038
fmatvec::SymMat LLMParent
Cholesky decomposition of mass matrix.
Definition: dynamic_system_solver.h:629
std::string name
name of element
Definition: element.h:262
static std::atomic< bool > exitRequest
boolean signal evaluation for end integration set by user
Definition: dynamic_system_solver.h:864
int limitGSize
TODO.
Definition: dynamic_system_solver.h:804
fmatvec::SymMat MParent
mass matrix
Definition: dynamic_system_solver.h:624
bool peds
TODO, flag for occuring impact and sticking in event driven solver.
Definition: dynamic_system_solver.h:809
fmatvec::Vec hParent[2]
smooth, smooth with respect to objects, smooth with respect to links right hand side
Definition: dynamic_system_solver.h:698
void writeStateTable(std::string fileName)
writes state table to a file
Definition: dynamic_system_solver.cc:1287
void constructor()
set plot feature default values
Definition: dynamic_system_solver.cc:1332
fmatvec::SqrMat G
mass action matrix
Definition: dynamic_system_solver.h:739
double dt
step size
Definition: dynamic_system_solver.h:604
void saveLa()
save contact impulses for use as starting value in next time step
Definition: dynamic_system_solver.cc:1152
bool integratorExitRequest
boolean signal evaluation for end integration set by program
Definition: dynamic_system_solver.h:859
fmatvec::Vec wbParent
TODO.
Definition: dynamic_system_solver.h:649
void addToGraph(Graph *graph, fmatvec::SqrMat &A, int i, std::vector< Element * > &objList)
adds list of objects to tree
Definition: dynamic_system_solver.cc:1431
virtual void updategRef(fmatvec::Vec &gParent)
references to relative distances of dynamic system parent
Definition: dynamic_system.cc:769
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: dynamic_system_solver.h:545
fmatvec::Vec la
contact force parameters
Definition: dynamic_system.h:865
int maxIter
maximum number of contact iterations, high number of contact iterations for warnings,...
Definition: dynamic_system_solver.h:754
void getLinkStatus(fmatvec::VecInt &LinkStatusExt)
Definition: dynamic_system_solver.cc:996
Solver
solver for contact equations
Definition: dynamic_system_solver.h:73
MBSimEnvironment * getMBSimEnvironment()
Definition: dynamic_system_solver.cc:1652
fmatvec::Vec zParent
state
Definition: dynamic_system_solver.h:686
fmatvec::Vec laParent
contact force parameters
Definition: dynamic_system_solver.h:654
fmatvec::Vec resParent
residuum of contact equations
Definition: dynamic_system_solver.h:669
bool velocityDriftCompensationNeeded(double gdmax)
check if drift compensation on velocity level is needed
Definition: dynamic_system_solver.cc:1025
fmatvec::Vec svParent
stopvector (rootfunctions for event driven integration
Definition: dynamic_system_solver.h:708
fmatvec::SqrMat Jprox
JACOBIAN of contact equations for Newton scheme.
Definition: dynamic_system_solver.h:734
fmatvec::Mat VParent[2]
condensed contact force directions
Definition: dynamic_system_solver.h:644
void updatezRef(fmatvec::Vec &ext)
references to external state
Definition: dynamic_system_solver.cc:1306
void writez(std::string fileName, bool formatH5=true)
writes state to a file
Definition: dynamic_system_solver.cc:1265
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: dynamic_system_solver.cc:107
int solveConstraintsRootFinding() override
solve contact equations with Newton scheme
Definition: dynamic_system_solver.cc:548
void decreaserFactors()
decrease relaxation factors if mass action matrix is not diagonal dominant
Definition: dynamic_system_solver.cc:990
void computeInitialCondition()
compute initial condition for links for event driven integrator
Definition: dynamic_system_solver.cc:848
bool READZ0
is a state read from a file
Definition: dynamic_system_solver.h:865
int solveImpactsRootFinding() override
solve impact equations with Newton scheme on velocity level
Definition: dynamic_system_solver.cc:615
void updategdRef(fmatvec::Vec &ref) override
references to relative velocities of dynamic system parent
Definition: dynamic_system_solver.h:539
virtual void updategdRef(fmatvec::Vec &gdParent)
references to relative velocities of dynamic system parent
Definition: dynamic_system.cc:776
fmatvec::Vec zdParent
differentiated state
Definition: dynamic_system_solver.h:691
Definition: dynamic_system_solver.h:414
namespace MBSim
Definition: bilateral_constraint.cc:29