29 : assembler(assembler_),
30 m_options(defaultOptions())
42 : assembler(assembler_),
43 solVector(initFreeDoFs),
44 m_options(defaultOptions())
55 : assembler(assembler_),
56 solVector(initFreeDoFs),
57 fixedDoFs(initFixedDoFs),
58 m_options(defaultOptions())
69 initResidualNorm = 1.;
79 opt.
addInt(
"Solver",
"Linear solver to use",linear_solver::LU);
81 opt.
addInt(
"MaxIters",
"Maximum number of iterations per loop",50);
82 opt.
addReal(
"AbsTol",
"Absolute tolerance for the convergence cretiria",1e-12);
83 opt.
addReal(
"RelTol",
"Relative tolerance for the stopping criteria",1e-9);
85 opt.
addInt(
"Verbosity",
"Amount of information printed to the terminal: none, some, all",solver_verbosity::none);
86 opt.
addInt(
"IterType",
"Type of iteration: update or next/full",iteration_type::update);
101 gsInfo << status() << std::endl;
102 if (residualNorm < m_options.getReal(
"AbsTol") ||
103 updateNorm < m_options.getReal(
"AbsTol") ||
104 residualNorm/initResidualNorm < m_options.getReal(
"RelTol") ||
105 updateNorm/initUpdateNorm < m_options.getReal(
"RelTol"))
106 m_status = converged;
107 else if (numIterations == m_options.getInt(
"MaxIters"))
112 if (m_options.getInt(
"Verbosity") != solver_verbosity::none)
113 gsInfo << status() << std::endl;
120 if (numIterations == 1 && m_options.getInt(
"IterType") == iteration_type::update)
121 assembler.homogenizeFixedDofs(-1);
123 if (!assembler.assemble(solVector,fixedDoFs))
127 if (m_options.getInt(
"Solver") == linear_solver::LU)
129 #ifdef GISMO_WITH_PARDISO
130 gsSparseSolver<>::PardisoLU solver(assembler.matrix());
131 solutionVector = solver.solve(assembler.rhs());
133 gsSparseSolver<>::LU solver(assembler.matrix());
134 solutionVector = solver.solve(assembler.rhs());
139 #ifdef GISMO_WITH_PARDISO
140 gsSparseSolver<>::PardisoLDLT solver(assembler.matrix());
141 solutionVector = solver.solve(assembler.rhs());
143 gsSparseSolver<>::SimplicialLDLT solver(assembler.matrix());
144 solutionVector = solver.solve(assembler.rhs());
149 gsSparseSolver<>::BiCGSTABDiagonal solver(assembler.matrix());
150 solutionVector = solver.solve(assembler.rhs());
154 gsSparseSolver<>::CGDiagonal solver(assembler.matrix());
155 solutionVector = solver.solve(assembler.rhs());
158 if (m_options.getInt(
"IterType") == iteration_type::update)
160 updateNorm = solutionVector.norm();
161 residualNorm = assembler.rhs().norm();
162 solVector += solutionVector;
164 if (numIterations == 0)
166 fixedDoFs[d] += assembler.fixedDofs(d);
170 updateNorm = (solutionVector-solVector).norm();
172 solVector = solutionVector;
174 if (numIterations == 0)
175 fixedDoFs = assembler.allFixedDofs();
178 if (numIterations == 0)
180 initUpdateNorm = updateNorm;
181 initResidualNorm = residualNorm;
191 std::string statusString;
192 if (m_status == converged)
193 statusString =
"Iterative solver converged after " +
196 statusString =
"Iterative solver was interrupted after " +
199 statusString =
"Iterative solver was interrupted after " +
200 util::to_string(numIterations) +
" iteration(s) due to an invalid solution";
220 fixedDoFs[d] = ddofs[d];
227 solVecSaved = solVector;
228 ddofsSaved = fixedDoFs;
234 GISMO_ASSERT(solVecSaved.rows() == solVector.rows(),
"No state saved!");
235 solVector = solVecSaved;
236 fixedDoFs = ddofsSaved;
void saveState()
save solver state
Definition: gsIterative.hpp:225
virtual void setFixedDofs(const std::vector< gsMatrix< T > > &ddofs)
set all fixed degrees of freedom
Definition: gsIterative.hpp:211
gsMatrix< T > solVector
solution vector
Definition: gsIterative.h:108
bool compute()
computes update or the next solution
Definition: gsIterative.hpp:117
#define short_t
Definition: gsConfig.h:35
std::string to_string(const C &value)
Converts value to string, assuming "operator<<" defined on C.
Definition: gsUtils.h:56
gsIterative(gsBaseAssembler< T > &assembler_)
constructor without an initial guess. Assumes a zero initial guess.
Definition: gsIterative.hpp:28
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
static gsOptionList defaultOptions()
default option list. used for initialization
Definition: gsIterative.hpp:75
void reset()
reset the solver state
Definition: gsIterative.hpp:64
void solve()
solution procedure
Definition: gsIterative.hpp:91
std::string status()
return solver status as a string
Definition: gsIterative.hpp:189
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
each iteration yields an update
Definition: gsBaseUtils.h:94
std::vector< gsMatrix< T > > fixedDoFs
current Dirichlet DoFs that the solution satisfies
Definition: gsIterative.h:110
void recoverState()
recover solver state from saved state
Definition: gsIterative.hpp:232
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:201
Conjugate gradient solver with diagonal (a.k.a. Jacobi) preconditioning: iterative(!), simmetric, Eigen only.
Definition: gsBaseUtils.h:72
only essential output
Definition: gsBaseUtils.h:84
Base class for assemblers of gsElasticity.
#define gsInfo
Definition: gsDebug.h:43
method successfully converged
Definition: gsBaseUtils.h:100
Extends the gsAssembler class by adding functionality necessary for a general nonlinear solver...
Definition: gsALE.h:26
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:211
LU decomposition: direct, no matrix requirements, robust but a bit slow, Eigen and Pardiso available...
Definition: gsBaseUtils.h:70
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
Cholesky decomposition pivoting: direct, simmetric positive or negative semidefinite, rather fast, Eigen and Pardiso available.
Definition: gsBaseUtils.h:71
solver working
Definition: gsBaseUtils.h:102
solver was interrupted after exceeding the limit of iterations
Definition: gsBaseUtils.h:101
A class providing an iterative solver for nonlinear problems.
gsBaseAssembler< T > & assembler
assembler object that generates the linear system
Definition: gsIterative.h:106