18template <
class T,
bool _NL>
19template <
bool _nonlinear>
20typename std::enable_if<(_nonlinear==
false),
gsStatus>::type
21gsDynamicRK4<T,_NL>::_step_impl(
const T t,
const T dt, gsVector<T> & U, gsVector<T> & V, gsVector<T> & A)
const
31 sol.topRows(N) = Uold;
32 sol.bottomRows(N) = Vold;
35 gsSparseMatrix<T> M, Minv, C, K;
38 this->_computeMass(t,M);
39 this->_computeMassInverse(M,Minv);
41 this->_computeDamping(U,t,C);
42 this->_computeJacobian(U,t,K);
46 gsVector<T> k1(2*N), k2(2*N), k3(2*N), k4(2*N);
47 gsVector<T> Utmp, Vtmp;
53 k1.bottomRows(N) = Minv * (R - C * Vold);
56 Utmp = Uold + dt/2. * k1.topRows(N);
57 Vtmp = Vold + dt/2. * k1.bottomRows(N);
58 _computeForce(t + dt/2.,F);
61 k2.bottomRows(N) = Minv * ( R - C * Vtmp);
64 Utmp = Uold + dt/2. * k2.topRows(N);
65 Vtmp = Vold + dt/2. * k2.bottomRows(N);
66 _computeForce(t + dt/2., F);
69 k3.bottomRows(N) = Minv * ( R - C * Vtmp);
72 Utmp = Uold + dt/2. * k3.topRows(N);
73 Vtmp = Vold + dt/2. * k3.bottomRows(N);
74 _computeForce(t + dt/2., F);
77 k4.bottomRows(N) = Minv * ( R - C * Vtmp);
79 sol += 1./6 * dt * (k1 + 2.*k2 + 2.*k3 + k4);
81 U = std::move(sol.topRows(N));
82 V = std::move(sol.bottomRows(N));
84 if (math::isinf(sol.norm()) || math::isnan(sol.norm()))
91template <
class T,
bool _NL>
92template <
bool _nonlinear>
93typename std::enable_if<(_nonlinear==
true),
gsStatus>::type
94gsDynamicRK4<T,_NL>::_step_impl(
const T t,
const T dt, gsVector<T> & U, gsVector<T> & V, gsVector<T> & A)
const
100 gsVector<T> Aold = A;
103 gsVector<T> sol(2*N);
104 sol.topRows(N) = Uold;
105 sol.bottomRows(N) = Vold;
108 gsSparseMatrix<T> M, Minv, C, K;
111 this->_computeMass(t,M);
112 this->_computeMassInverse(M,Minv);
114 this->_computeDamping(U,t,C);
115 this->_computeJacobian(U,t,K);
119 gsVector<T> k1(2*N), k2(2*N), k3(2*N), k4(2*N);
120 gsVector<T> Utmp, Vtmp;
123 _computeResidual(Uold, t, R);
124 k1.topRows(N) = Vold;
125 k1.bottomRows(N) = Minv * (R - C * Vold);
128 Utmp = Uold + dt/2. * k1.topRows(N);
129 Vtmp = Vold + dt/2. * k1.bottomRows(N);
130 _computeResidual(Utmp,t + dt/2.,R);
131 k2.topRows(N) = Vtmp;
132 k2.bottomRows(N) = Minv * ( R - C * Vtmp);
135 Utmp = Uold + dt/2. * k2.topRows(N);
136 Vtmp = Vold + dt/2. * k2.bottomRows(N);
137 _computeResidual(Utmp,t + dt/2.,R);
138 k3.topRows(N) = Vtmp;
139 k3.bottomRows(N) = Minv * ( R - C * Vtmp);
142 Utmp = Uold + dt/2. * k3.topRows(N);
143 Vtmp = Vold + dt/2. * k3.bottomRows(N);
144 _computeResidual(Utmp,t + dt/2.,R);
145 k4.topRows(N) = Vtmp;
146 k4.bottomRows(N) = Minv * ( R - C * Vtmp);
148 sol += 1./6 * dt * (k1 + 2.*k2 + 2.*k3 + k4);
150 U = std::move(sol.topRows(N));
151 V = std::move(sol.bottomRows(N));
153 if (math::isinf(sol.norm()) || math::isnan(sol.norm()))
159template <
class T,
bool _NL>
165 status = _step_impl<_NL>(t,dt,U,V,A);
169template <
class T,
bool _NL>
172 if (m_options.getSwitch(
"Verbose"))
175 gsInfo<<std::setw(4)<<std::left<<
"It.";
176 gsInfo<<std::setw(17)<<std::left<<
"|R|";
181template <
class T,
bool _NL>
182void gsDynamicRK4<T,_NL>::_stepOutput(
const index_t it,
const T resnorm,
const T )
const
184 if (m_options.getSwitch(
"Verbose"))
187 gsInfo<<std::setw(4)<<std::left<<it;
188 gsInfo<<std::setw(17)<<std::left<<resnorm;
Performs the arc length method to solve a nonlinear system of equations.
Definition gsDynamicRK4.h:34
gsStatus _step(const T t, const T dt, gsVector< T > &U, gsVector< T > &V, gsVector< T > &A) const
Initialize the ALM.
Definition gsDynamicRK4.hpp:160
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
The G+Smo namespace, containing all definitions for the library.
gsStatus
Definition gsStructuralAnalysisTypes.h:21
@ NotConverged
Step did not converge.
@ NotStarted
ALM has not started yet.