G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsDynamicExplicitEuler.hpp
Go to the documentation of this file.
1
14#pragma once
15
16namespace gismo
17{
18
19// template <class T, bool _NL>
20// gsStatus gsDynamicExplicitEuler<T,_NL>::_step(const T dt)
21// {
22// gsVector<T> R;
23// gsSparseMatrix<T> M, C;
24// _computeResidual(m_U,m_time,R);
25// _computeDamping(m_U,m_time,C);
26// _computeMass(m_time,M);
27
28// m_Uold = m_U;
29// m_Vold = m_V;
30// m_Aold = m_A;
31
32// m_U = m_Uold + m_dt * m_Vold;
33// // if (m_lumped)
34// // {
35// // gsVector<T> M = _computeMassLumped(m_t);
36// // m_DeltaV = m_dt * M.cwiseProduct(R - C * m_Vold);// element-wise;
37// // }
38// // else
39// // {
40// // gsSparseMatrix<T> M = _computeMass(m_t);
41// m_solver->compute(M);
42// m_V = m_Vold + m_dt * m_solver->solve( R - C * m_Vold );
43// // }
44
45// m_time += m_dt;
46
47// return gsStatus::Success;
48// }
49
50template <class T, bool _NL>
51template <bool _nonlinear>
52typename std::enable_if<(_nonlinear==false), gsStatus>::type
53gsDynamicExplicitEuler<T,_NL>::_step_impl(const T t, const T dt, gsVector<T> & U, gsVector<T> & V, gsVector<T> & A) const
54{
55 gsVector<T> Uold = U;
56 gsVector<T> Vold = V;
57 gsVector<T> Aold = A;
58
59 index_t N = U.rows();
60 gsVector<T> sol(2*N);
61 sol.topRows(N) = Uold;
62 sol.bottomRows(N) = Vold;
63
64 gsVector<T> F;
65 gsSparseMatrix<T> M, Minv, C, K;
66
67 // Computed at t=t0
68 this->_computeMass(t,M);
69 this->_computeMassInverse(M,Minv);
70 this->_computeForce(t,F);
71 this->_computeDamping(U,t,C);
72 this->_computeJacobian(U,t,K);
73
74 this->_initOutput();
75 sol.topRows(N) += dt * Vold;
76 sol.bottomRows(N) += dt * Minv * (F - K * Uold - C * Vold);
77 this->_stepOutput(0,sol.norm(),0.);
78 gsDebugVar(sol.transpose());
79
80 U = sol.topRows(N);
81 V = sol.bottomRows(N);
82
83 if (math::isinf(sol.norm()) || math::isnan(sol.norm()))
85 else
86 return gsStatus::Success;
87}
88
89
90template <class T, bool _NL>
91template <bool _nonlinear>
92typename std::enable_if<(_nonlinear==true), gsStatus>::type
93gsDynamicExplicitEuler<T,_NL>::_step_impl(const T t, const T dt, gsVector<T> & U, gsVector<T> & V, gsVector<T> & A) const
94{
95 gsVector<T> Uold = U;
96 gsVector<T> Vold = V;
97 gsVector<T> Aold = A;
98
99 index_t N = U.rows();
100 gsVector<T> sol(2*N);
101 sol.topRows(N) = Uold;
102 sol.bottomRows(N) = Vold;
103
104 gsVector<T> R;
105 gsSparseMatrix<T> M, Minv, C, K;
106
107 // Computed at t=t0
108 this->_computeMass(t,M);
109 this->_computeMassInverse(M,Minv);
110 this->_computeDamping(Uold,t,C);
111 this->_computeResidual(Uold,t,R);
112
113 this->_initOutput();
114 sol.topRows(N) += dt * Vold;
115 sol.bottomRows(N) += dt * Minv * ( - R - C * Vold);
116 this->_stepOutput(0,sol.norm(),0.);
117
118 U = sol.topRows(N);
119 V = sol.bottomRows(N);
120
121 if (math::isinf(sol.norm()) || math::isnan(sol.norm()))
123 else
124 return gsStatus::Success;
125}
126
127template <class T, bool _NL>
129 gsVector<T> & U, gsVector<T> & V,
130 gsVector<T> & A) const
131{
133 status = _step_impl<_NL>(t,dt,U,V,A);
134 return status;
135}
136
137template <class T, bool _NL>
139{
140 if (m_options.getSwitch("Verbose"))
141 {
142 gsInfo<<"\t";
143 gsInfo<<std::setw(4)<<std::left<<"It.";
144 gsInfo<<std::setw(17)<<std::left<<"|R|";
145 gsInfo<<"\n";
146 }
147}
148
149template <class T, bool _NL>
150void gsDynamicExplicitEuler<T,_NL>::_stepOutput(const index_t it, const T resnorm, const T /*updatenorm*/) const
151{
152 if (m_options.getSwitch("Verbose"))
153 {
154 gsInfo<<"\t";
155 gsInfo<<std::setw(4)<<std::left<<it;
156 gsInfo<<std::setw(17)<<std::left<<resnorm;
157 gsInfo<<"\n";
158 }
159}
160
161} // namespace gismo
Performs the arc length method to solve a nonlinear system of equations.
Definition gsDynamicExplicitEuler.h:34
gsStatus _step(const T t, const T dt, gsVector< T > &U, gsVector< T > &V, gsVector< T > &A) const override
Initialize the ALM.
Definition gsDynamicExplicitEuler.hpp:128
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
@ Success
Successful.
@ NotConverged
Step did not converge.
@ NotStarted
ALM has not started yet.