Class documentation of Concepts

Loading...
Searching...
No Matches
newton.hh
Go to the documentation of this file.
1
8#ifndef newton_hh
9#define newton_hh
10
11#include <type_traits>
12#include "basics/debug.hh"
13
14#define NEWTON_CONST_D 0
15
16
17#if defined(__clang__)
18#include <functional>
19#endif
20
21#if defined(__GNUC__)
22#if __GNUC__ >= 7
23#include <functional>
24#endif
25#endif
26
27namespace concepts
28{
29 // ****************************************************** Newton **
30
34 template<class F>
35 class Newton: public VecOperator<typename F::d_type >
36 {
37 public:
38
39 typename F::d_type type;
40
41#include "basics/warnings/push.h"
42#include "basics/warnings/ignore_warning_dangling_field.h"
52 Real tol = 1e-8, Real iterMax = 1000) :
53 VecOperator<typename F::d_type>(dimY, dimX), A_(A), JacA_(nullptr), definedJacA_(false), dx_(dx), dimY_(dimY), dimX_(dimX),
55 DEBUGL(NEWTON_CONST_D, "Newton solver with implicit computation of the Jacobian built");
56 };
57
68 uint dimX, Real tol = 1e-8, Real iterMax = 50) :
69 VecOperator<typename F::d_type>(dimY, dimX), A_(A), JacA_(&JacA), definedJacA_(true), dx_(0.), dimY_(dimY), dimX_(dimX),
71 DEBUGL(NEWTON_CONST_D, "Newton solver with explicit Jacobian built");
72 };
73#include "basics/warnings/pop.h"
74
75 virtual ~Newton() {};
76
77 virtual void show_messages();
78
79 virtual void hide_messages();
80
81 virtual void apply_(const Vector<typename F::d_type>& fncY,
83
84 virtual void apply_();
85
86 protected:
87
88#include "basics/warnings/push.h"
89#include "basics/warnings/ignore_warning_dangling_field.h"
90
92 std::function<Vector<typename F::d_type>(Vector<typename F::d_type>)>& A_;
93
96
97#include "basics/warnings/pop.h"
98
101
104
107
110
113
116
119
121 std::unique_ptr<concepts::Operator<typename F::d_type> > linearSolver_;
122
124 virtual void setLinearSolver_(F* Jacobian);
125
126 };
127}
128
129#endif
virtual void setLinearSolver_(F *Jacobian)
Set linear solver.
std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)> & A_
Function that evaluates the matrix A applied to vector X.
Definition newton.hh:92
bool definedJacA_
Flag that states if the Jacobian matrix has been set.
Definition newton.hh:100
uint dimY_
Size of the data.
Definition newton.hh:106
uint iterMax_
Maximum number of iterations.
Definition newton.hh:115
std::function< F(Vector< typename F::d_type >)> * JacA_
Function that evaluates the Jacobian of matrix A applied to vector X.
Definition newton.hh:95
std::unique_ptr< concepts::Operator< typename F::d_type > > linearSolver_
Internal linear solver.
Definition newton.hh:121
virtual void apply_()
Newton(std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)> A, std::function< F(Vector< typename F::d_type >)> JacA, uint dimY, uint dimX, Real tol=1e-8, Real iterMax=50)
Definition newton.hh:67
Real dx_
Step for the computation of the pseudo-Jacobian.
Definition newton.hh:103
Real tol_
Tolerance for the functional.
Definition newton.hh:112
bool verbose_
Internal flag for verbosity.
Definition newton.hh:118
uint dimX_
Size of the unknown.
Definition newton.hh:109
Newton(std::function< Vector< typename F::d_type >(Vector< typename F::d_type >)> A, Real dx, uint dimY, uint dimX, Real tol=1e-8, Real iterMax=1000)
Definition newton.hh:51
F type
Type of data, e.g. matrix entries.
#define DEBUGL(doit, msg)
Definition debug.hh:40
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320