23 template <
class T,
bool _NL>
24 template <
bool _nonlinear>
25 typename std::enable_if<(_nonlinear==false), gsStatus>::type
26 gsDynamicImplicitEuler<T,_NL>::_step_impl(
const T t,
const T dt, gsVector<T> & U, gsVector<T> & V, gsVector<T> & A)
const
35 sol.bottomRows(N) = V;
37 typename gsBlockOp<>::Ptr Amat;
40 gsGMRes<T> gmres(Amat);
42 gsSparseMatrix<T> eye(N,N);
46 gsSparseMatrix<T> M, C, K;
47 gsSparseMatrix<T> Minv;
50 this->_computeMass(t+dt,M);
51 this->_computeForce(t+dt,F);
52 this->_computeDamping(U,t+dt,C);
53 this->_computeJacobian(U,t,K);
56 Amat->addOperator(0,0,gsIdentityOp<T>::make(N) );
58 Amat->addOperator(0,1,makeMatrixOp( -dt*eye ) );
60 Amat->addOperator(1,0,makeMatrixOp( dt*K ) );
62 Amat->addOperator(1,1,makeMatrixOp( M + dt*C ) );
66 rhs.bottomRows(N) = dt*F + M*V;
69 gmres.solve(rhs,tmpsol);
71 U = tmpsol.topRows(N);
72 V = tmpsol.bottomRows(N);
74 this->_stepOutput(0,sol.norm(),0.);
80 template <
class T,
bool _NL>
81 template <
bool _nonlinear>
82 typename std::enable_if<(_nonlinear==true), gsStatus>::type
83 gsDynamicImplicitEuler<T,_NL>::_step_impl(
const T t,
const T dt, gsVector<T> & U, gsVector<T> & V, gsVector<T> & A)
const
92 sol.bottomRows(N) = V;
96 typename gsBlockOp<>::Ptr Amat;
99 gsGMRes<T> gmres(Amat);
101 gsSparseMatrix<T> eye(N,N);
105 gsSparseMatrix<T> M, C, K;
108 this->_computeMass(t+dt,M);
109 this->_computeDamping(U,t+dt,C);
110 this->_computeResidual(U,t+dt,R);
112 gsVector<T> rhs(2*N);
113 rhs.topRows(N) = - dt * V;
114 rhs.bottomRows(N) = dt * C * V + dt*(-R);
116 T tolU = m_options.getReal(
"TolU");
117 T tolF = m_options.getReal(
"TolF");
118 T updateNorm = 10.0*tolU;
119 T residualNorm = rhs.norm();
120 T residualNorm0 = (residualNorm!=0) ? residualNorm : 1;
123 for (
index_t numIterations = 0; numIterations < m_options.getInt(
"MaxIter"); ++numIterations)
126 if ((!m_options.getSwitch(
"Quasi")) || ((numIterations==0) || (numIterations % m_options.getInt(
"QuasiIterations") == 0)))
129 this->_computeDamping(U,t+dt,C);
130 this->_computeJacobian(U,t+dt,K);
133 Amat->addOperator(0,0,gsIdentityOp<T>::make(N) );
134 Amat->addOperator(0,1,makeMatrixOp(-dt*eye) );
135 Amat->addOperator(1,0,makeMatrixOp(dt*K) );
136 Amat->addOperator(1,1,makeMatrixOp(M + dt*C) );
138 rhs.topRows(N) = U - Uold - dt * V;
139 rhs.bottomRows(N) = M*(V - Vold) + dt * C * V + dt*(-R);
141 gmres.solve(-rhs,dsol);
144 solnorm = sol.norm();
145 dsolnorm = dsol.norm();
146 updateNorm = (solnorm != 0) ? dsolnorm / solnorm : dsolnorm;
149 V = sol.bottomRows(N);
151 this->_computeResidual(U,t,R);
152 residualNorm = rhs.norm() / residualNorm0;
154 this->_stepOutput(numIterations,residualNorm,updateNorm);
156 if ( (updateNorm<tolU && residualNorm<tolF) )
162 gsInfo<<
"maximum iterations reached. Solution did not converge\n";
166 template <
class T,
bool _NL>
172 status = _step_impl<_NL>(t,dt,U,V,A);
176 template <
class T,
bool _NL>
179 if (m_options.getSwitch(
"Verbose"))
182 gsInfo<<std::setw(4)<<std::left<<
"It.";
183 gsInfo<<std::setw(17)<<std::left<<
"|R|/|R0|";
184 gsInfo<<std::setw(17)<<std::left<<
"|dU|/|U0|"<<
"\n";
188 template <
class T,
bool _NL>
189 void gsDynamicImplicitEuler<T,_NL>::_stepOutput(
const index_t it,
const T resnorm,
const T updatenorm)
const
191 if (m_options.getSwitch(
"Verbose"))
194 gsInfo<<std::setw(4)<<std::left<<it;
195 gsInfo<<std::setw(17)<<std::left<<resnorm;
196 gsInfo<<std::setw(17)<<std::left<<updatenorm<<
"\n";
Simple class create a block preconditioner structure.
Preconditioned iterative solver using the generalized minimal residual method.
#define index_t
Definition: gsConfig.h:32
gsStatus
Definition: gsStructuralAnalysisTypes.h:20
gsStatus _step(const T t, const T dt, gsVector< T > &U, gsVector< T > &V, gsVector< T > &A) const override
Initialize the ALM.
Definition: gsDynamicImplicitEuler.hpp:167
#define gsInfo
Definition: gsDebug.h:43
Performs the arc length method to solve a nonlinear system of equations.
Definition: gsDynamicImplicitEuler.h:33
static uPtr make(index_t nRows, index_t nCols)
Make function returning a smart pointer.
Definition: gsBlockOp.h:60
Simple adapter classes to use matrices or linear solvers as gsLinearOperators.