G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsIterative.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <gsIO/gsOptionList.h>
20 #include <functional>
21 
22 namespace gismo
23 {
24 
25 template <class T>
26 class gsBaseAssembler;
27 // TODO correct
41 template <class T>
42 class gsIterative
43 {
44 public:
45  typedef memory::shared_ptr<gsIterative> Ptr;
46  typedef memory::unique_ptr<gsIterative> uPtr;
47 
49  gsIterative(gsBaseAssembler<T> & assembler_);
50 
55  gsIterative(gsBaseAssembler<T> & assembler_,
56  const gsMatrix<T> & initSolutionVector);
57 
61  gsIterative(gsBaseAssembler<T> & assembler_,
62  const gsMatrix<T> & initSolutionVector,
63  const std::vector<gsMatrix<T> > & initFixedDoFs);
64 
66  static gsOptionList defaultOptions();
67 
69  gsOptionList & options() { return m_options; }
70 
72  void solve();
73 
75  bool compute();
76 
78  const gsMatrix<T> & solution() const { return solVector; }
79 
81  const std::vector<gsMatrix<T> > & allFixedDofs() const { return fixedDoFs; }
82 
84  std::string status();
85 
87  void reset();
88 
90  virtual void setFixedDofs(const std::vector<gsMatrix<T> > & ddofs);
91 
94 
96  void setSolutionVector(const gsMatrix<T> & solutionVector) { solVector = solutionVector; }
97 
99  void saveState();
100 
102  void recoverState();
103 
104 protected:
110  std::vector<gsMatrix<T> > fixedDoFs;
120 
121  gsMatrix<T> solVecSaved;
122  std::vector<gsMatrix<T> > ddofsSaved;
123 };
124 
125 } // namespace ends
126 
127 #ifndef GISMO_BUILD_LIB
128 #include GISMO_HPP_HEADER(gsIterative.hpp)
129 #endif
void saveState()
save solver state
Definition: gsIterative.hpp:225
const gsMatrix< T > & solution() const
returns the solution vector
Definition: gsIterative.h:78
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
T initResidualNorm
norm of the residual vector
Definition: gsIterative.h:115
const std::vector< gsMatrix< T > > & allFixedDofs() const
returns the fixed degrees of freedom
Definition: gsIterative.h:81
T initUpdateNorm
norm of the update vector
Definition: gsIterative.h:117
gsIterative(gsBaseAssembler< T > &assembler_)
constructor without an initial guess. Assumes a zero initial guess.
Definition: gsIterative.hpp:28
solver_status
Specifies the status of the iterative solver.
Definition: gsBaseUtils.h:99
#define index_t
Definition: gsConfig.h:32
gsOptionList m_options
option list
Definition: gsIterative.h:119
void setSolutionVector(const gsMatrix< T > &solutionVector)
set initial guess
Definition: gsIterative.h:96
static gsOptionList defaultOptions()
default option list. used for initialization
Definition: gsIterative.hpp:75
index_t numIterations
-— status variables --— ///
Definition: gsIterative.h:112
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
std::vector< gsMatrix< T > > fixedDoFs
current Dirichlet DoFs that the solution satisfies
Definition: gsIterative.h:110
Provides several simple utility and naming classes.
void recoverState()
recover solver state from saved state
Definition: gsIterative.hpp:232
Provides a list of labeled parameters/options that can be set and accessed easily.
index_t numberIterations() const
number of iteration that Newton&#39;s method took
Definition: gsIterative.h:93
gsOptionList & options()
get options list to read or set parameters
Definition: gsIterative.h:69
T updateNorm
norm of the residual vector at the beginning of the loop
Definition: gsIterative.h:116
Extends the gsAssembler class by adding functionality necessary for a general nonlinear solver...
Definition: gsALE.h:26
T residualNorm
status of the solver (converged, interrupted, working)
Definition: gsIterative.h:114
solver_status m_status
number of iterations performed
Definition: gsIterative.h:113
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
gsBaseAssembler< T > & assembler
assembler object that generates the linear system
Definition: gsIterative.h:106