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 
408  void dropContactMatrices();
409 
410  // MBSim signal handler
411 #ifndef SWIG
413  public:
414  SignalHandler();
415  ~SignalHandler();
416  private:
417  #ifdef HAVE_ANSICSIGNAL
418  using SigHandle = void (*)(int);
419  SigHandle oldSigInt;
420  SigHandle oldSigTerm;
421  #endif
422  };
423 #endif
424 
428  static void sigInterruptHandler(int);
429 
430  void checkExitRequest();
431 
432  // TODO just for testing
433  void setPartialEventDrivenSolver(bool peds_) { peds = peds_; }
434 
440  void writez(std::string fileName, bool formatH5=true);
441 
447  void writeStateTable(std::string fileName);
448 
453  void readz0(std::string fileName);
454 
455  void initializeUsingXML(xercesc::DOMElement *element) override;
456 
461  void setProjectionTolerance(double tol) { tolProj = tol; }
462 
467  void updatezRef(fmatvec::Vec &ext);
468 
473  void updatezdRef(fmatvec::Vec &ext);
474 
475  void setAlwaysConsiderContact(bool alwaysConsiderContact_) { alwaysConsiderContact = alwaysConsiderContact_; }
476 
477  void setInverseKinetics(bool inverseKinetics_) { inverseKinetics = inverseKinetics_; }
478  bool getInverseKinetics() const { return inverseKinetics; }
479 
480  void setInitialProjection(bool initialProjection_) { initialProjection = initialProjection_; }
481  bool getInitialProjection() const { return initialProjection; }
482 
483  void setDetermineEquilibriumState(bool determineEquilibriumState_) { determineEquilibriumState = determineEquilibriumState_; }
484  bool getDetermineEquilibriumState() const { return determineEquilibriumState; }
485 
486  void setUseConstraintSolverForSmoothMotion(bool useConstraintSolverForSmoothMotion_) { useConstraintSolverForSmoothMotion = useConstraintSolverForSmoothMotion_; }
487  bool getUseConstraintSolverForSmoothMotion() const { return useConstraintSolverForSmoothMotion; }
488 
489  void setUseConstraintSolverForPlot(bool useConstraintSolverForPlot_) { useConstraintSolverForPlot = useConstraintSolverForPlot_; }
490  bool getUseConstraintSolverForPlot() const { return useConstraintSolverForPlot; }
491 
492  fmatvec::Mat dhdq(int lb=0, int ub=0);
493  fmatvec::Mat dhdu(int lb=0, int ub=0);
494  fmatvec::Mat dhdx();
495  fmatvec::Vec dhdt();
496 
497  void setRootID(int ID) {rootID = ID;}
498  int getRootID() const {return rootID;}
499 
500  void resetUpToDate() override;
501 
502  bool getUpdateT() { return updT; }
503  bool getUpdateM() { return updM; }
504  bool getUpdateLLM() { return updLLM; }
505  bool getUpdateh(int j) { return updh[j]; }
506  bool getUpdater(int j) { return updr[j]; }
507  bool getUpdaterdt() { return updrdt; }
508  bool getUpdateW(int j) { return updW[j]; }
509  bool getUpdateV(int j) { return updV[j]; }
510  bool getUpdatewb() { return updwb; }
511  bool getUpdateg() { return updg; }
512  bool getUpdategd() { return updgd; }
513  bool getUpdatela() { return updla; }
514  bool getUpdateLa() { return updLa; }
515  bool getUpdatezd() { return updzd; }
516  bool getUpdatedq() { return upddq; }
517  bool getUpdatedu() { return upddu; }
518  bool getUpdatedx() { return upddx; }
519  void setUpdatela(bool updla_) { updla = updla_; }
520  void setUpdateLa(bool updLa_) { updLa = updLa_; }
521  void setUpdateG(bool updG_) { updG = updG_; }
522  void setUpdatebi(bool updbi_) { updbi = updbi_; }
523  void setUpdatebc(bool updbc_) { updbc = updbc_; }
524  void setUpdatezd(bool updzd_) { updzd = updzd_; }
525  void setUpdateW(bool updW_, int i=0) { updW[i] = updW_; }
526 
531  void updategRef(fmatvec::Vec &ref) override { Group::updategRef(ref); updg = true; }
532 
537  void updategdRef(fmatvec::Vec &ref) override { Group::updategdRef(ref); updgd = true; }
538 
543  void updatewbRef(fmatvec::Vec &ref) override { Group::updatewbRef(ref); updwb = true; }
544 
550  void updateWRef(fmatvec::Mat &ref, int i=0) override { Group::updateWRef(ref,i); updW[i] = true; }
551 
557  void updateVRef(fmatvec::Mat &ref, int i=0) override { Group::updateVRef(ref,i); updV[i] = true; }
558 
562  virtual void updatelaInverseKinetics();
563 
564  void updatedq() override;
565  void updatedu() override;
566  void updatedx() override;
567 
568  void updateStopVector() override;
569 
570  void updateInternalState();
571 
572  void plot() override;
573 
574  void addEnvironment(Environment* env);
575 
580  template<class Env>
581  Env* getEnvironment();
582 
586 
587  std::vector<StateTable>& getStateTable() { return tabz; }
588 
589  protected:
593  double t;
594 
598  double dt;
599 
603  int zSize;
604 
608  fmatvec::Vec z;
609 
613  fmatvec::Vec zd;
614 
618  fmatvec::SymMat MParent;
619 
623  fmatvec::SymMat LLMParent;
624 
628  fmatvec::Mat TParent;
629 
633  fmatvec::Mat WParent[2];
634 
638  fmatvec::Mat VParent[2];
639 
643  fmatvec::Vec wbParent;
644 
648  fmatvec::Vec laParent, LaParent;
649 
653  fmatvec::Vec rFactorParent;
654 
658  fmatvec::Vec sParent;
659 
663  fmatvec::Vec resParent;
664 
665  fmatvec::Vec curisParent, nextisParent;
666 
670  fmatvec::Vec gParent;
671 
675  fmatvec::Vec gdParent;
676 
680  fmatvec::Vec zParent;
681 
685  fmatvec::Vec zdParent;
686 
687  fmatvec::Vec dxParent, dqParent, duParent;
688 
692  fmatvec::Vec hParent[2];
693 
697  fmatvec::Vec rParent[2], rdtParent;
698 
702  fmatvec::Vec svParent;
703 
707  fmatvec::VecInt jsvParent;
708 
712  fmatvec::VecInt LinkStatusParent;
713 
718  fmatvec::VecInt LinkStatusRegParent;
719 
723  fmatvec::SparseMat Gs;
724 
728  fmatvec::SqrMat Jprox;
729 
733  fmatvec::SqrMat G;
734 
738  fmatvec::Vec bc, bi;
739 
743  bool term;
744 
748  int maxIter, highIter, maxDampingSteps, iterc, iteri;
749 
753  double lmParm;
754 
758  Solver contactSolver, impactSolver;
759 
764 
769 
773  bool useOldla;
774 
778  bool numJac;
779 
783  fmatvec::VecInt decreaseLevels;
784 
788  fmatvec::VecInt checkTermLevels;
789 
794 
799 
803  bool peds;
804 
808  double tolProj;
809 
813  fmatvec::Vec laInverseKineticsParent;
814  fmatvec::Mat bInverseKineticsParent;
815 
819  fmatvec::Mat WInverseKineticsParent;
820 
821  bool alwaysConsiderContact;
822  bool inverseKinetics;
823  bool initialProjection;
824  bool determineEquilibriumState;
825  bool useConstraintSolverForSmoothMotion;
826  bool useConstraintSolverForPlot;
827 
828  fmatvec::Vec corrParent;
829 
830  int rootID;
831 
832  double gTol, gdTol, gddTol, laTol, LaTol;
833 
834  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;
835 
836  bool solveDirectly;
837 
838  std::vector<StateTable> tabz;
839 
840  private:
844  void constructor();
845 
850 
854  static std::atomic<bool> exitRequest;
855  static_assert(decltype(exitRequest)::is_always_lock_free);
856 
860  bool READZ0;
861 
870  void addToGraph(Graph* graph, fmatvec::SqrMat &A, int i, std::vector<Element*> &objList);
871 
872  bool truncateSimulationFiles;
873 
874  // Holds the dynamic systems before the "reorganize hierarchy" takes place.
875  // This is required since all elements of all other containers from DynamicSystem are readded to DynamicSystemSolver,
876  // except this container (which is a "pure" container = no calculation is done in DynamicSystem)
877  // However, we must hold this container until the dtor of DynamicSystemSolver is called to avoid the deallocation of other
878  // elements hold by DynamicSystem elements (especially (currently only) hdf5File)
879  std::vector<DynamicSystem*> dynamicsystemPreReorganize;
880 
881  double facSizeGs;
882 
883  std::vector<std::unique_ptr<Environment>> environments;
884  MBSimEnvironment *mbsimEnvironment = nullptr;
885 
886  bool firstPlot { true };
887  };
888 
889  template<class Env>
891  // get the Environment of type Env
892  auto &reqType=typeid(Env);
893  for(auto &e : environments) {
894  auto &e_=*e;
895  if(reqType==typeid(e_))
896  return static_cast<Env*>(e.get());
897  }
898  auto newEnv=new Env;
899  addEnvironment(newEnv);
900  return newEnv;
901  }
902 
903 }
904 
905 #endif /* _DYNAMIC_SYSTEM_SOLVER_H_ */
bool useOldla
flag if contac force parameter of last time step should be used
Definition: dynamic_system_solver.h:773
Definition: dynamic_system_solver.h:35
void plot() override
plots time dependent data
Definition: dynamic_system_solver.cc:1580
int solveImpactsGaussSeidel() override
solve impact equations with Gauss-Seidel scheme on velocity level
Definition: dynamic_system_solver.cc:518
int(DynamicSystemSolver::* solveConstraints_)()
Definition: dynamic_system_solver.h:282
int solveConstraintsLinearEquations()
solution of contact equations with Cholesky decomposition
Definition: dynamic_system_solver.cc:877
fmatvec::Vec gParent
relative distances
Definition: dynamic_system_solver.h:670
int zSize
size of state vector
Definition: dynamic_system_solver.h:603
double t
time
Definition: dynamic_system_solver.h:593
bool checkGSize
boolean if force action matrix should be resized in each step
Definition: dynamic_system_solver.h:793
int solveImpactsLinearEquations()
solution of contact equations with Cholesky decomposition on velocity level
Definition: dynamic_system_solver.cc:882
fmatvec::Vec rParent[2]
nonsmooth right hand side
Definition: dynamic_system_solver.h:697
int solveConstraintsGaussSeidel() override
solve contact equations with Gauss-Seidel scheme
Definition: dynamic_system_solver.cc:498
void initLa()
load contact impulses for use as starting value
Definition: dynamic_system_solver.cc:1134
bool term
boolean to check for termination of contact equations solution
Definition: dynamic_system_solver.h:743
void readz0(std::string fileName)
reads state from a file
Definition: dynamic_system_solver.cc:1275
Env * getEnvironment()
Definition: dynamic_system_solver.h:890
bool dropContactInfo
flag if contact matrices for debugging should be dropped in no-convergence case
Definition: dynamic_system_solver.h:768
int solveConstraintsFixpointSingle() override
solve contact equations with single step fixed point scheme
Definition: dynamic_system_solver.cc:436
double tolProj
Tolerance for projection of generalized position.
Definition: dynamic_system_solver.h:808
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:1124
virtual void updateVRef(fmatvec::Mat &VParent, int j=0)
references to condensed contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:828
fmatvec::SparseMat Gs
sparse mass action matrix
Definition: dynamic_system_solver.h:723
fmatvec::VecInt checkTermLevels
TODO.
Definition: dynamic_system_solver.h:788
DynamicSystemSolver(const std::string &name="")
constructor
Definition: dynamic_system_solver.cc:72
Solver contactSolver
solver for contact equations and impact equations
Definition: dynamic_system_solver.h:758
void updategRef(fmatvec::Vec &ref) override
references to relative distances of dynamic system parent
Definition: dynamic_system_solver.h:531
fmatvec::Vec bc
TODO.
Definition: dynamic_system_solver.h:738
bool stopIfNoConvergence
flag if the contact equations should be stopped if there is no convergence
Definition: dynamic_system_solver.h:763
virtual const fmatvec::Vec & shift()
update for event driven integrator for event
Definition: dynamic_system_solver.cc:1414
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:557
fmatvec::Mat TParent
matrix of linear relation between differentiated positions and velocities
Definition: dynamic_system_solver.h:628
fmatvec::Vec sParent
TODO.
Definition: dynamic_system_solver.h:658
fmatvec::VecInt LinkStatusRegParent
status vector of single valued links
Definition: dynamic_system_solver.h:718
Definition: environment.h:37
fmatvec::Vec zd
derivative of state vector
Definition: dynamic_system_solver.h:613
void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt)
Definition: dynamic_system_solver.cc:994
void updateWRef(fmatvec::Mat &ref, int i=0) override
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system_solver.h:550
fmatvec::Vec gdParent
relative velocities
Definition: dynamic_system_solver.h:675
void projectGeneralizedVelocities(int mode)
drift projection for positions
Definition: dynamic_system_solver.cc:1081
fmatvec::VecInt LinkStatusParent
status vector of set valued links with piecewise link equation (which piece is valid)
Definition: dynamic_system_solver.h:712
virtual void updatewbRef(fmatvec::Vec &wbParent)
references to TODO of dynamic system parent
Definition: dynamic_system.cc:800
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:681
std::string getSolverInfo()
Definition: dynamic_system_solver.cc:1178
fmatvec::Vec z
state vector
Definition: dynamic_system_solver.h:608
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:1228
double lmParm
Levenberg-Marquard parameter.
Definition: dynamic_system_solver.h:753
int solveImpactsFixpointSingle() override
solve impact equations with single step fixed point scheme on velocity level
Definition: dynamic_system_solver.cc:467
void addElement(Element *element_)
Definition: dynamic_system_solver.cc:1139
fmatvec::Vec rFactorParent
relaxation parameters for contact equations
Definition: dynamic_system_solver.h:653
void checkConstraintsForTermination() override
validate force laws concerning given tolerances
Definition: dynamic_system_solver.cc:670
virtual void updateWRef(fmatvec::Mat &WParent, int j=0)
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:807
fmatvec::VecInt decreaseLevels
decreasing relaxation factors is done in levels containing the number of contact iterations as condit...
Definition: dynamic_system_solver.h:783
virtual void updatelaInverseKinetics()
update inverse kinetics constraint forces
Definition: dynamic_system_solver.cc:1505
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:795
void dropContactMatrices()
Definition: dynamic_system_solver.cc:1193
void updatezdRef(fmatvec::Vec &ext)
references to differentiated external state
Definition: dynamic_system_solver.cc:1295
void initialize()
Initialize the system.
Definition: dynamic_system_solver.cc:90
virtual void updateG()
updates mass action matrix
Definition: dynamic_system_solver.cc:887
~DynamicSystemSolver() override
destructor
Definition: dynamic_system_solver.cc:82
bool numJac
flag if Jacobian for Newton scheme should be calculated numerically
Definition: dynamic_system_solver.h:778
fmatvec::Mat WParent[2]
contact force directions
Definition: dynamic_system_solver.h:633
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:461
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:1151
bool positionDriftCompensationNeeded(double gmax)
check if drift compensation on position level is needed
Definition: dynamic_system_solver.cc:1002
fmatvec::VecInt jsvParent
boolean evaluation of stopvector
Definition: dynamic_system_solver.h:707
void savela()
save contact forces for use as starting value in next time step
Definition: dynamic_system_solver.cc:1119
Definition: contact_kinematics.h:32
void projectGeneralizedPositions(int mode, bool fullUpdate=false)
drift projection for positions
Definition: dynamic_system_solver.cc:1028
fmatvec::SymMat LLMParent
Cholesky decomposition of mass matrix.
Definition: dynamic_system_solver.h:623
std::string name
name of element
Definition: element.h:251
static std::atomic< bool > exitRequest
boolean signal evaluation for end integration set by user
Definition: dynamic_system_solver.h:854
int limitGSize
TODO.
Definition: dynamic_system_solver.h:798
fmatvec::SymMat MParent
mass matrix
Definition: dynamic_system_solver.h:618
bool peds
TODO, flag for occuring impact and sticking in event driven solver.
Definition: dynamic_system_solver.h:803
fmatvec::Vec hParent[2]
smooth, smooth with respect to objects, smooth with respect to links right hand side
Definition: dynamic_system_solver.h:692
void writeStateTable(std::string fileName)
writes state table to a file
Definition: dynamic_system_solver.cc:1264
void constructor()
set plot feature default values
Definition: dynamic_system_solver.cc:1309
fmatvec::SqrMat G
mass action matrix
Definition: dynamic_system_solver.h:733
double dt
step size
Definition: dynamic_system_solver.h:598
void saveLa()
save contact impulses for use as starting value in next time step
Definition: dynamic_system_solver.cc:1129
bool integratorExitRequest
boolean signal evaluation for end integration set by program
Definition: dynamic_system_solver.h:849
fmatvec::Vec wbParent
TODO.
Definition: dynamic_system_solver.h:643
void addToGraph(Graph *graph, fmatvec::SqrMat &A, int i, std::vector< Element * > &objList)
adds list of objects to tree
Definition: dynamic_system_solver.cc:1401
virtual void updategRef(fmatvec::Vec &gParent)
references to relative distances of dynamic system parent
Definition: dynamic_system.cc:765
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: dynamic_system_solver.h:543
fmatvec::Vec la
contact force parameters
Definition: dynamic_system.h:856
int maxIter
maximum number of contact iterations, high number of contact iterations for warnings,...
Definition: dynamic_system_solver.h:748
void getLinkStatus(fmatvec::VecInt &LinkStatusExt)
Definition: dynamic_system_solver.cc:986
Solver
solver for contact equations
Definition: dynamic_system_solver.h:73
MBSimEnvironment * getMBSimEnvironment()
Definition: dynamic_system_solver.cc:1622
fmatvec::Vec zParent
state
Definition: dynamic_system_solver.h:680
fmatvec::Vec laParent
contact force parameters
Definition: dynamic_system_solver.h:648
fmatvec::Vec resParent
residuum of contact equations
Definition: dynamic_system_solver.h:663
bool velocityDriftCompensationNeeded(double gdmax)
check if drift compensation on velocity level is needed
Definition: dynamic_system_solver.cc:1015
fmatvec::Vec svParent
stopvector (rootfunctions for event driven integration
Definition: dynamic_system_solver.h:702
fmatvec::SqrMat Jprox
JACOBIAN of contact equations for Newton scheme.
Definition: dynamic_system_solver.h:728
fmatvec::Mat VParent[2]
condensed contact force directions
Definition: dynamic_system_solver.h:638
void updatezRef(fmatvec::Vec &ext)
references to external state
Definition: dynamic_system_solver.cc:1283
void writez(std::string fileName, bool formatH5=true)
writes state to a file
Definition: dynamic_system_solver.cc:1242
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: dynamic_system_solver.cc:106
int solveConstraintsRootFinding() override
solve contact equations with Newton scheme
Definition: dynamic_system_solver.cc:538
void decreaserFactors()
decrease relaxation factors if mass action matrix is not diagonal dominant
Definition: dynamic_system_solver.cc:980
void computeInitialCondition()
compute initial condition for links for event driven integrator
Definition: dynamic_system_solver.cc:838
bool READZ0
is a state read from a file
Definition: dynamic_system_solver.h:855
int solveImpactsRootFinding() override
solve impact equations with Newton scheme on velocity level
Definition: dynamic_system_solver.cc:605
void updategdRef(fmatvec::Vec &ref) override
references to relative velocities of dynamic system parent
Definition: dynamic_system_solver.h:537
virtual void updategdRef(fmatvec::Vec &gdParent)
references to relative velocities of dynamic system parent
Definition: dynamic_system.cc:772
fmatvec::Vec zdParent
differentiated state
Definition: dynamic_system_solver.h:685
Definition: dynamic_system_solver.h:412
namespace MBSim
Definition: bilateral_constraint.cc:29