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 getHighIter() {return highIter;}
270  int getIterC() {return iterc;}
271  int getIterI() {return iteri;}
272  /***************************************************/
273 
278 
284 
291 
298 
306 
311  virtual void updateG();
312 
316  void decreaserFactors();
317 
324  virtual const fmatvec::Vec& shift();
325 
330  void getLinkStatus(fmatvec::VecInt &LinkStatusExt);
331 
336  void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt);
337 
341  bool positionDriftCompensationNeeded(double gmax);
342 
346  bool velocityDriftCompensationNeeded(double gdmax);
347 
351  void projectGeneralizedPositions(int mode, bool fullUpdate=false);
352 
356  void projectGeneralizedVelocities(int mode);
357 
362  void savela();
363 
368  void initla();
369 
374  void saveLa();
375 
380  void initLa();
381 
386  void addElement(Element *element_);
387 
393  Element* getElement(const std::string &name);
394 
398  std::string getSolverInfo();
399 
404  void setStopIfNoConvergence(bool flag, bool dropInfo = false) { stopIfNoConvergence = flag; dropContactInfo=dropInfo; }
405 
406  bool getStopIfNoConvergence() { return stopIfNoConvergence; }
407 
411  void dropContactMatrices();
412 
413  // MBSim signal handler
414 #ifndef SWIG
416  public:
417  SignalHandler();
418  ~SignalHandler();
419  private:
420  #ifdef HAVE_ANSICSIGNAL
421  using SigHandle = void (*)(int);
422  SigHandle oldSigInt;
423  SigHandle oldSigTerm;
424  #endif
425  };
426 #endif
427 
431  static void sigInterruptHandler(int);
432 
433  void checkExitRequest();
434 
435  // TODO just for testing
436  void setPartialEventDrivenSolver(bool peds_) { peds = peds_; }
437 
443  void writez(std::string fileName, bool formatH5=true);
444 
450  void writeStateTable(std::string fileName);
451 
456  void readz0(std::string fileName);
457 
458  void initializeUsingXML(xercesc::DOMElement *element) override;
459 
464  void setProjectionTolerance(double tol) { tolProj = tol; }
465 
470  void setLocalSolverTolerance(double tol) { tolLocalSolver = tol; }
471  double getLocalSolverTolerance() { return tolLocalSolver; }
472 
477  void updatezRef(fmatvec::Vec &ext);
478 
483  void updatezdRef(fmatvec::Vec &ext);
484 
485  void setAlwaysConsiderContact(bool alwaysConsiderContact_) { alwaysConsiderContact = alwaysConsiderContact_; }
486 
487  void setInverseKinetics(bool inverseKinetics_) { inverseKinetics = inverseKinetics_; }
488  bool getInverseKinetics() const { return inverseKinetics; }
489 
490  void setInitialProjection(bool initialProjection_) { initialProjection = initialProjection_; }
491  bool getInitialProjection() const { return initialProjection; }
492 
493  void setDetermineEquilibriumState(bool determineEquilibriumState_) { determineEquilibriumState = determineEquilibriumState_; }
494  bool getDetermineEquilibriumState() const { return determineEquilibriumState; }
495 
496  void setUseConstraintSolverForSmoothMotion(bool useConstraintSolverForSmoothMotion_) { useConstraintSolverForSmoothMotion = useConstraintSolverForSmoothMotion_; }
497  bool getUseConstraintSolverForSmoothMotion() const { return useConstraintSolverForSmoothMotion; }
498 
499  void setUseConstraintSolverForPlot(bool useConstraintSolverForPlot_) { useConstraintSolverForPlot = useConstraintSolverForPlot_; }
500  bool getUseConstraintSolverForPlot() const { return useConstraintSolverForPlot; }
501 
502  fmatvec::Mat dhdq(int lb=0, int ub=0);
503  fmatvec::Mat dhdu(int lb=0, int ub=0);
504  fmatvec::Mat dhdx();
505  fmatvec::Vec dhdt();
506 
507  void setRootID(int ID) {rootID = ID;}
508  int getRootID() const {return rootID;}
509 
510  void resetUpToDate() override;
511 
512  bool getUpdateT() { return updT; }
513  bool getUpdateM() { return updM; }
514  bool getUpdateLLM() { return updLLM; }
515  bool getUpdateh(int j) { return updh[j]; }
516  bool getUpdater(int j) { return updr[j]; }
517  bool getUpdaterdt() { return updrdt; }
518  bool getUpdateW(int j) { return updW[j]; }
519  bool getUpdateV(int j) { return updV[j]; }
520  bool getUpdatewb() { return updwb; }
521  bool getUpdateg() { return updg; }
522  bool getUpdategd() { return updgd; }
523  bool getUpdatela() { return updla; }
524  bool getUpdateLa() { return updLa; }
525  bool getUpdatezd() { return updzd; }
526  bool getUpdatedq() { return upddq; }
527  bool getUpdatedu() { return upddu; }
528  bool getUpdatedx() { return upddx; }
529  void setUpdatela(bool updla_) { updla = updla_; }
530  void setUpdateLa(bool updLa_) { updLa = updLa_; }
531  void setUpdateG(bool updG_) { updG = updG_; }
532  void setUpdatebi(bool updbi_) { updbi = updbi_; }
533  void setUpdatebc(bool updbc_) { updbc = updbc_; }
534  void setUpdatezd(bool updzd_) { updzd = updzd_; }
535  void setUpdateW(bool updW_, int i=0) { updW[i] = updW_; }
536 
541  void updategRef(fmatvec::Vec &ref) override { Group::updategRef(ref); updg = true; }
542 
547  void updategdRef(fmatvec::Vec &ref) override { Group::updategdRef(ref); updgd = true; }
548 
553  void updatewbRef(fmatvec::Vec &ref) override { Group::updatewbRef(ref); updwb = true; }
554 
560  void updateWRef(fmatvec::Mat &ref, int i=0) override { Group::updateWRef(ref,i); updW[i] = true; }
561 
567  void updateVRef(fmatvec::Mat &ref, int i=0) override { Group::updateVRef(ref,i); updV[i] = true; }
568 
572  virtual void updatelaInverseKinetics();
573 
574  void updatedq() override;
575  void updatedu() override;
576  void updatedx() override;
577 
578  void updateStopVector() override;
579 
580  void updateInternalState();
581 
582  void plot() override;
583 
584  void addEnvironment(Environment* env);
585 
590  template<class Env>
591  Env* getEnvironment();
592 
596 
597  std::vector<StateTable>& getStateTable() { return tabz; }
598 
599  void setCompressionLevel(int level) { compressionLevel=level; }
600  void setChunkSize(int size) { chunkSize=size; }
601  void setCacheSize(int size) { cacheSize=size; }
602 
603  protected:
607  double t;
608 
612  double dt;
613 
617  int zSize;
618 
622  fmatvec::Vec z;
623 
627  fmatvec::Vec zd;
628 
632  fmatvec::SymMat MParent;
633 
637  fmatvec::SymMat LLMParent;
638 
642  fmatvec::Mat TParent;
643 
647  fmatvec::Mat WParent[2];
648 
652  fmatvec::Mat VParent[2];
653 
657  fmatvec::Vec wbParent;
658 
662  fmatvec::Vec laParent, LaParent;
663 
667  fmatvec::Vec rFactorParent;
668 
672  fmatvec::Vec sParent;
673 
677  fmatvec::Vec resParent;
678 
679  fmatvec::Vec curisParent, nextisParent;
680 
684  fmatvec::Vec gParent;
685 
689  fmatvec::Vec gdParent;
690 
694  fmatvec::Vec zParent;
695 
699  fmatvec::Vec zdParent;
700 
701  fmatvec::Vec dxParent, dqParent, duParent;
702 
706  fmatvec::Vec hParent[2];
707 
711  fmatvec::Vec rParent[2], rdtParent;
712 
716  fmatvec::Vec svParent;
717 
721  fmatvec::VecInt jsvParent;
722 
726  fmatvec::VecInt LinkStatusParent;
727 
732  fmatvec::VecInt LinkStatusRegParent;
733 
737  fmatvec::SparseMat Gs;
738 
742  fmatvec::SqrMat Jprox;
743 
747  fmatvec::SqrMat G;
748 
752  fmatvec::Vec bc, bi;
753 
757  bool term;
758 
762  int maxIter, highIter, maxDampingSteps, iterc, iteri;
763 
767  double lmParm;
768 
772  Solver contactSolver, impactSolver;
773 
778 
783 
787  bool useOldla;
788 
792  bool numJac;
793 
797  fmatvec::VecInt decreaseLevels;
798 
802  fmatvec::VecInt checkTermLevels;
803 
808 
813 
817  bool peds;
818 
822  double tolProj;
823 
827  double tolLocalSolver { 1e-10 };
828 
832  fmatvec::Vec laInverseKineticsParent;
833  fmatvec::Mat bInverseKineticsParent;
834 
838  fmatvec::Mat WInverseKineticsParent;
839 
840  bool alwaysConsiderContact;
841  bool inverseKinetics;
842  bool initialProjection;
843  bool determineEquilibriumState;
844  bool useConstraintSolverForSmoothMotion;
845  bool useConstraintSolverForPlot;
846 
847  fmatvec::Vec corrParent;
848 
849  int rootID;
850 
851  double gTol, gdTol, gddTol, laTol, LaTol;
852 
853  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;
854 
855  bool solveDirectly;
856 
857  std::vector<StateTable> tabz;
858 
859  int compressionLevel { H5::File::getDefaultCompression() };
860  int chunkSize { H5::File::getDefaultChunkSize() };
861  int cacheSize { H5::File::getDefaultCacheSize() };
862 
863  private:
867  void constructor();
868 
873 
877  static std::atomic<bool> exitRequest;
878  static_assert(decltype(exitRequest)::is_always_lock_free);
879 
883  bool READZ0;
884 
893  void addToGraph(Graph* graph, fmatvec::SqrMat &A, int i, std::vector<Element*> &objList);
894 
895  bool truncateSimulationFiles;
896 
897  // Holds the dynamic systems before the "reorganize hierarchy" takes place.
898  // This is required since all elements of all other containers from DynamicSystem are readded to DynamicSystemSolver,
899  // except this container (which is a "pure" container = no calculation is done in DynamicSystem)
900  // However, we must hold this container until the dtor of DynamicSystemSolver is called to avoid the deallocation of other
901  // elements hold by DynamicSystem elements (especially (currently only) hdf5File)
902  std::vector<DynamicSystem*> dynamicsystemPreReorganize;
903 
904  double facSizeGs;
905 
906  std::vector<std::unique_ptr<Environment>> environments;
907  MBSimEnvironment *mbsimEnvironment = nullptr;
908 
909  bool firstPlot { true };
910  };
911 
912  template<class Env>
914  // get the Environment of type Env
915  auto &reqType=typeid(Env);
916  for(auto &e : environments) {
917  auto &e_=*e;
918  if(reqType==typeid(e_))
919  return static_cast<Env*>(e.get());
920  }
921  auto newEnv=new Env;
922  addEnvironment(newEnv);
923  return newEnv;
924  }
925 
926 }
927 
928 #endif /* _DYNAMIC_SYSTEM_SOLVER_H_ */
bool useOldla
flag if contac force parameter of last time step should be used
Definition: dynamic_system_solver.h:787
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:521
int(DynamicSystemSolver::* solveConstraints_)()
Definition: dynamic_system_solver.h:283
int solveConstraintsLinearEquations()
solution of contact equations with Cholesky decomposition
Definition: dynamic_system_solver.cc:884
fmatvec::Vec gParent
relative distances
Definition: dynamic_system_solver.h:684
int zSize
size of state vector
Definition: dynamic_system_solver.h:617
double t
time
Definition: dynamic_system_solver.h:607
bool checkGSize
boolean if force action matrix should be resized in each step
Definition: dynamic_system_solver.h:807
int solveImpactsLinearEquations()
solution of contact equations with Cholesky decomposition on velocity level
Definition: dynamic_system_solver.cc:889
fmatvec::Vec rParent[2]
nonsmooth right hand side
Definition: dynamic_system_solver.h:711
int solveConstraintsGaussSeidel() override
solve contact equations with Gauss-Seidel scheme
Definition: dynamic_system_solver.cc:501
void initLa()
load contact impulses for use as starting value
Definition: dynamic_system_solver.cc:1154
bool term
boolean to check for termination of contact equations solution
Definition: dynamic_system_solver.h:757
void readz0(std::string fileName)
reads state from a file
Definition: dynamic_system_solver.cc:1295
Env * getEnvironment()
Definition: dynamic_system_solver.h:913
bool dropContactInfo
flag if contact matrices for debugging should be dropped in no-convergence case
Definition: dynamic_system_solver.h:782
int solveConstraintsFixpointSingle() override
solve contact equations with single step fixed point scheme
Definition: dynamic_system_solver.cc:441
double tolProj
Tolerance for projection of generalized position.
Definition: dynamic_system_solver.h:822
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:1144
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:737
fmatvec::VecInt checkTermLevels
TODO.
Definition: dynamic_system_solver.h:802
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:772
void updategRef(fmatvec::Vec &ref) override
references to relative distances of dynamic system parent
Definition: dynamic_system_solver.h:541
fmatvec::Vec bc
TODO.
Definition: dynamic_system_solver.h:752
bool stopIfNoConvergence
flag if the contact equations should be stopped if there is no convergence
Definition: dynamic_system_solver.h:777
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:567
fmatvec::Mat TParent
matrix of linear relation between differentiated positions and velocities
Definition: dynamic_system_solver.h:642
fmatvec::Vec sParent
TODO.
Definition: dynamic_system_solver.h:672
fmatvec::VecInt LinkStatusRegParent
status vector of single valued links
Definition: dynamic_system_solver.h:732
void setLocalSolverTolerance(double tol)
set tolerance for local none-linear solver, like the Newton-Solver in JointConstraint
Definition: dynamic_system_solver.h:470
Definition: environment.h:37
fmatvec::Vec zd
derivative of state vector
Definition: dynamic_system_solver.h:627
void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt)
Definition: dynamic_system_solver.cc:1001
void updateWRef(fmatvec::Mat &ref, int i=0) override
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system_solver.h:560
fmatvec::Vec gdParent
relative velocities
Definition: dynamic_system_solver.h:689
void projectGeneralizedVelocities(int mode)
drift projection for positions
Definition: dynamic_system_solver.cc:1099
fmatvec::VecInt LinkStatusParent
status vector of set valued links with piecewise link equation (which piece is valid)
Definition: dynamic_system_solver.h:726
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:684
std::string getSolverInfo()
Definition: dynamic_system_solver.cc:1198
fmatvec::Vec z
state vector
Definition: dynamic_system_solver.h:622
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:1248
double lmParm
Levenberg-Marquard parameter.
Definition: dynamic_system_solver.h:767
int solveImpactsFixpointSingle() override
solve impact equations with single step fixed point scheme on velocity level
Definition: dynamic_system_solver.cc:471
void addElement(Element *element_)
Definition: dynamic_system_solver.cc:1159
fmatvec::Vec rFactorParent
relaxation parameters for contact equations
Definition: dynamic_system_solver.h:667
void checkConstraintsForTermination() override
validate force laws concerning given tolerances
Definition: dynamic_system_solver.cc:673
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:797
virtual void updatelaInverseKinetics()
update inverse kinetics constraint forces
Definition: dynamic_system_solver.cc:1534
double tolLocalSolver
Tolerance for local none-linear solvers.
Definition: dynamic_system_solver.h:827
void setStopIfNoConvergence(bool flag, bool dropInfo=false)
Definition: dynamic_system_solver.h:404
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:798
void dropContactMatrices()
Definition: dynamic_system_solver.cc:1213
void updatezdRef(fmatvec::Vec &ext)
references to differentiated external state
Definition: dynamic_system_solver.cc:1315
void initialize()
Initialize the system.
Definition: dynamic_system_solver.cc:91
virtual void updateG()
updates mass action matrix
Definition: dynamic_system_solver.cc:894
~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:792
fmatvec::Mat WParent[2]
contact force directions
Definition: dynamic_system_solver.h:647
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:464
int(DynamicSystemSolver::* solveImpacts_)()
function pointer for election of prox-solver for impact equations on velocity level
Definition: dynamic_system_solver.h:290
Element * getElement(const std::string &name)
Definition: dynamic_system_solver.cc:1171
bool positionDriftCompensationNeeded(double gmax)
check if drift compensation on position level is needed
Definition: dynamic_system_solver.cc:1009
fmatvec::VecInt jsvParent
boolean evaluation of stopvector
Definition: dynamic_system_solver.h:721
void savela()
save contact forces for use as starting value in next time step
Definition: dynamic_system_solver.cc:1139
Definition: contact_kinematics.h:32
void projectGeneralizedPositions(int mode, bool fullUpdate=false)
drift projection for positions
Definition: dynamic_system_solver.cc:1035
fmatvec::SymMat LLMParent
Cholesky decomposition of mass matrix.
Definition: dynamic_system_solver.h:637
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:877
int limitGSize
TODO.
Definition: dynamic_system_solver.h:812
fmatvec::SymMat MParent
mass matrix
Definition: dynamic_system_solver.h:632
bool peds
TODO, flag for occuring impact and sticking in event driven solver.
Definition: dynamic_system_solver.h:817
fmatvec::Vec hParent[2]
smooth, smooth with respect to objects, smooth with respect to links right hand side
Definition: dynamic_system_solver.h:706
void writeStateTable(std::string fileName)
writes state table to a file
Definition: dynamic_system_solver.cc:1284
void constructor()
set plot feature default values
Definition: dynamic_system_solver.cc:1329
fmatvec::SqrMat G
mass action matrix
Definition: dynamic_system_solver.h:747
double dt
step size
Definition: dynamic_system_solver.h:612
void saveLa()
save contact impulses for use as starting value in next time step
Definition: dynamic_system_solver.cc:1149
bool integratorExitRequest
boolean signal evaluation for end integration set by program
Definition: dynamic_system_solver.h:872
fmatvec::Vec wbParent
TODO.
Definition: dynamic_system_solver.h:657
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:553
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:762
void getLinkStatus(fmatvec::VecInt &LinkStatusExt)
Definition: dynamic_system_solver.cc:993
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:694
fmatvec::Vec laParent
contact force parameters
Definition: dynamic_system_solver.h:662
fmatvec::Vec resParent
residuum of contact equations
Definition: dynamic_system_solver.h:677
bool velocityDriftCompensationNeeded(double gdmax)
check if drift compensation on velocity level is needed
Definition: dynamic_system_solver.cc:1022
fmatvec::Vec svParent
stopvector (rootfunctions for event driven integration
Definition: dynamic_system_solver.h:716
fmatvec::SqrMat Jprox
JACOBIAN of contact equations for Newton scheme.
Definition: dynamic_system_solver.h:742
fmatvec::Mat VParent[2]
condensed contact force directions
Definition: dynamic_system_solver.h:652
void updatezRef(fmatvec::Vec &ext)
references to external state
Definition: dynamic_system_solver.cc:1303
void writez(std::string fileName, bool formatH5=true)
writes state to a file
Definition: dynamic_system_solver.cc:1262
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:541
void decreaserFactors()
decrease relaxation factors if mass action matrix is not diagonal dominant
Definition: dynamic_system_solver.cc:987
void computeInitialCondition()
compute initial condition for links for event driven integrator
Definition: dynamic_system_solver.cc:841
bool READZ0
is a state read from a file
Definition: dynamic_system_solver.h:878
int solveImpactsRootFinding() override
solve impact equations with Newton scheme on velocity level
Definition: dynamic_system_solver.cc:608
void updategdRef(fmatvec::Vec &ref) override
references to relative velocities of dynamic system parent
Definition: dynamic_system_solver.h:547
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:699
Definition: dynamic_system_solver.h:415
namespace MBSim
Definition: bilateral_constraint.cc:30