1 #ifndef DEF_ABSTRACT_RKMK_STEP 2 #define DEF_ABSTRACT_RKMK_STEP 7 #include "include/Problem/ProblemInterface.hpp" 8 #include "include/Common/Utils.hpp" 12 template <
typename T_M,
14 typename T_LIE_ALGEBRA,
15 int T_N_INTERNAL_STAGES>
22 T_LIE_ALGEBRA m_solution;
26 double m_a_coeffs [T_N_INTERNAL_STAGES * T_N_INTERNAL_STAGES];
27 double m_b_coeffs [T_N_INTERNAL_STAGES];
28 T_LIE_ALGEBRA m_k [T_N_INTERNAL_STAGES];
29 unsigned int m_order_q;
33 : m_interface(interface)
34 { setTruncatureOrder(); }
49 m_solution = other.m_solution;
50 m_interface = other.m_interface;
51 std::copy(std::begin(other.m_a_coeffs),std::end(other.m_a_coeffs),std::begin(m_a_coeffs));
52 std::copy(std::begin(other.m_b_coeffs),std::end(other.m_b_coeffs),std::begin(m_b_coeffs));
53 std::copy(std::begin(other.m_k),std::end(other.m_k),std::begin(m_k));
54 m_order_q = other.m_order_q;
58 a_coeffs (
int i,
int j)
const 59 {
return m_a_coeffs[i*T_N_INTERNAL_STAGES+j]; }
62 setData (T_M h_var, T_Q y0_var)
69 setCoeffs (std::vector<double> a, std::vector<double> b)
71 if ((a.size()!=T_N_INTERNAL_STAGES*T_N_INTERNAL_STAGES) || (b.size()!=T_N_INTERNAL_STAGES))
73 for (
int i=0; i<T_N_INTERNAL_STAGES; i++)
75 for (
int i=0; i<T_N_INTERNAL_STAGES*T_N_INTERNAL_STAGES; i++)
81 setTruncatureOrder ( )
82 { m_order_q = std::max(0,T_N_INTERNAL_STAGES-2); }
93 T_LIE_ALGEBRA omega0 = T_LIE_ALGEBRA::Zero();
94 T_LIE_ALGEBRA omega = omega0;
95 T_LIE_ALGEBRA sol = omega0;
99 for (i=0; i<T_N_INTERNAL_STAGES; i++) {
103 for (j=0; j<T_N_INTERNAL_STAGES; j++) {
104 omega += this->m_k[j]*this->m_h*this->a_coeffs(i,j);
107 this->m_interface.computeA(A,omega.exp()*this->m_y0);
109 this->m_k[i] = omega.computeDExpRInv(A,this->m_order_q);
110 sol += this->m_b_coeffs[i]*this->m_h*this->m_k[i];
113 this->m_solution = sol;
122 T_LIE_ALGEBRA w(solution);
123 return T_Q(w.exp()*m_y0);
128 {
return this->reconstruct(this->m_solution.toVector()); }
142 computeA (T_LIE_ALGEBRA& A,
const T_Q& y)
143 {
return m_interface.computeA(A,y); }
146 computeJacobianA (std::vector<T_LIE_ALGEBRA>& JA,
const T_Q& y)
147 {
return m_interface.computeJacobianA(JA,y); }
160 template <
typename T_M,
162 typename T_LIE_ALGEBRA,
163 int T_N_INTERNAL_STAGES>
172 static const char TYPE_UNKNOWN = 0;
173 static const char TYPE_EXPLICIT = 1;
174 static const char TYPE_DIAGONAL_IMPLICIT = 2;
179 : m_interface(interface)
200 setCoeffs (std::vector<double> a, std::vector<double> b)
const 201 {
return m_internals->setCoeffs(a,b); }
204 setData (T_M h_var, T_Q y0_var)
205 { m_internals->setData(h_var,y0_var); }
212 bool isExplicit =
true;
215 for (i=0; i<T_N_INTERNAL_STAGES; i++) {
216 isExplicit &= isZero<double>(m_internals->a_coeffs(i,i));
217 for (j=i+1; j<T_N_INTERNAL_STAGES; j++) {
218 tmp_isZero = isZero<double>(m_internals->a_coeffs(i,j));
219 isExplicit &= tmp_isZero;
220 isDIRK &= tmp_isZero;
225 m_type = TYPE_EXPLICIT;
227 m_type = TYPE_DIAGONAL_IMPLICIT;
229 m_type = TYPE_UNKNOWN;
Definition: ProblemInterface.hpp:10
Definition: AbstractRKMKStep.hpp:16
Definition: Factory.hpp:8
bool computeSolution(void)
Definition: AbstractRKMKStep.hpp:89
Definition: AbstractRKMKStep.hpp:164
Definition: AbstractStep.hpp:9
Definition: NOXVector.hpp:14