Sandals  v0.0.0
A C++ library for ODEs/DAEs integration
Loading...
Searching...
No Matches
Implicit.hxx
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, Davide Stocco and Enrico Bertolazzi. *
3 * *
4 * The Sandals project is distributed under the BSD 2-Clause License. *
5 * *
6 * Davide Stocco Enrico Bertolazzi *
7 * University of Trento University of Trento *
8 * e-mail: davide.stocco@unitn.it e-mail: enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#pragma once
12
13#ifndef SANDALS_IMPLICIT_SYSTEM_HXX
14#define SANDALS_IMPLICIT_SYSTEM_HXX
15
16namespace Sandals
17{
18
19 /*\
20 | ___ _ _ _ _
21 | |_ _|_ __ ___ _ __ | (_) ___(_) |_
22 | | || '_ ` _ \| '_ \| | |/ __| | __|
23 | | || | | | | | |_) | | | (__| | |_
24 | |___|_| |_| |_| .__/|_|_|\___|_|\__|
25 | |_|
26 \*/
27
37 template <Integer N, Integer M>
39 {
40 public:
41 using Type = enum class Type : Integer {IMPLICIT=0, EXPLICIT=1, SEMIEXPLICIT=1};
42 using Pointer = std::shared_ptr<Implicit<N, M>>;
43 using VectorF = Eigen::Vector<Real, N>;
44 using MatrixJF = Eigen::Matrix<Real, N, N>;
45 using VectorH = Eigen::Vector<Real, M>;
46 using MatrixJH = Eigen::Matrix<Real, M, N>;
47
48 private:
49 Type m_type{Type::IMPLICIT};
50 std::string m_name;
51
52 protected:
53
59 Implicit(Type t_type, std::string t_name) : m_type(t_type), m_name(t_name) {}
60
61 public:
62
66 Implicit() : m_type(Type::IMPLICIT), m_name("(missing name)") {}
67
72 Implicit(std::string t_name) : m_type(Type::IMPLICIT), m_name(t_name) {}
73
77 virtual ~Implicit() {}
78
83 Type type() const {return this->m_type;}
84
89 bool is_implicit() const {return this->m_type == Type::IMPLICIT;}
90
95 bool is_explicit() const {return this->m_type == Type::EXPLICIT;}
96
101 bool is_semiexplicit() const {return this->m_type == Type::SEMIEXPLICIT;}
102
107 std::string & name() {return this->m_name;}
108
113 std::string const & name() const {return this->m_name;}
114
119 Integer equations_number() const {return N;}
120
125 Integer invariants_number() const {return M;}
126
134 virtual VectorF F(VectorF const &x, VectorF const &x_dot, Real t) const = 0;
135
150 virtual MatrixJF JF_x(VectorF const &x, VectorF const &x_dot, Real t) const = 0;
151
167 virtual MatrixJF JF_x_dot(VectorF const &x, VectorF const &x_dot, Real t) const = 0;
168
175 virtual VectorH h(VectorF const &x, Real t) const = 0;
176
190 virtual MatrixJH Jh_x(VectorF const &x, Real t) const = 0;
191
199 virtual bool in_domain(VectorF const &x, Real t) const = 0;
200
209 VectorF F_reverse(VectorF const &x, VectorF const &x_dot, Real t) const
210 {
211 return -this->F(x, -x_dot, -t);
212 }
213
224 MatrixJF JF_x_reverse(VectorF const &x, VectorF const &x_dot, Real t) const
225 {
226 return -this->JF_x(x, -x_dot, -t);
227 }
228
239 MatrixJF JF_x_dot_reverse(VectorF const &x, VectorF const &x_dot, Real t) const
240 {
241 return this->JF_x_dot(x, -x_dot, -t);
242 }
243
244 }; // class Implicit
245
246} // namespace Sandals
247
248#endif // SANDALS_IMPLICIT_SYSTEM_HXX
std::string m_name
Definition Implicit.hxx:50
virtual bool in_domain(VectorF const &x, Real t) const =0
Integer equations_number() const
Definition Implicit.hxx:119
Integer invariants_number() const
Definition Implicit.hxx:125
MatrixJF JF_x_dot_reverse(VectorF const &x, VectorF const &x_dot, Real t) const
Definition Implicit.hxx:239
bool is_implicit() const
Definition Implicit.hxx:89
virtual VectorH h(VectorF const &x, Real t) const =0
Eigen::Vector< Real, N > VectorF
Definition Implicit.hxx:43
virtual MatrixJF JF_x_dot(VectorF const &x, VectorF const &x_dot, Real t) const =0
std::string const & name() const
Definition Implicit.hxx:113
std::string & name()
Definition Implicit.hxx:107
virtual MatrixJH Jh_x(VectorF const &x, Real t) const =0
Eigen::Matrix< Real, N, N > MatrixJF
Definition Implicit.hxx:44
VectorF F_reverse(VectorF const &x, VectorF const &x_dot, Real t) const
Definition Implicit.hxx:209
virtual ~Implicit()
Definition Implicit.hxx:77
virtual VectorF F(VectorF const &x, VectorF const &x_dot, Real t) const =0
Type type() const
Definition Implicit.hxx:83
Eigen::Vector< Real, M > VectorH
Definition Implicit.hxx:45
Eigen::Matrix< Real, M, N > MatrixJH
Definition Implicit.hxx:46
bool is_explicit() const
Definition Implicit.hxx:95
bool is_semiexplicit() const
Definition Implicit.hxx:101
Implicit(std::string t_name)
Definition Implicit.hxx:72
virtual MatrixJF JF_x(VectorF const &x, VectorF const &x_dot, Real t) const =0
Type m_type
Definition Implicit.hxx:49
Implicit()
Definition Implicit.hxx:66
enum class Type :Integer {IMPLICIT=0, EXPLICIT=1, SEMIEXPLICIT=1} Type
Definition Implicit.hxx:41
std::shared_ptr< Implicit< N, M > > Pointer
Definition Implicit.hxx:42
MatrixJF JF_x_reverse(VectorF const &x, VectorF const &x_dot, Real t) const
Definition Implicit.hxx:224
Implicit(Type t_type, std::string t_name)
Definition Implicit.hxx:59
The namespace for the Sandals library.
Definition Sandals.hh:73
double Real
Definition Sandals.hh:84
int Integer
Definition Sandals.hh:85