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 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:
68 MBSim::DynamicSystemSolver *sys;
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
138 /* INHERITED INTERFACE OF GROUP */
139 void init(InitStage stage, const InitConfigSet &config) override;
140 using Group::plot;
141 /***************************************************/
142
143 /* INHERITED INTERFACE OF DYNAMICSYSTEM */
144 int solveConstraintsFixpointSingle() override;
145 int solveImpactsFixpointSingle() override;
146 int solveConstraintsGaussSeidel() override;
147 int solveImpactsGaussSeidel() override;
148 int solveConstraintsRootFinding() override;
149 int solveImpactsRootFinding() override;
150 void checkConstraintsForTermination() override;
151 void checkImpactsForTermination() override;
152 /***************************************************/
153
154 /* INHERITED INTERFACE OF OBJECTINTERFACE */
155 void updateT() override;
156 void updateh(int i=0) override;
157 void updateM() override;
158 void updateLLM() override;
159 void updatezd() override;
160 /***************************************************/
161
162 /* INHERITED INTERFACE OF LINKINTERFACE */
163
174 virtual void updater(int j=0);
175 virtual void updateJrla(int j=0);
176 virtual void updaterdt();
177 void updatewb() override;
178 void updateg() override;
179 void updategd() override;
180 void updateW(int j=0) override;
181 void updateV(int j=0) override;
182 virtual void updatebc();
183 virtual void updatebi();
184 virtual void updatela();
185 virtual void updateLa();
186 /***************************************************/
187
188 /* INHERITED INTERFACE OF ELEMENT */
189 /***************************************************/
190
191 /* GETTER / SETTER */
192
193 void setSmoothSolver(Solver solver_) { smoothSolver = solver_; }
194 void setConstraintSolver(Solver solver_) { contactSolver = solver_; }
195 void setImpactSolver(Solver solver_) { impactSolver = solver_; }
196 const Solver& getSmoothSolver() { return smoothSolver; }
197 const Solver& getConstraintSolver() { return contactSolver; }
198 const Solver& getImpactSolver() { return impactSolver; }
199 void setTermination(bool term_) { term = term_; }
200 void setMaximumNumberOfIterations(int iter) { maxIter = iter; }
201 void setHighNumberOfIterations(int iter) { highIter = iter; }
202 void setNumericalJacobian(bool numJac_) { numJac = numJac_; }
203 void setMaximumDampingSteps(int maxDSteps) { maxDampingSteps = maxDSteps; }
204 void setLevenbergMarquardtParamater(double lmParm_) { lmParm = lmParm_; }
205
206 void setUseOldla(bool flag) { useOldla = flag; }
207 void setDecreaseLevels(const fmatvec::VecInt &decreaseLevels_) { decreaseLevels = decreaseLevels_; }
208 void setCheckTermLevels(const fmatvec::VecInt &checkTermLevels_) { checkTermLevels = checkTermLevels_; }
209 void setCheckGSize(bool checkGSize_) { checkGSize = checkGSize_; }
210 void setLimitGSize(int limitGSize_) { limitGSize = limitGSize_; checkGSize = false; }
211
212 double& getTime() { return t; }
213 const double& getTime() const { return t; }
214 void setTime(double t_) { t = t_; }
215
216 double getStepSize() const { return dt; }
217 void setStepSize(double dt_) { dt = dt_; }
218
219 int getzSize() const { return zSize; }
220
221 fmatvec::Vec& getState() { return z; }
222 const fmatvec::Vec& getState() const { return z; }
223 void setState(const fmatvec::Vec &z_) { z = z_; }
224
225 void setzd(const fmatvec::Vec &zd_) { zd = zd_; }
226
227 const fmatvec::SqrMat& getG(bool check=true) const { assert((not check) or (not updG)); return G; }
228 const fmatvec::SparseMat& getGs(bool check=true) const { assert((not check) or (not updG)); return Gs; }
229 const fmatvec::Vec& getbc(bool check=true) const { assert((not check) or (not updbc)); return bc; }
230 const fmatvec::Vec& getbi(bool check=true) const { assert((not check) or (not updbi)); return bi; }
231 const fmatvec::SqrMat& getJprox() const { return Jprox; }
232 fmatvec::SqrMat& getG(bool check=true) { assert((not check) or (not updG)); return G; }
233 fmatvec::SparseMat& getGs(bool check=true) { assert((not check) or (not updG)); return Gs; }
234 fmatvec::Vec& getbc(bool check=true) { assert((not check) or (not updbc)); return bc; }
235 fmatvec::Vec& getbi(bool check=true) { assert((not check) or (not updbi)); return bi; }
236 fmatvec::SqrMat& getJprox() { return Jprox; }
237 const fmatvec::Vec& getr(int j=0, bool check=true) const { assert((not check) or (not updr[j])); return r[j]; }
238 fmatvec::Vec& getr(int j=0, bool check=true) { assert((not check) or (not updr[j])); return r[j]; }
239
240 // Jacobian of dr/dla
241 const fmatvec::Mat& getJrla(int j=0, bool check=true) const { assert((not check) or (not updJrla[j])); return Jrla[j]; }
242 fmatvec::Mat& getJrla(int j=0, bool check=true) { assert((not check) or (not updJrla[j])); return Jrla[j]; }
243
244 const fmatvec::Vec& evaldq() { if(upddq) updatedq(); return dq; }
245 const fmatvec::Vec& evaldu() { if(upddu) updatedu(); return du; }
246 const fmatvec::Vec& evaldx() { if(upddx) updatedx(); return dx; }
247 const fmatvec::Vec& evalzd();
248 const fmatvec::SqrMat& evalG() { if(updG) updateG(); return G; }
249 const fmatvec::SparseMat& evalGs() { if(updG) updateG(); return Gs; }
250 const fmatvec::Vec& evalbc() { if(updbc) updatebc(); return bc; }
251 const fmatvec::Vec& evalbi() { if(updbi) updatebi(); return bi; }
252 const fmatvec::Vec& evalsv();
253 const fmatvec::Vec& evalz0();
254 const fmatvec::Vec& evalla() { if(updla) updatela(); return la; }
255 const fmatvec::Vec& evalLa() { if(updLa) updateLa(); return La; }
256
257 fmatvec::Vec& getzParent() { return zParent; }
258 fmatvec::Vec& getzdParent() { return zdParent; }
259 fmatvec::Vec& getlaParent() { return laParent; }
260 fmatvec::Vec& getLaParent() { return LaParent; }
261 // const fmatvec::Vec& getzParent() const { return zParent; }
262 // const fmatvec::Vec& getzdParent() const { return zdParent; }
263 // const fmatvec::Mat& getWParent(int i=0) const { return WParent[i]; }
264 fmatvec::Mat& getWParent(int i=0) { return WParent[i]; }
265 fmatvec::Mat& getVParent(int i=0) { return VParent[i]; }
266 // fmatvec::Vec& getlaParent() { return laParent; }
267 // fmatvec::Vec& getLaParent() { return LaParent; }
268 // const fmatvec::Vec& getgParent() const { return gParent; }
269 fmatvec::Vec& getgParent() { return gParent; }
270 // const fmatvec::Vec& getgdParent() const { return gdParent; }
271 fmatvec::Vec& getgdParent() { return gdParent; }
272 fmatvec::Vec& getresParent() { return resParent; }
273 fmatvec::Vec& getrFactorParent() { return rFactorParent; }
274
275 void resizezParent(int nz) { zParent.resize(nz); }
276 void resizezdParent(int nz) { zdParent.resize(nz); }
277
278 DynamicSystemSolver* getDynamicSystemSolver() { return this; }
279 bool getIntegratorExitRequest() { return integratorExitRequest; }
280 int getMaxIter() {return maxIter;}
281 int getHighIter() {return highIter;}
282 int getIterC() {return iterc;}
283 int getIterI() {return iteri;}
284 /***************************************************/
285
289 void computeInitialCondition();
290
291 int (DynamicSystemSolver::*solveSmooth_)();
292
297 int (DynamicSystemSolver::*solveConstraints_)();
298
304 int (DynamicSystemSolver::*solveImpacts_)();
305
311 int solveConstraintsLinearEquations();
312
318 int solveConstraintsNonlinearEquations();
319
326 int solveImpactsLinearEquations();
327
328 int solveImpactsNonlinearEquations();
329
334 virtual void updateG();
335
339 void decreaserFactors();
340
347 virtual const fmatvec::Vec& shift();
348
353 void getLinkStatus(fmatvec::VecInt &LinkStatusExt);
354
359 void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt);
360
364 bool positionDriftCompensationNeeded(double gmax);
365
369 bool velocityDriftCompensationNeeded(double gdmax);
370
374 void projectGeneralizedPositions(int mode, bool fullUpdate=false);
375
379 void projectGeneralizedVelocities(int mode);
380
385 void savela();
386
391 void initla();
392
397 void saveLa();
398
403 void initLa();
404
409 void addElement(Element *element_);
410
416 Element* getElement(const std::string &name);
417
421 std::string getSolverInfo();
422
427 void setStopIfNoConvergence(bool flag, bool dropInfo = false) { stopIfNoConvergence = flag; dropContactInfo=dropInfo; }
428
429 bool getStopIfNoConvergence() { return stopIfNoConvergence; }
430
434 void dropContactMatrices();
435
436 // MBSim signal handler
437 #ifndef SWIG
438 class SignalHandler {
439 public:
440 SignalHandler();
441 ~SignalHandler();
442 private:
443 #ifdef HAVE_ANSICSIGNAL
444 using SigHandle = void (*)(int);
445 SigHandle oldSigInt;
446 SigHandle oldSigTerm;
447 #endif
448 };
449 #endif
450
454 static void sigInterruptHandler(int);
455
456 void checkExitRequest();
457
458 // TODO just for testing
459 void setPartialEventDrivenSolver(bool peds_) { peds = peds_; }
460
466 void writez(std::string fileName, bool formatH5=true);
467
473 void writeStateTable(std::string fileName);
474
479 void readz0(std::string fileName);
480
481 void initializeUsingXML(xercesc::DOMElement *element) override;
482
487 void setProjectionTolerance(double tol) { tolProj = tol; }
488
493 void setLocalSolverTolerance(double tol) { tolLocalSolver = tol; }
494 double getLocalSolverTolerance() { return tolLocalSolver; }
495
500 void setDynamicSystemSolverTolerance(double tol) { tolDSS = tol; }
501 double getDynamicSystemSolverTolerance() { return tolDSS; }
502
507 void updatezRef(fmatvec::Vec &ext);
508
513 void updatezdRef(fmatvec::Vec &ext);
514
515 void setAlwaysConsiderContact(bool alwaysConsiderContact_) { alwaysConsiderContact = alwaysConsiderContact_; }
516
517 void setInverseKinetics(bool inverseKinetics_) { inverseKinetics = inverseKinetics_; }
518 bool getInverseKinetics() const { return inverseKinetics; }
519
520 void setInitialProjection(bool initialProjection_) { initialProjection = initialProjection_; }
521 bool getInitialProjection() const { return initialProjection; }
522
523 void setDetermineEquilibriumState(bool determineEquilibriumState_) { determineEquilibriumState = determineEquilibriumState_; }
524 bool getDetermineEquilibriumState() const { return determineEquilibriumState; }
525
526 void setUseConstraintSolverForSmoothMotion(bool useConstraintSolverForSmoothMotion_) { useConstraintSolverForSmoothMotion = useConstraintSolverForSmoothMotion_; }
527 bool getUseConstraintSolverForSmoothMotion() const { return useConstraintSolverForSmoothMotion; }
528
529 void setUseConstraintSolverForPlot(bool useConstraintSolverForPlot_) { useConstraintSolverForPlot = useConstraintSolverForPlot_; }
530 bool getUseConstraintSolverForPlot() const { return useConstraintSolverForPlot; }
531
532 fmatvec::Mat dhdq(int lb=0, int ub=0);
533 fmatvec::Mat dhdu(int lb=0, int ub=0);
534 fmatvec::Mat dhdx();
535 fmatvec::Vec dhdt();
536
537 void setRootID(int ID) {rootID = ID;}
538 int getRootID() const {return rootID;}
539
540 void resetUpToDate() override;
541
542 bool getUpdateT() { return updT; }
543 bool getUpdateM() { return updM; }
544 bool getUpdateLLM() { return updLLM; }
545 bool getUpdateh(int j) { return updh[j]; }
546 bool getUpdater(int j) { return updr[j]; }
547 bool getUpdateJrla(int j) { return updJrla[j]; }
548 bool getUpdaterdt() { return updrdt; }
549 bool getUpdateW(int j) { return updW[j]; }
550 bool getUpdateV(int j) { return updV[j]; }
551 bool getUpdatewb() { return updwb; }
552 bool getUpdateg() { return updg; }
553 bool getUpdategd() { return updgd; }
554 bool getUpdatela() { return updla; }
555 bool getUpdateLa() { return updLa; }
556 bool getUpdatezd() { return updzd; }
557 bool getUpdatedq() { return upddq; }
558 bool getUpdatedu() { return upddu; }
559 bool getUpdatedx() { return upddx; }
560 void setUpdatela(bool updla_) { updla = updla_; }
561 void setUpdateLa(bool updLa_) { updLa = updLa_; }
562 void setUpdateG(bool updG_) { updG = updG_; }
563 void setUpdatebi(bool updbi_) { updbi = updbi_; }
564 void setUpdatebc(bool updbc_) { updbc = updbc_; }
565 void setUpdatezd(bool updzd_) { updzd = updzd_; }
566 void setUpdateW(bool updW_, int i=0) { updW[i] = updW_; }
567
572 void updategRef(fmatvec::Vec &ref) override { Group::updategRef(ref); updg = true; }
573
578 void updategdRef(fmatvec::Vec &ref) override { Group::updategdRef(ref); updgd = true; }
579
584 void updatewbRef(fmatvec::Vec &ref) override { Group::updatewbRef(ref); updwb = true; }
585
591 void updateWRef(fmatvec::Mat &ref, int i=0) override { Group::updateWRef(ref,i); updW[i] = true; }
592
598 void updateVRef(fmatvec::Mat &ref, int i=0) override { Group::updateVRef(ref,i); updV[i] = true; }
599
603 virtual void updatelaInverseKinetics();
604
605 void updatedq() override;
606 void updatedu() override;
607 void updatedx() override;
608
609 void updateStopVector() override;
610
611 void updateInternalState();
612
613 void plot() override;
614
615 void addEnvironment(Environment* env);
616
621 template<class Env>
622 Env* getEnvironment();
623
626 MBSimEnvironment* getMBSimEnvironment();
627
628 std::vector<StateTable>& getStateTable() { return tabz; }
629
630 void setCompressionLevel(int level) { compressionLevel=level; }
631 void setChunkSize(int size) { chunkSize=size; }
632 void setCacheSize(int size) { cacheSize=size; }
633
634 protected:
638 double t;
639
643 double dt;
644
648 int zSize;
649
653 fmatvec::Vec z;
654
658 fmatvec::Vec zd;
659
663 fmatvec::SymMat MParent;
664
668 fmatvec::SymMat LLMParent;
669
673 fmatvec::Mat TParent;
674
678 fmatvec::Mat WParent[2];
679
683 fmatvec::Mat VParent[2];
684
688 fmatvec::Vec wbParent;
689
693 fmatvec::Vec laParent, LaParent;
694
698 fmatvec::Vec rFactorParent;
699
703 fmatvec::Vec sParent;
704
708 fmatvec::Vec resParent;
709
710 fmatvec::Vec curisParent, nextisParent;
711
715 fmatvec::Vec gParent;
716
720 fmatvec::Vec gdParent;
721
725 fmatvec::Vec zParent;
726
730 fmatvec::Vec zdParent;
731
732 fmatvec::Vec dxParent, dqParent, duParent;
733
737 fmatvec::Vec hParent[2];
738
742 fmatvec::Vec rParent[2], rdtParent;
743
744 fmatvec::Mat JrlaParent[2];
745
749 fmatvec::Vec svParent;
750
754 fmatvec::VecInt jsvParent;
755
759 fmatvec::VecInt LinkStatusParent;
760
765 fmatvec::VecInt LinkStatusRegParent;
766
770 fmatvec::SparseMat Gs;
771
775 fmatvec::SqrMat Jprox;
776
780 fmatvec::SqrMat G;
781
785 fmatvec::Vec bc, bi;
786
790 bool term;
791
795 int maxIter, highIter, maxDampingSteps, iterc, iteri;
796
800 double lmParm;
801
805 Solver smoothSolver, contactSolver, impactSolver;
806
810 bool stopIfNoConvergence;
811
815 bool dropContactInfo;
816
820 bool useOldla;
821
825 bool numJac;
826
830 fmatvec::VecInt decreaseLevels;
831
835 fmatvec::VecInt checkTermLevels;
836
840 bool checkGSize;
841
845 int limitGSize;
846
850 bool peds;
851
855 double tolProj;
856
860 double tolLocalSolver { 1e-10 };
861
865 double tolDSS { 1e-9 };
866
870 fmatvec::Vec laInverseKineticsParent;
871 fmatvec::Mat bInverseKineticsParent;
872
876 fmatvec::Mat WInverseKineticsParent;
877
878 bool alwaysConsiderContact;
879 bool inverseKinetics;
880 bool initialProjection;
881 bool determineEquilibriumState;
882 bool useConstraintSolverForSmoothMotion;
883 bool useConstraintSolverForPlot;
884
885 fmatvec::Vec corrParent;
886
887 int rootID;
888
889 double gTol, gdTol, gddTol, laTol, LaTol;
890
891 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;
892
893 bool useSmoothSolver;
894
895 std::vector<StateTable> tabz;
896
897 int compressionLevel { H5::File::getDefaultCompression() };
898 int chunkSize { H5::File::getDefaultChunkSize() };
899 int cacheSize { H5::File::getDefaultCacheSize() };
900
901 private:
905 void constructor();
906
910 bool integratorExitRequest;
911
915 static std::atomic<bool> exitRequest;
916 static_assert(decltype(exitRequest)::is_always_lock_free);
917
921 bool READZ0;
922
931 void addToGraph(Graph* graph, fmatvec::SqrMat &A, int i, std::vector<Element*> &objList);
932
933 bool truncateSimulationFiles;
934
935 // Holds the dynamic systems before the "reorganize hierarchy" takes place.
936 // This is required since all elements of all other containers from DynamicSystem are readded to DynamicSystemSolver,
937 // except this container (which is a "pure" container = no calculation is done in DynamicSystem)
938 // However, we must hold this container until the dtor of DynamicSystemSolver is called to avoid the deallocation of other
939 // elements hold by DynamicSystem elements (especially (currently only) hdf5File)
940 std::vector<DynamicSystem*> dynamicsystemPreReorganize;
941
942 double facSizeGs;
943
944 std::vector<std::unique_ptr<Environment>> environments;
945 MBSimEnvironment *mbsimEnvironment = nullptr;
946
947 bool firstPlot { true };
948
949 std::unique_ptr<MultiDimNewtonMethod> nonlinearConstraintNewtonSolver;
950 std::unique_ptr<ConstraintResiduum> constraintResiduum;
951 std::unique_ptr<ConstraintJacobian> constraintJacobian;
952 };
953
954 template<class Env>
955 Env* DynamicSystemSolver::getEnvironment() {
956 // get the Environment of type Env
957 auto &reqType=typeid(Env);
958 for(auto &e : environments) {
959 auto &e_=*e;
960 if(reqType==typeid(e_))
961 return static_cast<Env*>(e.get());
962 }
963 auto newEnv=new Env;
964 addEnvironment(newEnv);
965 return newEnv;
966 }
967
968 }
969
970 #endif /* _DYNAMIC_SYSTEM_SOLVER_H_ */
MBSim::DynamicSystemSolver::solveConstraintsNonlinearEquations
int solveConstraintsNonlinearEquations()
solution of contact equations with direct nonlinear newton solver using minimum of least squares in e...
Definition: dynamic_system_solver.cc:964
MBSim::DynamicSystemSolver::useOldla
bool useOldla
flag if contac force parameter of last time step should be used
Definition: dynamic_system_solver.h:820
MBSim::StateTable
Definition: dynamic_system_solver.h:38
MBSim::DynamicSystemSolver::plot
void plot() override
plots time dependent data
Definition: dynamic_system_solver.cc:1732
MBSim::DynamicSystemSolver::solveImpactsGaussSeidel
int solveImpactsGaussSeidel() override
solve impact equations with Gauss-Seidel scheme on velocity level
Definition: dynamic_system_solver.cc:574
MBSim::DynamicSystemSolver::solveConstraints_
int(DynamicSystemSolver::* solveConstraints_)()
Definition: dynamic_system_solver.h:297
MBSim::DynamicSystemSolver::solveConstraintsLinearEquations
int solveConstraintsLinearEquations()
solution of contact equations with direct linear solver using minimum of least squares
Definition: dynamic_system_solver.cc:945
MBSim::DynamicSystemSolver::gParent
fmatvec::Vec gParent
relative distances
Definition: dynamic_system_solver.h:715
MBSim::DynamicSystemSolver::zSize
int zSize
size of state vector
Definition: dynamic_system_solver.h:648
MBSim::DynamicSystemSolver::t
double t
time
Definition: dynamic_system_solver.h:638
MBSim::DynamicSystemSolver::checkGSize
bool checkGSize
boolean if force action matrix should be resized in each step
Definition: dynamic_system_solver.h:840
MBSim::DynamicSystemSolver::solveImpactsLinearEquations
int solveImpactsLinearEquations()
solution of contact equations with Cholesky decomposition on velocity level
Definition: dynamic_system_solver.cc:974
MBSim::DynamicSystemSolver::rParent
fmatvec::Vec rParent[2]
nonsmooth right hand side
Definition: dynamic_system_solver.h:742
MBSim::DynamicSystemSolver::solveConstraintsGaussSeidel
int solveConstraintsGaussSeidel() override
solve contact equations with Gauss-Seidel scheme
Definition: dynamic_system_solver.cc:554
MBSim::DynamicSystemSolver::initLa
void initLa()
load contact impulses for use as starting value
Definition: dynamic_system_solver.cc:1251
MBSim::DynamicSystemSolver::term
bool term
boolean to check for termination of contact equations solution
Definition: dynamic_system_solver.h:790
MBSim::DynamicSystemSolver::readz0
void readz0(std::string fileName)
reads state from a file
Definition: dynamic_system_solver.cc:1394
MBSim::DynamicSystemSolver::getEnvironment
Env * getEnvironment()
Definition: dynamic_system_solver.h:955
MBSim::DynamicSystemSolver::dropContactInfo
bool dropContactInfo
flag if contact matrices for debugging should be dropped in no-convergence case
Definition: dynamic_system_solver.h:815
MBSim::DynamicSystemSolver::solveConstraintsFixpointSingle
int solveConstraintsFixpointSingle() override
solve contact equations with single step fixed point scheme
Definition: dynamic_system_solver.cc:494
MBSim::DynamicSystemSolver::tolProj
double tolProj
Tolerance for projection of generalized position.
Definition: dynamic_system_solver.h:855
MBSim::DynamicSystemSolver
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
MBSim::DynamicSystemSolver::initla
void initla()
load contact forces for use as starting value
Definition: dynamic_system_solver.cc:1241
MBSim::DynamicSystem::updateVRef
virtual void updateVRef(fmatvec::Mat &VParent, int j=0)
references to condensed contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:857
MBSim::DynamicSystemSolver::Gs
fmatvec::SparseMat Gs
sparse mass action matrix
Definition: dynamic_system_solver.h:770
MBSim::DynamicSystemSolver::checkTermLevels
fmatvec::VecInt checkTermLevels
TODO.
Definition: dynamic_system_solver.h:835
MBSim::DynamicSystemSolver::DynamicSystemSolver
DynamicSystemSolver(const std::string &name="")
constructor
Definition: dynamic_system_solver.cc:87
MBSim::DynamicSystemSolver::smoothSolver
Solver smoothSolver
solver for contact equations and impact equations
Definition: dynamic_system_solver.h:805
MBSim::DynamicSystemSolver::updategRef
void updategRef(fmatvec::Vec &ref) override
references to relative distances of dynamic system parent
Definition: dynamic_system_solver.h:572
MBSim::DynamicSystemSolver::bc
fmatvec::Vec bc
TODO.
Definition: dynamic_system_solver.h:785
MBSim::DynamicSystemSolver::stopIfNoConvergence
bool stopIfNoConvergence
flag if the contact equations should be stopped if there is no convergence
Definition: dynamic_system_solver.h:810
MBSim::DynamicSystemSolver::shift
virtual const fmatvec::Vec & shift()
update for event driven integrator for event
Definition: dynamic_system_solver.cc:1559
MBSim::DynamicSystemSolver::updateVRef
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:598
MBSim::DynamicSystemSolver::TParent
fmatvec::Mat TParent
matrix of linear relation between differentiated positions and velocities
Definition: dynamic_system_solver.h:673
MBSim::DynamicSystemSolver::sParent
fmatvec::Vec sParent
TODO.
Definition: dynamic_system_solver.h:703
MBSim::DynamicSystemSolver::LinkStatusRegParent
fmatvec::VecInt LinkStatusRegParent
status vector of single valued links
Definition: dynamic_system_solver.h:765
MBSim::DynamicSystemSolver::setLocalSolverTolerance
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:493
MBSim::Environment
Definition: environment.h:37
MBSim::DynamicSystemSolver::zd
fmatvec::Vec zd
derivative of state vector
Definition: dynamic_system_solver.h:658
MBSim::DynamicSystemSolver::getLinkStatusReg
void getLinkStatusReg(fmatvec::VecInt &LinkStatusRegExt)
Definition: dynamic_system_solver.cc:1098
MBSim::DynamicSystemSolver::updateWRef
void updateWRef(fmatvec::Mat &ref, int i=0) override
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system_solver.h:591
MBSim::DynamicSystemSolver::gdParent
fmatvec::Vec gdParent
relative velocities
Definition: dynamic_system_solver.h:720
MBSim::DynamicSystemSolver::projectGeneralizedVelocities
void projectGeneralizedVelocities(int mode)
drift projection for positions
Definition: dynamic_system_solver.cc:1196
MBSim::DynamicSystemSolver::LinkStatusParent
fmatvec::VecInt LinkStatusParent
status vector of set valued links with piecewise link equation (which piece is valid)
Definition: dynamic_system_solver.h:759
MBSim::DynamicSystem::updatewbRef
virtual void updatewbRef(fmatvec::Vec &wbParent)
references to TODO of dynamic system parent
Definition: dynamic_system.cc:829
MBSim::Group
group ingredients do not depend on each other
Definition: group.h:35
MBSim::DynamicSystemSolver::checkImpactsForTermination
void checkImpactsForTermination() override
validate force laws concerning given tolerances on velocity level
Definition: dynamic_system_solver.cc:737
MBSim::DynamicSystemSolver::getSolverInfo
std::string getSolverInfo()
Definition: dynamic_system_solver.cc:1295
MBSim::DynamicSystemSolver::z
fmatvec::Vec z
state vector
Definition: dynamic_system_solver.h:653
MBSim::Element
basic class of MBSim mainly for plotting
Definition: element.h:56
MBSim::DynamicSystemSolver::sigInterruptHandler
static void sigInterruptHandler(int)
handler for user interrupt signal
Definition: dynamic_system_solver.cc:1347
MBSim::DynamicSystemSolver::lmParm
double lmParm
Levenberg-Marquard parameter.
Definition: dynamic_system_solver.h:800
MBSim::DynamicSystemSolver::solveImpactsFixpointSingle
int solveImpactsFixpointSingle() override
solve impact equations with single step fixed point scheme on velocity level
Definition: dynamic_system_solver.cc:524
MBSim::DynamicSystemSolver::addElement
void addElement(Element *element_)
Definition: dynamic_system_solver.cc:1256
MBSim::DynamicSystemSolver::rFactorParent
fmatvec::Vec rFactorParent
relaxation parameters for contact equations
Definition: dynamic_system_solver.h:698
MBSim::DynamicSystemSolver::checkConstraintsForTermination
void checkConstraintsForTermination() override
validate force laws concerning given tolerances
Definition: dynamic_system_solver.cc:726
MBSim::DynamicSystem::updateWRef
virtual void updateWRef(fmatvec::Mat &WParent, int j=0)
references to contact force direction matrix of dynamic system parent
Definition: dynamic_system.cc:836
MBSim::DynamicSystemSolver::decreaseLevels
fmatvec::VecInt decreaseLevels
decreasing relaxation factors is done in levels containing the number of contact iterations as condit...
Definition: dynamic_system_solver.h:830
MBSim::DynamicSystemSolver::updatelaInverseKinetics
virtual void updatelaInverseKinetics()
update inverse kinetics constraint forces
Definition: dynamic_system_solver.cc:1653
MBSim::DynamicSystemSolver::tolLocalSolver
double tolLocalSolver
Tolerance for local none-linear solvers (solvers on element level)
Definition: dynamic_system_solver.h:860
MBSim::DynamicSystemSolver::setStopIfNoConvergence
void setStopIfNoConvergence(bool flag, bool dropInfo=false)
Definition: dynamic_system_solver.h:427
MBSim::DynamicSystemSolver::Residuum
Definition: dynamic_system_solver.h:63
MBSim::MBSimEnvironment
Definition: environment.h:59
MBSim::DynamicSystemSolver::updater
virtual void updater(int j=0)
update smooth link force law
Definition: dynamic_system_solver.cc:851
MBSim::DynamicSystemSolver::dropContactMatrices
void dropContactMatrices()
Definition: dynamic_system_solver.cc:1312
MBSim::DynamicSystemSolver::updatezdRef
void updatezdRef(fmatvec::Vec &ext)
references to differentiated external state
Definition: dynamic_system_solver.cc:1414
MBSim::DynamicSystemSolver::initialize
void initialize()
Initialize the system.
Definition: dynamic_system_solver.cc:106
MBSim::DynamicSystemSolver::updateG
virtual void updateG()
updates mass action matrix
Definition: dynamic_system_solver.cc:983
MBSim::DynamicSystemSolver::~DynamicSystemSolver
~DynamicSystemSolver() override
destructor
Definition: dynamic_system_solver.cc:98
MBSim::DynamicSystemSolver::numJac
bool numJac
flag if Jacobian for Newton scheme should be calculated numerically
Definition: dynamic_system_solver.h:825
MBSim::DynamicSystemSolver::setDynamicSystemSolverTolerance
void setDynamicSystemSolverTolerance(double tol)
set tolerance for global none-linear solver (solvers on DynamicSystemSolver level),...
Definition: dynamic_system_solver.h:500
MBSim::DynamicSystemSolver::WParent
fmatvec::Mat WParent[2]
contact force directions
Definition: dynamic_system_solver.h:678
MBSim::DynamicSystem::plot
void plot() override
plots time dependent data
Definition: dynamic_system.cc:344
MBSim::Graph
class for tree-structured mechanical systems with recursive and flat memory mechanism
Definition: graph.h:36
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::DynamicSystemSolver::setProjectionTolerance
void setProjectionTolerance(double tol)
set tolerance for projection of generalized position
Definition: dynamic_system_solver.h:487
MBSim::DynamicSystemSolver::solveImpacts_
int(DynamicSystemSolver::* solveImpacts_)()
function pointer for election of prox-solver for impact equations on velocity level
Definition: dynamic_system_solver.h:304
MBSim::DynamicSystemSolver::getElement
Element * getElement(const std::string &name)
Definition: dynamic_system_solver.cc:1268
MBSim::DynamicSystemSolver::positionDriftCompensationNeeded
bool positionDriftCompensationNeeded(double gmax)
check if drift compensation on position level is needed
Definition: dynamic_system_solver.cc:1106
MBSim::DynamicSystemSolver::jsvParent
fmatvec::VecInt jsvParent
boolean evaluation of stopvector
Definition: dynamic_system_solver.h:754
MBSim::DynamicSystemSolver::savela
void savela()
save contact forces for use as starting value in next time step
Definition: dynamic_system_solver.cc:1236
MBSim::DynamicSystemSolver::tolDSS
double tolDSS
Tolerance for global none-linear solvers (solvers on DynamicSystemSolver level)
Definition: dynamic_system_solver.h:865
MBSim::Function
Definition: contact_kinematics.h:32
MBSim::DynamicSystemSolver::projectGeneralizedPositions
void projectGeneralizedPositions(int mode, bool fullUpdate=false)
drift projection for positions
Definition: dynamic_system_solver.cc:1132
MBSim::DynamicSystemSolver::LLMParent
fmatvec::SymMat LLMParent
Cholesky decomposition of mass matrix.
Definition: dynamic_system_solver.h:668
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::DynamicSystemSolver::exitRequest
static std::atomic< bool > exitRequest
boolean signal evaluation for end integration set by user
Definition: dynamic_system_solver.h:915
MBSim::DynamicSystemSolver::limitGSize
int limitGSize
TODO.
Definition: dynamic_system_solver.h:845
MBSim::DynamicSystemSolver::MParent
fmatvec::SymMat MParent
mass matrix
Definition: dynamic_system_solver.h:663
MBSim::DynamicSystemSolver::peds
bool peds
TODO, flag for occuring impact and sticking in event driven solver.
Definition: dynamic_system_solver.h:850
MBSim::DynamicSystemSolver::hParent
fmatvec::Vec hParent[2]
smooth, smooth with respect to objects, smooth with respect to links right hand side
Definition: dynamic_system_solver.h:737
MBSim::DynamicSystemSolver::writeStateTable
void writeStateTable(std::string fileName)
writes state table to a file
Definition: dynamic_system_solver.cc:1383
MBSim::DynamicSystemSolver::constructor
void constructor()
set plot feature default values
Definition: dynamic_system_solver.cc:1428
MBSim::DynamicSystemSolver::G
fmatvec::SqrMat G
mass action matrix
Definition: dynamic_system_solver.h:780
MBSim::DynamicSystemSolver::dt
double dt
step size
Definition: dynamic_system_solver.h:643
MBSim::DynamicSystemSolver::saveLa
void saveLa()
save contact impulses for use as starting value in next time step
Definition: dynamic_system_solver.cc:1246
MBSim::DynamicSystemSolver::integratorExitRequest
bool integratorExitRequest
boolean signal evaluation for end integration set by program
Definition: dynamic_system_solver.h:910
MBSim::DynamicSystemSolver::wbParent
fmatvec::Vec wbParent
TODO.
Definition: dynamic_system_solver.h:688
MBSim::DynamicSystemSolver::addToGraph
void addToGraph(Graph *graph, fmatvec::SqrMat &A, int i, std::vector< Element * > &objList)
adds list of objects to tree
Definition: dynamic_system_solver.cc:1546
MBSim::DynamicSystem::updategRef
virtual void updategRef(fmatvec::Vec &gParent)
references to relative distances of dynamic system parent
Definition: dynamic_system.cc:794
MBSim::DynamicSystemSolver::updatewbRef
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: dynamic_system_solver.h:584
MBSim::DynamicSystem::la
fmatvec::Vec la
contact force parameters
Definition: dynamic_system.h:871
MBSim::DynamicSystemSolver::maxIter
int maxIter
maximum number of contact iterations, high number of contact iterations for warnings,...
Definition: dynamic_system_solver.h:795
MBSim::DynamicSystemSolver::getLinkStatus
void getLinkStatus(fmatvec::VecInt &LinkStatusExt)
Definition: dynamic_system_solver.cc:1090
MBSim::DynamicSystemSolver::Solver
Solver
solver for contact equations
Definition: dynamic_system_solver.h:76
MBSim::DynamicSystemSolver::getMBSimEnvironment
MBSimEnvironment * getMBSimEnvironment()
Definition: dynamic_system_solver.cc:1774
MBSim::DynamicSystemSolver::zParent
fmatvec::Vec zParent
state
Definition: dynamic_system_solver.h:725
MBSim::DynamicSystemSolver::laParent
fmatvec::Vec laParent
contact force parameters
Definition: dynamic_system_solver.h:693
MBSim::DynamicSystemSolver::resParent
fmatvec::Vec resParent
residuum of contact equations
Definition: dynamic_system_solver.h:708
MBSim::DynamicSystemSolver::velocityDriftCompensationNeeded
bool velocityDriftCompensationNeeded(double gdmax)
check if drift compensation on velocity level is needed
Definition: dynamic_system_solver.cc:1119
MBSim::DynamicSystemSolver::svParent
fmatvec::Vec svParent
stopvector (rootfunctions for event driven integration
Definition: dynamic_system_solver.h:749
MBSim::DynamicSystemSolver::Jprox
fmatvec::SqrMat Jprox
JACOBIAN of contact equations for Newton scheme.
Definition: dynamic_system_solver.h:775
MBSim::DynamicSystemSolver::VParent
fmatvec::Mat VParent[2]
condensed contact force directions
Definition: dynamic_system_solver.h:683
MBSim::DynamicSystemSolver::updatezRef
void updatezRef(fmatvec::Vec &ext)
references to external state
Definition: dynamic_system_solver.cc:1402
MBSim::DynamicSystemSolver::writez
void writez(std::string fileName, bool formatH5=true)
writes state to a file
Definition: dynamic_system_solver.cc:1361
MBSim::DynamicSystem::Jrla
fmatvec::Mat Jrla[2]
Jacobian dr/dla.
Definition: dynamic_system.h:861
MBSim::DynamicSystemSolver::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: dynamic_system_solver.cc:122
MBSim::DynamicSystemSolver::solveConstraintsRootFinding
int solveConstraintsRootFinding() override
solve contact equations with Newton scheme
Definition: dynamic_system_solver.cc:594
MBSim::DynamicSystemSolver::decreaserFactors
void decreaserFactors()
decrease relaxation factors if mass action matrix is not diagonal dominant
Definition: dynamic_system_solver.cc:1084
MBSim::DynamicSystemSolver::computeInitialCondition
void computeInitialCondition()
compute initial condition for links for event driven integrator
Definition: dynamic_system_solver.cc:902
MBSim::DynamicSystemSolver::READZ0
bool READZ0
is a state read from a file
Definition: dynamic_system_solver.h:916
MBSim::DynamicSystemSolver::solveImpactsRootFinding
int solveImpactsRootFinding() override
solve impact equations with Newton scheme on velocity level
Definition: dynamic_system_solver.cc:661
MBSim::DynamicSystemSolver::updategdRef
void updategdRef(fmatvec::Vec &ref) override
references to relative velocities of dynamic system parent
Definition: dynamic_system_solver.h:578
MBSim::DynamicSystem::updategdRef
virtual void updategdRef(fmatvec::Vec &gdParent)
references to relative velocities of dynamic system parent
Definition: dynamic_system.cc:801
MBSim::DynamicSystemSolver::zdParent
fmatvec::Vec zdParent
differentiated state
Definition: dynamic_system_solver.h:730
MBSim::DynamicSystemSolver::SignalHandler
Definition: dynamic_system_solver.h:438
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30