mbsim  4.0.0
MBSim Kernel
dae_integrator.h
1/* Copyright (C) 2004-2025 Martin Förg
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 *
18 * Contact:
19 * martin.o.foerg@googlemail.com
20 *
21 */
22
23#ifndef _DAE_INTEGRATOR_H_
24#define _DAE_INTEGRATOR_H_
25
26#include "implicit_integrator.h"
27#include <optional>
28
29namespace MBSim {
30
34
35 public:
36 enum Formalism {
37 ODE=0,
38 DAE1,
39 DAE2,
40 DAE3,
41 GGL,
42 unknown
43 };
44
45 protected:
46 // DAE1
47 void par_ud_xd_gdd_par_q_u(fmatvec::Mat &J, const fmatvec::Vec &ud_=fmatvec::Vec());
48 void par_zd_gdd_par_q_u(fmatvec::Mat &J, const fmatvec::Vec &ud_=fmatvec::Vec());
49 void par_ud_xd_par_x(fmatvec::Mat &J);
50 // DAE2
51 void par_ud_xd_gd_par_q(fmatvec::Mat &J);
52 void par_zd_gd_par_q(fmatvec::Mat &J);
53 // DAE3
54 void par_ud_xd_g_par_q(fmatvec::Mat &J);
55 void par_zd_g_par_q(fmatvec::Mat &J);
56 // GGL
57 void par_ud_xd_gd_g_par_q(fmatvec::Mat &J);
58 void par_zd_gd_g_par_q(fmatvec::Mat &J);
59
60 void calcSize() override;
61 void init() override;
62 virtual void reinit();
63
65 Formalism formalism{ODE};
66
68 fmatvec::Vec aTol;
69 std::optional<double> aTolScalar;
71 fmatvec::Vec rTol;
72 std::optional<double> rTolScalar;
73
74 std::optional<double> aTolPos, aTolVel, aTol1st, aTolForce, rTolPos, rTolVel, rTol1st, rTolForce;
75
76 int laInd, lInd;
77 fmatvec::Vec gd0, g0; // saved constraints
78 fmatvec::RangeV Rla, Rl; // ranges for la and GGL alg.-states
79 fmatvec::RangeV RlaMove, RlMove; // ranges for la and GGL alg.-states reduced by q
80
81 public:
82 ~DAEIntegrator() override = default;
83
84 void initializeUsingXML(xercesc::DOMElement *element) override;
85
86 void setFormalism(Formalism formalism_) { formalism = formalism_; }
87
88 void setAbsoluteTolerance(const fmatvec::Vec &aTol_) { aTol <<= aTol_; }
89 void setAbsoluteTolerance(double aTol_) { aTolScalar = aTol_; }
90 void setRelativeTolerance(const fmatvec::Vec &rTol_) { rTol <<= rTol_; }
91 void setRelativeTolerance(double rTol_) { rTolScalar = rTol_; }
92
93 void setAbsolutePositionTolerance(double aTolPos_) { aTolPos = aTolPos_; }
94 void setAbsoluteVelocityTolerance(double aTolVel_) { aTolVel = aTolVel_; }
95 void setAbsoluteFirstOrderTolerance(double aTol1st_) { aTol1st = aTol1st_; }
96 void setAbsoluteForceTolerance(double aTolForce_) { aTolForce = aTolForce_; }
97 void setRelativePositionTolerance(double rTolPos_) { rTolPos = rTolPos_; }
98 void setRelativeVelocityTolerance(double rTolVel_) { rTolVel = rTolVel_; }
99 void setRelativeFirstOrderTolerance(double rTol1st_) { rTol1st = rTol1st_; }
100 void setRelativeForceTolerance(double rTolForce_) { rTolForce = rTolForce_; }
101 };
102
103}
104
105#endif
Base class for all DAE integrators.
Definition: dae_integrator.h:33
fmatvec::Vec rTol
Definition: dae_integrator.h:71
fmatvec::Vec aTol
Definition: dae_integrator.h:68
void initializeUsingXML(xercesc::DOMElement *element) override
initialize integrator
Definition: dae_integrator.cc:301
Formalism formalism
Definition: dae_integrator.h:65
Base class for all implicit integrators.
Definition: implicit_integrator.h:34
namespace MBSim
Definition: bilateral_constraint.cc:30