99 virtual void solveLinearProblem(
gsMatrix<T> &updateVector);
103 virtual T getResidue() {
return m_assembler.rhs().norm();}
154 void gsNewtonIterator<T>::solveLinearProblem(gsMatrix<T>& updateVector)
157 m_assembler.assemble();
163 m_solver.compute( m_assembler.matrix() );
164 updateVector = m_solver.solve( m_assembler.rhs() );
170 void gsNewtonIterator<T>::solveLinearProblem(
const gsMultiPatch<T> & currentSol, gsMatrix<T>& updateVector)
173 m_assembler.assemble(currentSol);
179 m_solver.compute( m_assembler.matrix() );
180 updateVector = m_solver.solve( m_assembler.rhs() );
191 const T initResidue = m_residue;
192 const T initUpdate = m_updnorm;
195 for (m_numIterations = 1; m_numIterations < m_maxIterations; ++m_numIterations)
197 gsDebug <<
"Newton iteration " << m_numIterations
203 if (
math::abs(m_updnorm / initUpdate) < m_tolerance ||
204 math::abs(m_residue / initResidue) < m_tolerance )
220 solveLinearProblem(m_updateVector);
223 m_assembler.constructSolution(m_updateVector, m_curSolution);
226 m_assembler.homogenizeFixedDofs(-1);
229 m_residue = getResidue();
230 m_updnorm = m_updateVector .norm();
233 <<
", residue: "<< m_residue
234 <<
", update norm: "<< m_updnorm
242 solveLinearProblem(m_curSolution, m_updateVector);
245 m_assembler.updateSolution(m_updateVector, m_curSolution);
248 m_residue = getResidue();
249 m_updnorm = m_updateVector.norm();
251 gsDebug<<
"Iteration: "<< m_numIterations
252 <<
", residue: "<< m_residue
253 <<
", update norm: "<< m_updnorm
gsAssembler< T > & m_assembler
gsAssemblerBase object to generate the linear system for each iteration
Definition: gsNewtonIterator.h:108
T m_residue
Final error.
Definition: gsNewtonIterator.h:139
Provides generic assembler routines.
T m_updnorm
Norm of the current Newton update vector.
Definition: gsNewtonIterator.h:142
Performs Newton iterations to solve a nonlinear system of PDEs.
Definition: gsNewtonIterator.h:31
#define gsDebug
Definition: gsDebug.h:61
#define index_t
Definition: gsConfig.h:32
gsMatrix< T > m_updateVector
Solution of the linear system in each iteration.
Definition: gsNewtonIterator.h:114
T m_tolerance
Tolerance value to decide convergence.
Definition: gsNewtonIterator.h:131
void setTolerance(T tol)
Set the tolerance for convergence.
Definition: gsNewtonIterator.h:95
bool m_converged
Convergence result.
Definition: gsNewtonIterator.h:136
index_t m_maxIterations
Maximum number of Newton iterations allowed.
Definition: gsNewtonIterator.h:128
void nextIteration()
Solves linear system in each iteration based on last solution and computes residual.
Definition: gsNewtonIterator.h:239
index_t m_numIterations
Number of Newton iterations performed.
Definition: gsNewtonIterator.h:125
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
bool converged() const
Tells whether the Newton method converged.
Definition: gsNewtonIterator.h:80
const gsMultiPatch< T > & solution() const
Returns the latest configuration.
Definition: gsNewtonIterator.h:77
T residue() const
Returns the error after solving the nonlinear system.
Definition: gsNewtonIterator.h:89
void solve()
Applies Newton method and Performs Newton iterations until convergence or maximum iterations...
Definition: gsNewtonIterator.h:187
gsSparseSolver::LU m_solver
Linear solver employed.
Definition: gsNewtonIterator.h:120
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4488
gsMultiPatch< T > m_curSolution
The latest/current solution.
Definition: gsNewtonIterator.h:111
The assembler class provides generic routines for volume and boundary integrals that are used for for...
Definition: gsAssembler.h:265
void setMaxIterations(index_t nIter)
Set the maximum number of Newton iterations allowed.
Definition: gsNewtonIterator.h:92
T tolerance() const
Returns the tolerance value used.
Definition: gsNewtonIterator.h:86
gsNewtonIterator(gsAssembler< T > &assembler, const gsMultiPatch< T > &initialSolution)
Definition: gsNewtonIterator.h:37
index_t numIterations() const
Returns the number of Newton iterations performed.
Definition: gsNewtonIterator.h:83
void firstIteration()
Solves linear system obtained using linear elasticity in first step and computes residual.
Definition: gsNewtonIterator.h:214