19 template <
class T,
bool _NL>
22 Base::defaultOptions();
23 m_options.addReal(
"alpha",
"Beta parameter for Bathe's method, such that 0 =< 2 beta =< 1",0.25);
24 m_options.addReal(
"delta",
"Beta parameter for Bathe's method, such that 0 =< delta =< 1",0.50);
25 m_options.addReal(
"gamma",
"Beta parameter for Bathe's method, such that 0 =< gamma =< 1",0.50);
29 template <
class T,
bool _NL>
30 template <
bool _nonlinear>
31 typename std::enable_if<(_nonlinear==false), gsStatus>::type
34 T gamma = m_options.getReal(
"gamma");
45 this->_stageOutput(1);
46 Base::_step(t,gamma*dt,Ustep,Vstep,Astep);
53 this->_computeMass(t+dt,M);
54 this->_computeForce(t+dt,F);
55 this->_computeDamping(U,t+dt,C);
56 this->_computeJacobian(U,t+dt,K);
58 T c1 = (1-gamma)/(gamma*dt);
59 T c2 = (-1)/((1-gamma)*gamma*dt);
60 T c3 = (2-gamma)/((1-gamma)*dt);
63 gsMatrix<T> rhs = F - M*(c1*Vold+c2*Vstep+c1*c3*Uold+c3*c2*Ustep) - C*(c2*Ustep+c1*Uold);
65 this->_stageOutput(2);
67 typename gsSparseSolver<T>::uPtr solver;
70 U = solver->solve(rhs);
71 V = c1*Uold + c2*Ustep + c3*U;
72 A = c1*Vold + c2*Vstep + c3*V;
74 this->_stepOutput(0,(F - K*U - M * A - C * V).norm(),U.norm());
75 if (math::isinf(U.norm()) || math::isnan(U.norm()))
82 template <
class T,
bool _NL>
83 template <
bool _nonlinear>
84 typename std::enable_if<(_nonlinear==true), gsStatus>::type
87 T gamma = m_options.getReal(
"gamma");
89 T c1 = (1-gamma)/(gamma*dt);
90 T c2 = (-1)/((1-gamma)*gamma*dt);
91 T c3 = (2-gamma)/((1-gamma)*dt);
103 this->_stageOutput(1);
104 Base::_step(t,gamma*dt,Ustep,Vstep,Astep);
114 this->_computeMass(t+dt,M);
115 this->_computeDamping(U,t+dt,C);
116 this->_computeResidual(U,t+dt,R);
122 rhs = R - M*(c1*Vold+c2*Vstep+c1*c3*Uold+c3*c2*Ustep+c3*c3*U) - C*(c1*Uold+c2*Ustep+c3*U);
124 T tolU = m_options.getReal(
"TolU");
125 T tolF = m_options.getReal(
"TolF");
126 T updateNorm = 10.0*tolU;
127 T residualNorm = rhs.norm();
128 T residualNorm0 = (residualNorm!=0) ? residualNorm : 1;
131 for (
index_t numIterations = 0; numIterations < m_options.getInt(
"MaxIter"); ++numIterations)
133 if ((!m_options.getSwitch(
"Quasi")) || ((numIterations==0) || (numIterations % m_options.getInt(
"QuasiIterations") == 0)))
136 this->_computeDamping(U,t+dt,C);
137 this->_computeJacobian(U,t+dt,K);
140 lhs = K + c3*c3*M + c3*C;
142 typename gsSparseSolver<T>::uPtr solver;
144 solver->compute(lhs);
149 dU = solver->solve(rhs);
154 updateNorm = (Unorm!=0) ? dUnorm/Unorm : dUnorm;
156 this->_computeResidual(U,t+dt,R);
157 rhs = R - M*(c1*Vold+c2*Vstep+c1*c3*Uold+c3*c2*Ustep+c3*c3*U) - C*(c1*Uold+c2*Ustep+c3*U);
158 residualNorm = rhs.norm() / residualNorm0;
159 updateNorm = dU.norm() / U.norm();
161 this->_stepOutput(numIterations,residualNorm,updateNorm);
163 if ( (updateNorm<tolU && residualNorm<tolF) )
165 V = c1*Uold + c2*Ustep + c3*U;
166 A = c1*Vold + c2*Vstep + c3*V;
171 V = c1*Uold + c2*Ustep + c3*U;
172 A = c1*Vold + c2*Vstep + c3*V;
173 gsInfo<<
"maximum iterations reached. Solution did not converge\n";
177 template <
class T,
bool _NL>
183 status = _step_impl<_NL>(t,dt,U,V,A);
187 template <
class T,
bool _NL>
190 if (m_options.getSwitch(
"Verbose"))
192 gsInfo<<
"Stage "<<stage<<
":";
197 template <
class T,
bool _NL>
198 void gsDynamicBathe<T,_NL>::_initOutput()
const
200 if (m_options.getSwitch(
"Verbose"))
203 gsInfo<<std::setw(4)<<std::left<<
"It.";
204 gsInfo<<std::setw(17)<<std::left<<
"|R|/|R0|";
205 gsInfo<<std::setw(17)<<std::left<<
"|dU|/|U0|"<<
"\n";
209 template <
class T,
bool _NL>
210 void gsDynamicBathe<T,_NL>::_stepOutput(
const index_t it,
const T resnorm,
const T updatenorm)
const
212 if (m_options.getSwitch(
"Verbose"))
215 gsInfo<<std::setw(4)<<std::left<<it;
216 gsInfo<<std::setw(17)<<std::left<<resnorm;
217 gsInfo<<std::setw(17)<<std::left<<updatenorm<<
"\n";
gsStatus _step(const T t, const T dt, gsVector< T > &U, gsVector< T > &V, gsVector< T > &A) const override
Initialize the ALM.
Definition: gsDynamicBathe.hpp:178
virtual void defaultOptions() override
Set default options.
Definition: gsDynamicBathe.hpp:20
#define index_t
Definition: gsConfig.h:32
gsStatus
Definition: gsStructuralAnalysisTypes.h:20
Performs the arc length method to solve a nonlinear system of equations.
Definition: gsDynamicBathe.h:35
#define gsInfo
Definition: gsDebug.h:43
Abstract class for solvers. The solver interface is base on 3 methods: -compute set the system matrix...
Definition: gsSparseSolver.h:66
std::enable_if<(_nonlinear==false), gsStatus >::type _step_impl(const T t, const T dt, gsVector< T > &U, gsVector< T > &V, gsVector< T > &A) const
Definition: gsDynamicBathe.hpp:32