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
30namespace MBSim {
31
32 class Graph;
33 class MBSimEnvironment;
34 class MultiDimNewtonMethod;
35 class ConstraintResiduum;
36 class ConstraintJacobian;
37
38 struct StateTable {
39 std::string name;
40 char label;
41 int number;
42 StateTable() = default;
43 StateTable(const std::string &name_, char label_, int number_) : name(name_), label(label_), number(number_) { }
44 };
45
61 class DynamicSystemSolver : public Group {
62
63 class Residuum : public MBSim::Function<fmatvec::Vec(fmatvec::Vec)> {
64 public:
65 Residuum(MBSim::DynamicSystemSolver *sys_) : sys(sys_) { }
66 fmatvec::Vec operator()(const fmatvec::Vec &z);
67 private:
69 };
70
71 public:
72
76 enum Solver { fixedpoint, GaussSeidel, direct, rootfinding, unknownSolver, directNonlinear };
77
82 DynamicSystemSolver(const std::string &name="");
83
87 ~DynamicSystemSolver() override;
88
127 void initialize();
128
129 /*
130 * If true (the default) then
131 * the simulation output files (h5 files) are deleted/truncated/regenerated.
132 * If false, then these files left are untouched from a previous run.
133 * This is useful to regenerate the
134 * e.g. OpenMBV XML files without doing a new integration.
135 */
136 void setTruncateSimulationFiles(bool trunc) { truncateSimulationFiles=trunc; }
137
139 void setEmbedOmbvxInH5(bool flag) { embedOmbvxInH5=flag; }
140
141 /* INHERITED INTERFACE OF GROUP */
142 void init(InitStage stage, const InitConfigSet &config) override;
143 using Group::plot;
144 /***************************************************/
145
146 /* INHERITED INTERFACE OF DYNAMICSYSTEM */
147 int solveConstraintsFixpointSingle() override;
148 int solveImpactsFixpointSingle() override;
149 int solveConstraintsGaussSeidel() override;
150 int solveImpactsGaussSeidel() override;
151 int solveConstraintsRootFinding() override;
152 int solveImpactsRootFinding() override;
153 void checkConstraintsForTermination() override;
154 void checkImpactsForTermination() override;
155 /***************************************************/
156
157 /* INHERITED INTERFACE OF OBJECTINTERFACE */
158 void updateT() override;
159 void updateh(int i=0) override;
160 void updateM() override;
161 void updateLLM() override;
162 void updatezd() override;
163 /***************************************************/
164
165 /* INHERITED INTERFACE OF LINKINTERFACE */
166
177 void updater(int j=0) override;
178 void updateJrla(int j=0) override;
179 virtual void updaterdt();
180 void updatewb() override;
181 void updateg() override;
182 void updategd() override;
183 void updateW(int j=0) override;
184 void updateV(int j=0) override;
185 virtual void updatebc();
186 virtual void updatebi();
187 virtual void updatela();
188 virtual void updateLa();
189 /***************************************************/
190
191 /* INHERITED INTERFACE OF ELEMENT */
192 /***************************************************/
193
194 /* GETTER / SETTER */
195
196 void setSmoothSolver(Solver solver_) { smoothSolver = solver_; }
197 void setConstraintSolver(Solver solver_) { contactSolver = solver_; }
198 void setImpactSolver(Solver solver_) { impactSolver = solver_; }
199 const Solver& getSmoothSolver() { return smoothSolver; }
200 const Solver& getConstraintSolver() { return contactSolver; }
201 const Solver& getImpactSolver() { return impactSolver; }
202 void setTermination(bool term_) { term = term_; }
203 void setMaximumNumberOfIterations(int iter) { maxIter = iter; }
204 void setHighNumberOfIterations(int iter) { highIter = iter; }
205 void setNumericalJacobian(bool numJac_) { numJac = numJac_; }
206 void setMaximumDampingSteps(int maxDSteps) { maxDampingSteps = maxDSteps; }
207 void setLevenbergMarquardtParamater(double lmParm_) { lmParm = lmParm_; }
208
209 void setUseOldla(bool flag) { useOldla = flag; }
210 void setDecreaseLevels(const fmatvec::VecInt &decreaseLevels_) { decreaseLevels = decreaseLevels_; }
211 void setCheckTermLevels(const fmatvec::VecInt &checkTermLevels_) { checkTermLevels = checkTermLevels_; }
212 void setCheckGSize(bool checkGSize_) { checkGSize = checkGSize_; }
213 void setLimitGSize(int limitGSize_) { limitGSize = limitGSize_; checkGSize = false; }
214
215 double& getTime() { return t; }
216 const double& getTime() const { return t; }
217 void setTime(double t_) { t = t_; }
218
219 double getStepSize() const { return dt; }
220 void setStepSize(double dt_) { dt = dt_; }
221
222 int getzSize() const { return zSize; }
223
224 fmatvec::Vec& getState() { return z; }
225 const fmatvec::Vec& getState() const { return z; }
226 void setState(const fmatvec::Vec &z_) { z = z_; }
227
228 const fmatvec::Vec& getzd(bool check=true) const { assert((not check) or (not updzd)); return zd; }
229 void setzd(const fmatvec::Vec &zd_) { zd = zd_; }
230
231 const fmatvec::SqrMat& getG(bool check=true) const { assert((not check) or (not updG)); return G; }
232 const fmatvec::SparseMat& getGs(bool check=true) const { assert((not check) or (not updG)); return Gs; }
233 const fmatvec::Vec& getbc(bool check=true) const { assert((not check) or (not updbc)); return bc; }
234 const fmatvec::Vec& getbi(bool check=true) const { assert((not check) or (not updbi)); return bi; }
235 const fmatvec::SqrMat& getJprox() const { return Jprox; }
236 fmatvec::SqrMat& getG(bool check=true) { assert((not check) or (not updG)); return G; }
237 fmatvec::SparseMat& getGs(bool check=true) { assert((not check) or (not updG)); return Gs; }
238 fmatvec::Vec& getbc(bool check=true) { assert((not check) or (not updbc)); return bc; }
239 fmatvec::Vec& getbi(bool check=true) { assert((not check) or (not updbi)); return bi; }
240 fmatvec::SqrMat& getJprox() { return Jprox; }
241 const fmatvec::Vec& getr(int j=0, bool check=true) const { assert((not check) or (not updr[j])); return r[j]; }
242 fmatvec::Vec& getr(int j=0, bool check=true) { assert((not check) or (not updr[j])); return r[j]; }
243
244 // Jacobian of dr/dla
245 const fmatvec::Mat& getJrla(int j=0, bool check=true) const { assert((not check) or (not updJrla[j])); return Jrla[j]; }
246 fmatvec::Mat& getJrla(int j=0, bool check=true) { assert((not check) or (not updJrla[j])); return Jrla[j]; }
247
248 const fmatvec::Vec& evaldq() { if(upddq) updatedq(); return dq; }
249 const fmatvec::Vec& evaldu() { if(upddu) updatedu(); return du; }
250 const fmatvec::Vec& evaldx() { if(upddx) updatedx(); return dx; }
251 const fmatvec::Vec& evalzd();
252 const fmatvec::SqrMat& evalG() { if(updG) updateG(); return G; }
253 const fmatvec::SparseMat& evalGs() { if(updG) updateG(); return Gs; }
254 const fmatvec::Vec& evalbc() { if(updbc) updatebc(); return bc; }
255 const fmatvec::Vec& evalbi() { if(updbi) updatebi(); return bi; }
256 const fmatvec::Vec& evalsv();
257 const fmatvec::Vec& evalz0();
258 const fmatvec::Vec& evalla() { if(updla) updatela(); return la; }
259 const fmatvec::Vec& evalLa() { if(updLa) updateLa(); return La; }
260
261 fmatvec::Vec& getzParent() { return zParent; }
262 fmatvec::Vec& getzdParent() { return zdParent; }
263 fmatvec::Vec& getlaParent() { return laParent; }
264 fmatvec::Vec& getLaParent() { return LaParent; }
265// const fmatvec::Vec& getzParent() const { return zParent; }
266// const fmatvec::Vec& getzdParent() const { return zdParent; }
267// const fmatvec::Mat& getWParent(int i=0) const { return WParent[i]; }
268 fmatvec::Mat& getWParent(int i=0) { return WParent[i]; }
269 fmatvec::Mat& getVParent(int i=0) { return VParent[i]; }
270// fmatvec::Vec& getlaParent() { return laParent; }
271// fmatvec::Vec& getLaParent() { return LaParent; }
272// const fmatvec::Vec& getgParent() const { return gParent; }
273 fmatvec::Vec& getgParent() { return gParent; }
274// const fmatvec::Vec& getgdParent() const { return gdParent; }
275 fmatvec::Vec& getgdParent() { return gdParent; }
276 fmatvec::Vec& getresParent() { return resParent; }
277 fmatvec::Vec& getrFactorParent() { return rFactorParent; }
278
279 void resizezParent(int nz) { zParent.resize(nz); }
280 void resizezdParent(int nz) { zdParent.resize(nz); }
281
282 DynamicSystemSolver* getDynamicSystemSolver() { return this; }
283 int getMaxIter() {return maxIter;}
284 int getHighIter() {return highIter;}
285 int getIterC() {return iterc;}
286 int getIterI() {return iteri;}
287 /***************************************************/
288
293
294 int (DynamicSystemSolver::*solveSmooth_)();
295
301
308
315
322
330
331 int solveImpactsNonlinearEquations();
332
337 virtual void updateG();
338
342 void decreaserFactors();
343
350 virtual const fmatvec::Vec& shift(std::optional<std::reference_wrapper<bool>> &&velProjWasCalled={},
351 std::optional<std::reference_wrapper<bool>> &&posProjWasCalled={});
352
357 void getLinkStatus(fmatvec::VecInt &LinkStatusExt);
358
363 void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt);
364
368 bool positionDriftCompensationNeeded(double gmax);
369
373 bool velocityDriftCompensationNeeded(double gdmax);
374
378 void projectGeneralizedPositions(int mode, bool fullUpdate=false);
379
383 void projectGeneralizedVelocities(int mode);
384
389 void savela();
390
395 void initla();
396
401 void saveLa();
402
407 void initLa();
408
413 void addElement(Element *element_);
414
420 Element* getElement(const std::string &name);
421
425 std::string getSolverInfo();
426
431 void setStopIfNoConvergence(bool flag, bool dropInfo = false) { stopIfNoConvergence = flag; dropContactInfo=dropInfo; }
432
433 bool getStopIfNoConvergence() { return stopIfNoConvergence; }
434
438 void dropContactMatrices();
439
440 // MBSim signal handler
441#ifndef SWIG
443 public:
444 // This resets the DSS flags exitRequest and silentExit to false
447 private:
448 using SigHandle = void (*)(int);
449 #ifndef _WIN32
450 SigHandle oldSigHup;
451 #endif
452 SigHandle oldSigInt;
453 SigHandle oldSigTerm;
454 };
455#endif
456
457 // This function should be called repeatetly in mbsim, at least in heavy work parts of the code.
458 // If the DSS exitRequest flag is set a error message is printed and a std::runtime_error exception is thrown to interrupt.
459 // If silent is true or the DSS silentExit flag is set then not message is printed and a SilentError is thrown.
460 static void throwIfExitRequested(bool silent=false) {
461 if(exitRequest) {
462 if(!silent && !silentExit) {
463 msgStatic(fmatvec::Atom::Error)<<"User requested a exit (throw exception now)."<<std::endl;
464 throw std::runtime_error("Exception due to user requested exit.");
465 }
466 msgStatic(fmatvec::Atom::Info)<<"User requested a silent exit (throw exception now)."<<std::endl;
467 throw SilentError();
468 }
469 }
470
471 // TODO just for testing
472 void setPartialEventDrivenSolver(bool peds_) { peds = peds_; }
473
479 void writez(std::string fileName, bool formatH5=true);
480 using DynamicSystem::writez;
481
487 void writeStateTable(std::string fileName);
488
493 void readz0(std::string fileName);
494 using DynamicSystem::readz0;
495
496 void initializeUsingXML(xercesc::DOMElement *element) override;
497
502 void setProjectionTolerance(double tol) { tolProj = tol; }
503
508 void setLocalSolverTolerance(double tol) { tolLocalSolver = tol; }
509 double getLocalSolverTolerance() { return tolLocalSolver; }
510
515 void setDynamicSystemSolverTolerance(double tol) { tolDSS = tol; }
516 double getDynamicSystemSolverTolerance() { return tolDSS; }
517
522 void updatezRef(fmatvec::Vec &ext);
523
528 void updatezdRef(fmatvec::Vec &ext);
529
530 void setAlwaysConsiderContact(bool alwaysConsiderContact_) { alwaysConsiderContact = alwaysConsiderContact_; }
531
532 void setInverseKinetics(bool inverseKinetics_) { inverseKinetics = inverseKinetics_; }
533 bool getInverseKinetics() const { return inverseKinetics; }
534
535 void setInitialProjection(bool initialProjection_) { initialProjection = initialProjection_; }
536 bool getInitialProjection() const { return initialProjection; }
537
538 void setDetermineEquilibriumState(bool determineEquilibriumState_) { determineEquilibriumState = determineEquilibriumState_; }
539 bool getDetermineEquilibriumState() const { return determineEquilibriumState; }
540
541 void setUseConstraintSolverForPlot(bool useConstraintSolverForPlot_) { useConstraintSolverForPlot = useConstraintSolverForPlot_; }
542 bool getUseConstraintSolverForPlot() const { return useConstraintSolverForPlot; }
543
544 fmatvec::Mat dhdq(int lb=0, int ub=0);
545 fmatvec::Mat dhdu(int lb=0, int ub=0);
546 fmatvec::Mat dhdx();
547 fmatvec::Vec dhdt();
548
549 void setRootID(int ID) {rootID = ID;}
550 int getRootID() const {return rootID;}
551
552 void resetUpToDate() override;
553
554 bool getUpdateT() { return updT; }
555 bool getUpdateM() { return updM; }
556 bool getUpdateLLM() { return updLLM; }
557 bool getUpdateh(int j) { return updh[j]; }
558 bool getUpdater(int j) { return updr[j]; }
559 bool getUpdateJrla(int j) { return updJrla[j]; }
560 bool getUpdaterdt() { return updrdt; }
561 bool getUpdateW(int j) { return updW[j]; }
562 bool getUpdateV(int j) { return updV[j]; }
563 bool getUpdatewb() { return updwb; }
564 bool getUpdateg() { return updg; }
565 bool getUpdategd() { return updgd; }
566 bool getUpdatela() { return updla; }
567 bool getUpdateLa() { return updLa; }
568 bool getUpdatezd() { return updzd; }
569 bool getUpdatedq() { return upddq; }
570 bool getUpdatedu() { return upddu; }
571 bool getUpdatedx() { return upddx; }
572 void setUpdatela(bool updla_) { updla = updla_; }
573 void setUpdateLa(bool updLa_) { updLa = updLa_; }
574 void setUpdateG(bool updG_) { updG = updG_; }
575 void setUpdatebi(bool updbi_) { updbi = updbi_; }
576 void setUpdatebc(bool updbc_) { updbc = updbc_; }
577 void setUpdatezd(bool updzd_) { updzd = updzd_; }
578 void setUpdateW(bool updW_, int i=0) { updW[i] = updW_; }
579
584 void updategRef(fmatvec::Vec &ref) override { Group::updategRef(ref); updg = true; }
585
590 void updategdRef(fmatvec::Vec &ref) override { Group::updategdRef(ref); updgd = true; }
591
596 void updatewbRef(fmatvec::Vec &ref) override { Group::updatewbRef(ref); updwb = true; }
597
603 void updateWRef(fmatvec::Mat &ref, int i=0) override { Group::updateWRef(ref,i); updW[i] = true; }
604
610 void updateVRef(fmatvec::Mat &ref, int i=0) override { Group::updateVRef(ref,i); updV[i] = true; }
611
615 virtual void updatelaInverseKinetics();
616
617 void updatedq() override;
618 void updatedu() override;
619 void updatedx() override;
620
621 void updateStopVector() override;
622
623 void updateInternalState();
624
625 void plot() override;
626
627 void addEnvironment(Environment* env);
628
633 template<class Env>
634 Env* getEnvironment();
635
639
640 std::vector<StateTable>& getStateTable() { return tabz; }
641
642 void setCompressionLevel(int level) { compressionLevel=level; }
643 void setChunkSize(int size) { chunkSize=size; }
644 void setCacheSize(int size) { cacheSize=size; }
645
646 void setqdequ(bool qdequ_) { qdequ = qdequ_; }
647 bool getqdequ() { return qdequ; }
648
650 static void interrupt(bool silent=false);
651
652 protected:
656 double t;
657
661 double dt;
662
666 int zSize;
667
671 fmatvec::Vec z;
672
676 fmatvec::Vec zd;
677
681 fmatvec::SymMat MParent;
682
686 fmatvec::SymMat LLMParent;
687
691 fmatvec::Mat TParent;
692
696 fmatvec::Mat WParent[2];
697
701 fmatvec::Mat VParent[2];
702
706 fmatvec::Vec wbParent;
707
711 fmatvec::Vec laParent, LaParent;
712
716 fmatvec::Vec rFactorParent;
717
721 fmatvec::Vec sParent;
722
726 fmatvec::Vec resParent;
727
728 fmatvec::Vec curisParent, nextisParent;
729
733 fmatvec::Vec gParent;
734
738 fmatvec::Vec gdParent;
739
743 fmatvec::Vec zParent;
744
748 fmatvec::Vec zdParent;
749
750 fmatvec::Vec dxParent, dqParent, duParent;
751
755 fmatvec::Vec hParent[2];
756
760 fmatvec::Vec rParent[2], rdtParent;
761
762 fmatvec::Mat JrlaParent[2];
763
767 fmatvec::Vec svParent;
768
772 fmatvec::VecInt jsvParent;
773
777 fmatvec::VecInt LinkStatusParent;
778
783 fmatvec::VecInt LinkStatusRegParent;
784
788 fmatvec::SparseMat Gs;
789
793 fmatvec::SqrMat Jprox;
794
798 fmatvec::SqrMat G;
799
803 fmatvec::Vec bc, bi;
804
808 bool term;
809
813 int maxIter, highIter, maxDampingSteps, iterc, iteri;
814
818 double lmParm;
819
823 Solver smoothSolver, contactSolver, impactSolver;
824
829
834
839
843 bool numJac;
844
848 fmatvec::VecInt decreaseLevels;
849
853 fmatvec::VecInt checkTermLevels;
854
859
864
868 bool peds;
869
873 double tolProj;
874
878 double tolLocalSolver { 1e-10 };
879
883 double tolDSS { 1e-9 };
884
888 fmatvec::Vec laInverseKineticsParent;
889 fmatvec::Mat bInverseKineticsParent;
890
894 fmatvec::Mat WInverseKineticsParent;
895
896 bool alwaysConsiderContact;
897 bool inverseKinetics;
898 bool initialProjection;
899 bool determineEquilibriumState;
900 bool useConstraintSolverForPlot;
901
902 fmatvec::Vec corrParent;
903
904 int rootID;
905
906 double gTol, gdTol, gddTol, laTol, LaTol;
907
908 bool updT, updh[2], updr[2], updJrla[2], updrdt, updM, updLLM, updW[2], updV[2], updwb, updg, updgd, updG, updbc, updbi, updsv, updzd, updla, updLa, upddq, upddu, upddx;
909
910 bool useSmoothSolver;
911
912 bool qdequ;
913
914 std::vector<StateTable> tabz;
915
916 int compressionLevel { H5::File::getDefaultCompression() };
917 int chunkSize { H5::File::getDefaultChunkSize() };
918 int cacheSize { H5::File::getDefaultCacheSize() };
919
920 private:
925 static void sigInterruptHandler(int);
926
930 void constructor();
931
935 static std::atomic<bool> exitRequest;
936 static_assert(decltype(exitRequest)::is_always_lock_free);
937 // flag to indicate if a user requested interruption should be silent.
938 static std::atomic<bool> silentExit;
939
943 bool READZ0;
944
953 void addToGraph(Graph* graph, fmatvec::SqrMat &A, int i, std::vector<Element*> &objList);
954
955 bool truncateSimulationFiles;
956 bool embedOmbvxInH5 { false };
957
958 // Holds the dynamic systems before the "reorganize hierarchy" takes place.
959 // This is required since all elements of all other containers from DynamicSystem are readded to DynamicSystemSolver,
960 // except this container (which is a "pure" container = no calculation is done in DynamicSystem)
961 // However, we must hold this container until the dtor of DynamicSystemSolver is called to avoid the deallocation of other
962 // elements hold by DynamicSystem elements (especially (currently only) hdf5File)
963 std::vector<DynamicSystem*> dynamicsystemPreReorganize;
964
965 double facSizeGs;
966
967 std::vector<std::unique_ptr<Environment>> environments;
968 MBSimEnvironment *mbsimEnvironment = nullptr;
969
970 bool firstPlot { true };
971
972 std::unique_ptr<MultiDimNewtonMethod> nonlinearConstraintNewtonSolver;
973 std::unique_ptr<ConstraintResiduum> constraintResiduum;
974 std::unique_ptr<ConstraintJacobian> constraintJacobian;
975 };
976
977 template<class Env>
979 // get the Environment of type Env
980 auto &reqType=typeid(Env);
981 for(auto &e : environments) {
982 auto &e_=*e;
983 if(reqType==typeid(e_))
984 return static_cast<Env*>(e.get());
985 }
986 auto newEnv=new Env;
987 addEnvironment(newEnv);
988 return newEnv;
989 }
990
991}
992
993#endif /* _DYNAMIC_SYSTEM_SOLVER_H_ */
Definition: dynamic_system_solver.h:63
Definition: dynamic_system_solver.h:442
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
void checkConstraintsForTermination() override
validate force laws concerning given tolerances
Definition: dynamic_system_solver.cc:744
fmatvec::Vec sParent
TODO.
Definition: dynamic_system_solver.h:721
int(DynamicSystemSolver::* solveImpacts_)()
function pointer for election of prox-solver for impact equations on velocity level
Definition: dynamic_system_solver.h:307
void plot() override
plots time dependent data
Definition: dynamic_system_solver.cc:1781
bool term
boolean to check for termination of contact equations solution
Definition: dynamic_system_solver.h:808
int solveConstraintsFixpointSingle() override
solve contact equations with single step fixed point scheme
Definition: dynamic_system_solver.cc:512
void computeInitialCondition()
compute initial condition for links for event driven integrator
Definition: dynamic_system_solver.cc:919
fmatvec::Vec hParent[2]
smooth, smooth with respect to objects, smooth with respect to links right hand side
Definition: dynamic_system_solver.h:755
void setProjectionTolerance(double tol)
set tolerance for projection of generalized position
Definition: dynamic_system_solver.h:502
fmatvec::Vec zd
derivative of state vector
Definition: dynamic_system_solver.h:676
bool useOldla
flag if contac force parameter of last time step should be used
Definition: dynamic_system_solver.h:838
fmatvec::Mat WParent[2]
contact force directions
Definition: dynamic_system_solver.h:696
fmatvec::VecInt LinkStatusParent
status vector of set valued links with piecewise link equation (which piece is valid)
Definition: dynamic_system_solver.h:777
fmatvec::Vec bc
TODO.
Definition: dynamic_system_solver.h:803
int solveConstraintsLinearEquations()
solution of contact equations with direct linear solver using minimum of least squares
Definition: dynamic_system_solver.cc:969
void setLocalSolverTolerance(double tol)
set tolerance for local none-linear solver (solvers on element level), like the Newton-Solver in Join...
Definition: dynamic_system_solver.h:508
fmatvec::SqrMat Jprox
JACOBIAN of contact equations for Newton scheme.
Definition: dynamic_system_solver.h:793
void initialize()
Initialize the system.
Definition: dynamic_system_solver.cc:113
void updateWRef(fmatvec::Mat &ref, int i=0) override
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system_solver.h:603
fmatvec::Mat VParent[2]
condensed contact force directions
Definition: dynamic_system_solver.h:701
double lmParm
Levenberg-Marquard parameter.
Definition: dynamic_system_solver.h:818
fmatvec::Vec gParent
relative distances
Definition: dynamic_system_solver.h:733
virtual void updatelaInverseKinetics()
update inverse kinetics constraint forces
Definition: dynamic_system_solver.cc:1701
fmatvec::Vec z
state vector
Definition: dynamic_system_solver.h:671
bool peds
TODO, flag for occuring impact and sticking in event driven solver.
Definition: dynamic_system_solver.h:868
static void sigInterruptHandler(int)
handler for user interrupt signal Set the DSS flag exitRequest to true.
Definition: dynamic_system_solver.cc:1387
void writeStateTable(std::string fileName)
writes state table to a file
Definition: dynamic_system_solver.cc:1418
bool numJac
flag if Jacobian for Newton scheme should be calculated numerically
Definition: dynamic_system_solver.h:843
void saveLa()
save contact impulses for use as starting value in next time step
Definition: dynamic_system_solver.cc:1282
fmatvec::Vec wbParent
TODO.
Definition: dynamic_system_solver.h:706
double t
time
Definition: dynamic_system_solver.h:656
Solver smoothSolver
solver for contact equations and impact equations
Definition: dynamic_system_solver.h:823
int solveConstraintsRootFinding() override
solve contact equations with Newton scheme
Definition: dynamic_system_solver.cc:612
double tolProj
Tolerance for projection of generalized position.
Definition: dynamic_system_solver.h:873
void updater(int j=0) override
update smooth link force law
Definition: dynamic_system_solver.cc:868
fmatvec::Vec resParent
residuum of contact equations
Definition: dynamic_system_solver.h:726
int(DynamicSystemSolver::* solveConstraints_)()
Definition: dynamic_system_solver.h:300
bool dropContactInfo
flag if contact matrices for debugging should be dropped in no-convergence case
Definition: dynamic_system_solver.h:833
fmatvec::VecInt decreaseLevels
decreasing relaxation factors is done in levels containing the number of contact iterations as condit...
Definition: dynamic_system_solver.h:848
fmatvec::VecInt checkTermLevels
TODO.
Definition: dynamic_system_solver.h:853
bool READZ0
is a state read from a file
Definition: dynamic_system_solver.h:943
int solveConstraintsGaussSeidel() override
solve contact equations with Gauss-Seidel scheme
Definition: dynamic_system_solver.cc:572
fmatvec::SqrMat G
mass action matrix
Definition: dynamic_system_solver.h:798
std::string getSolverInfo()
Definition: dynamic_system_solver.cc:1331
int solveConstraintsNonlinearEquations()
solution of contact equations with direct nonlinear newton solver using minimum of least squares in e...
Definition: dynamic_system_solver.cc:988
fmatvec::VecInt LinkStatusRegParent
status vector of single valued links
Definition: dynamic_system_solver.h:783
void updategRef(fmatvec::Vec &ref) override
references to relative distances of dynamic system parent
Definition: dynamic_system_solver.h:584
void updatezRef(fmatvec::Vec &ext)
references to external state
Definition: dynamic_system_solver.cc:1437
void setStopIfNoConvergence(bool flag, bool dropInfo=false)
Definition: dynamic_system_solver.h:431
int solveImpactsLinearEquations()
solution of contact equations with Cholesky decomposition on velocity level
Definition: dynamic_system_solver.cc:998
void writez(std::string fileName, bool formatH5=true)
writes state to a file
Definition: dynamic_system_solver.cc:1396
void addToGraph(Graph *graph, fmatvec::SqrMat &A, int i, std::vector< Element * > &objList)
adds list of objects to tree
Definition: dynamic_system_solver.cc:1584
int solveImpactsRootFinding() override
solve impact equations with Newton scheme on velocity level
Definition: dynamic_system_solver.cc:679
static std::atomic< bool > exitRequest
boolean flags to store a user requested interruption
Definition: dynamic_system_solver.h:935
~DynamicSystemSolver() override
destructor
Definition: dynamic_system_solver.cc:105
double tolLocalSolver
Tolerance for local none-linear solvers (solvers on element level)
Definition: dynamic_system_solver.h:878
void updatezdRef(fmatvec::Vec &ext)
references to differentiated external state
Definition: dynamic_system_solver.cc:1449
void addElement(Element *element_)
Definition: dynamic_system_solver.cc:1292
void checkImpactsForTermination() override
validate force laws concerning given tolerances on velocity level
Definition: dynamic_system_solver.cc:755
bool positionDriftCompensationNeeded(double gmax)
check if drift compensation on position level is needed
Definition: dynamic_system_solver.cc:1130
fmatvec::Vec gdParent
relative velocities
Definition: dynamic_system_solver.h:738
DynamicSystemSolver(const std::string &name="")
constructor
Definition: dynamic_system_solver.cc:94
MBSimEnvironment * getMBSimEnvironment()
Definition: dynamic_system_solver.cc:1824
Env * getEnvironment()
Definition: dynamic_system_solver.h:978
fmatvec::Vec zParent
state
Definition: dynamic_system_solver.h:743
bool stopIfNoConvergence
flag if the contact equations should be stopped if there is no convergence
Definition: dynamic_system_solver.h:828
fmatvec::Vec laParent
contact force parameters
Definition: dynamic_system_solver.h:711
void projectGeneralizedPositions(int mode, bool fullUpdate=false)
drift projection for positions
Definition: dynamic_system_solver.cc:1156
fmatvec::SymMat LLMParent
Cholesky decomposition of mass matrix.
Definition: dynamic_system_solver.h:686
fmatvec::Vec rFactorParent
relaxation parameters for contact equations
Definition: dynamic_system_solver.h:716
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: dynamic_system_solver.cc:130
Element * getElement(const std::string &name)
Definition: dynamic_system_solver.cc:1304
fmatvec::Vec svParent
stopvector (rootfunctions for event driven integration
Definition: dynamic_system_solver.h:767
void constructor()
set plot feature default values
Definition: dynamic_system_solver.cc:1463
double dt
step size
Definition: dynamic_system_solver.h:661
int zSize
size of state vector
Definition: dynamic_system_solver.h:666
fmatvec::Mat TParent
matrix of linear relation between differentiated positions and velocities
Definition: dynamic_system_solver.h:691
void updategdRef(fmatvec::Vec &ref) override
references to relative velocities of dynamic system parent
Definition: dynamic_system_solver.h:590
virtual const fmatvec::Vec & shift(std::optional< std::reference_wrapper< bool > > &&velProjWasCalled={}, std::optional< std::reference_wrapper< bool > > &&posProjWasCalled={})
update for event driven integrator for event
Definition: dynamic_system_solver.cc:1597
virtual void updateG()
updates mass action matrix
Definition: dynamic_system_solver.cc:1007
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:610
fmatvec::Vec zdParent
differentiated state
Definition: dynamic_system_solver.h:748
void setDynamicSystemSolverTolerance(double tol)
set tolerance for global none-linear solver (solvers on DynamicSystemSolver level),...
Definition: dynamic_system_solver.h:515
void initla()
load contact forces for use as starting value
Definition: dynamic_system_solver.cc:1277
void readz0(std::string fileName)
reads state from a file
Definition: dynamic_system_solver.cc:1429
fmatvec::SparseMat Gs
sparse mass action matrix
Definition: dynamic_system_solver.h:788
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: dynamic_system_solver.h:596
fmatvec::SymMat MParent
mass matrix
Definition: dynamic_system_solver.h:681
void dropContactMatrices()
Definition: dynamic_system_solver.cc:1348
static void interrupt(bool silent=false)
Definition: dynamic_system_solver.cc:1391
bool velocityDriftCompensationNeeded(double gdmax)
check if drift compensation on velocity level is needed
Definition: dynamic_system_solver.cc:1143
fmatvec::VecInt jsvParent
boolean evaluation of stopvector
Definition: dynamic_system_solver.h:772
int solveImpactsFixpointSingle() override
solve impact equations with single step fixed point scheme on velocity level
Definition: dynamic_system_solver.cc:542
fmatvec::Vec rParent[2]
nonsmooth right hand side
Definition: dynamic_system_solver.h:760
Solver
solver for contact equations
Definition: dynamic_system_solver.h:76
double tolDSS
Tolerance for global none-linear solvers (solvers on DynamicSystemSolver level)
Definition: dynamic_system_solver.h:883
int maxIter
maximum number of contact iterations, high number of contact iterations for warnings,...
Definition: dynamic_system_solver.h:813
int solveImpactsGaussSeidel() override
solve impact equations with Gauss-Seidel scheme on velocity level
Definition: dynamic_system_solver.cc:592
void projectGeneralizedVelocities(int mode)
drift projection for positions
Definition: dynamic_system_solver.cc:1223
bool checkGSize
boolean if force action matrix should be resized in each step
Definition: dynamic_system_solver.h:858
void initLa()
load contact impulses for use as starting value
Definition: dynamic_system_solver.cc:1287
void setEmbedOmbvxInH5(bool flag)
If true the ombvx XML file in embedded in the ombvh5 file.
Definition: dynamic_system_solver.h:139
void savela()
save contact forces for use as starting value in next time step
Definition: dynamic_system_solver.cc:1272
int limitGSize
TODO.
Definition: dynamic_system_solver.h:863
void decreaserFactors()
decrease relaxation factors if mass action matrix is not diagonal dominant
Definition: dynamic_system_solver.cc:1108
virtual void updatewbRef(fmatvec::Vec &wbParent)
references to TODO of dynamic system parent
Definition: dynamic_system.cc:854
void plot() override
plots time dependent data
Definition: dynamic_system.cc:369
fmatvec::Mat Jrla[2]
Jacobian dr/dla.
Definition: dynamic_system.h:868
fmatvec::Vec la
contact force parameters
Definition: dynamic_system.h:878
virtual void updateVRef(fmatvec::Mat &VParent, int j=0)
references to condensed contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:882
virtual void updateWRef(fmatvec::Mat &WParent, int j=0)
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:861
virtual void updategRef(fmatvec::Vec &gParent)
references to relative distances of dynamic system parent
Definition: dynamic_system.cc:819
virtual void updategdRef(fmatvec::Vec &gdParent)
references to relative velocities of dynamic system parent
Definition: dynamic_system.cc:826
Element(const std::string &name)
constructor
Definition: element.cc:64
InitStage
The stages of the initialization.
Definition: element.h:63
std::string name
name of element
Definition: element.h:263
Definition: environment.h:37
Definition: function.h:53
class for tree-structured mechanical systems with recursive and flat memory mechanism
Definition: graph.h:36
group ingredients do not depend on each other
Definition: group.h:35
Definition: environment.h:59
Definition: mbsim_event.h:79
solver-interface for dynamic systems
Definition: solver.h:38
namespace MBSim
Definition: bilateral_constraint.cc:30
Definition: dynamic_system_solver.h:38