jacobi.template
jacsolve.h
Go to the documentation of this file.
1 #ifndef JACSOLVE_FILE
2 #define JACSOLVE_FILE
3 #include "geom.h"
4 #include "getmatrix.h"
5 #include <vector>
6 
7 
16 void JacobiSolve(CRS_Matrix const &SK, std::vector<double> const &f, std::vector<double> &u);
17 
18 
34 void JacobiSmoother(Matrix const &SK, std::vector<double> const &f, std::vector<double> &u,
35  std::vector<double> & r, int nsmooth=1, double const omega=1.0, bool zero=false);
36 
49 void DiagPrecond(Matrix const &SK, std::vector<double> const &r, std::vector<double> &w,
50  double const omega=1.0);
51 
52 
53 
57 class Multigrid
58 {
59  public:
70  Multigrid(Mesh const& cmesh, int nlevel);
71 
72  Multigrid(Multigrid const&) = delete;
73  Multigrid& operator=(Multigrid const&) = delete;
74 
75  ~Multigrid();
76 
80  size_t Nlevels() const
81  {return _meshes.size(); }
82 
86  int Ndofs() const
87  {return _meshes[Nlevels()-1].Nnodes(); }
88 
92  Mesh const& GetMesh(int lev) const
93  { return _meshes[lev]; }
94 
98  std::vector<double> const& GetSolution(int lev) const
99  { return _u.at(lev); }
100 
104  void DefineOperators();
105 
111  void DefineOperator(size_t lev);
112 
118  void JacobiSolve(size_t lev);
119 
128  void MG_Step(size_t lev, int pre_smooth=1, bool const bzero=false, int nu=1);
129 
137  void MG_Solve(int pre_smooth=1, double eps=1e-6, int nu=1);
138 
139 
140  private:
142  std::vector<FEM_Matrix> _SK;
143  std::vector<std::vector<double>> _u;
144  std::vector<std::vector<double>> _f;
145  std::vector<std::vector<double>> _d;
146  std::vector<std::vector<double>> _w;
147  std::vector<BisectIntDirichlet> _Pc2f;
148 
149 };
150 
151 
152 
153 
154 #endif
Multigrid::MG_Solve
void MG_Solve(int pre_smooth=1, double eps=1e-6, int nu=1)
Definition: jacsolve.cpp:207
Multigrid::GetSolution
std::vector< double > const & GetSolution(int lev) const
Definition: jacsolve.h:98
Multigrid::_w
std::vector< std::vector< double > > _w
Correction vector on each level.
Definition: jacsolve.h:146
gMesh_Hierarchy
Definition: geom.h:546
Multigrid::_d
std::vector< std::vector< double > > _d
Defect vector on each level.
Definition: jacsolve.h:145
Multigrid::MG_Step
void MG_Step(size_t lev, int pre_smooth=1, bool const bzero=false, int nu=1)
Definition: jacsolve.cpp:170
Multigrid::GetMesh
Mesh const & GetMesh(int lev) const
Definition: jacsolve.h:92
Multigrid::_meshes
gMesh_Hierarchy _meshes
mesh hierarchy from coarse (level 0) to fine.
Definition: jacsolve.h:141
Multigrid::operator=
Multigrid & operator=(Multigrid const &)=delete
e
angle in trangle e
Definition: square_bb_4.m:62
Multigrid
The Multigrid hierarchy including meshes, vectors and matrices, prolongations is stored.
Definition: jacsolve.h:57
Multigrid::JacobiSolve
void JacobiSolve(size_t lev)
Definition: jacsolve.cpp:164
Mesh
Definition: geom.h:13
Multigrid::Ndofs
int Ndofs() const
Definition: jacsolve.h:86
Multigrid::DefineOperators
void DefineOperators()
Definition: jacsolve.cpp:137
Multigrid::_f
std::vector< std::vector< double > > _f
Right hand side vector on each level.
Definition: jacsolve.h:144
DiagPrecond
void DiagPrecond(Matrix const &SK, std::vector< double > const &r, std::vector< double > &w, double const omega=1.0)
Simple diagonale preconditioning.
Definition: jacsolve.cpp:89
u
u
Definition: laplacian.m:3
Multigrid::Nlevels
size_t Nlevels() const
Definition: jacsolve.h:80
Multigrid::_Pc2f
std::vector< BisectIntDirichlet > _Pc2f
Interpolation to level from next coarser level.
Definition: jacsolve.h:147
geom.h
Multigrid::~Multigrid
~Multigrid()
Definition: jacsolve.cpp:134
gMesh_Hierarchy::size
size_t size() const
Definition: geom.h:559
CRS_Matrix
Definition: getmatrix.h:131
Multigrid::DefineOperator
void DefineOperator(size_t lev)
Definition: jacsolve.cpp:146
getmatrix.h
JacobiSolve
void JacobiSolve(CRS_Matrix const &SK, std::vector< double > const &f, std::vector< double > &u)
Multigrid::_u
std::vector< std::vector< double > > _u
Solution vector on each level.
Definition: jacsolve.h:143
Matrix
Definition: getmatrix.h:11
JacobiSmoother
void JacobiSmoother(Matrix const &SK, std::vector< double > const &f, std::vector< double > &u, std::vector< double > &r, int nsmooth=1, double const omega=1.0, bool zero=false)
Definition: jacsolve.cpp:65
Multigrid::_SK
std::vector< FEM_Matrix > _SK
Sparse matrix on each level.
Definition: jacsolve.h:142
Multigrid::Multigrid
Multigrid(Mesh const &cmesh, int nlevel)
Definition: jacsolve.cpp:104