Hypre.hxx
1 #ifndef SELDON_FILE_HYPRE_HXX
2 
3 #include "HYPRE.h"
4 #include "HYPRE_parcsr_ls.h"
5 #include "_hypre_parcsr_mv.h"
6 
7 namespace Seldon
8 {
9 
11 
14  template<class T>
16  {
17  protected:
19  HYPRE_IJMatrix A;
20  HYPRE_ParCSRMatrix parcsr_A;
21 
23  HYPRE_Solver solver;
24  bool solver_created;
25 
27  HYPRE_IJVector vec_b, vec_x;
28  HYPRE_ParVector par_x;
29  HYPRE_ParVector par_b;
30 
35 
38 
41 
43  int nodl_scalar, nb_u;
44 
46  MPI_Comm comm;
47 
50 
53 
54  // parameters for Boomer AMG
55  int amg_max_levels, amg_num_sweeps, amg_smoother;
56 
57  // parameters for ParaSails
58  HYPRE_Real sai_filter, sai_threshold;
59  int sai_max_levels, sai_sym;
60 
61  // parameters for Euclid
62  int euclid_level;
63  bool euclid_use_ilut;
64  HYPRE_Real euclid_threshold, euclid_droptol;
65 
66  public:
67 
69  enum {BOOMER_AMG, PARASAILS, EUCLID, AMS};
70 
72  enum {JACOBI=0, GS_SEQ=1, GS_PAR_SEQ=2, HYBRID_GS_BACKWARD=3, HYBRID_GS_FORWARD=4,
73  HYBRID_GS_SYMMETRIC=6, L1_GAUSS_SEIDEL=8, CHEBYSHEV=16, FCF_JACOBI=17, L1_JACOBI=18};
74 
75 
78 
79  void Clear();
80 
81  // inline methods
82  void SetPreconditioner(int type);
83  void SetSmoother(int type);
84  void SetLevelEuclid(int lvl);
85  void ShowMessages();
86 
87  // specifying preconditioning with a line of a data file
88  void SetInputPreconditioning(const string&, const Vector<string>&);
89 
90  // main method constructing the preconditioning
91  template<class Prop, class Storage, class Allocator>
92  void ConstructPreconditioner(DistributedMatrix<HYPRE_Complex, Prop, Storage, Allocator>& A0,
93  bool keep_matrix = false);
94 
95  protected:
96  // internal method
97  void FinalizePreconditioner(Vector<int>& row_numbers, Vector<long>& size_rows,
98  Vector<int>& cols, Vector<HYPRE_Complex>& values);
99 
100  public :
101  // methods to apply preconditioning
102  void Solve(const SeldonTranspose& trans, const VirtualMatrix<T>& A,
103  const Vector<T>& r, Vector<T>& z);
104 
105  void Solve(const VirtualMatrix<T>& A, const Vector<T>& r, Vector<T>& z);
106  void TransSolve(const VirtualMatrix<T>& A, const Vector<T>& r, Vector<T>& z);
107 
108  };
109 
110 
111 }
112 
113 #define SELDON_FILE_HYPRE_HXX
114 #endif
115 
Seldon::HyprePreconditioner::vec_b
HYPRE_IJVector vec_b
intermediary vectors x and b
Definition: Hypre.hxx:27
Seldon::HyprePreconditioner::~HyprePreconditioner
~HyprePreconditioner()
destructor
Definition: Hypre.cxx:43
Seldon::HyprePreconditioner::local_rows
Vector< int > local_rows
row numbers of original rows (that belong to only one processor) In Seldon row numbers can be shared,...
Definition: Hypre.hxx:34
Seldon::HyprePreconditioner::TransSolve
void TransSolve(const VirtualMatrix< T > &A, const Vector< T > &r, Vector< T > &z)
applies transpose preconditioning
Definition: HypreInline.cxx:49
Seldon::Vector< int >
Seldon::HyprePreconditioner::HyprePreconditioner
HyprePreconditioner()
default constructor
Definition: Hypre.cxx:11
Seldon::HyprePreconditioner::comm
MPI_Comm comm
MPI communicator.
Definition: Hypre.hxx:46
Seldon::HyprePreconditioner::FinalizePreconditioner
void FinalizePreconditioner(Vector< int > &row_numbers, Vector< long > &size_rows, Vector< int > &cols, Vector< HYPRE_Complex > &values)
internal function to finalize the computation of preconditioning
Definition: Hypre.cxx:211
Seldon::HyprePreconditioner::SetInputPreconditioning
void SetInputPreconditioning(const string &, const Vector< string > &)
sets parameters from a keyword and associated parameters
Definition: Hypre.cxx:75
Seldon::HyprePreconditioner::SetLevelEuclid
void SetLevelEuclid(int lvl)
sets the level k of ILU(k) factorization
Definition: HypreInline.cxx:24
Seldon::HyprePreconditioner::Solve
void Solve(const SeldonTranspose &trans, const VirtualMatrix< T > &A, const Vector< T > &r, Vector< T > &z)
applies preconditioning z = M r (or its transpose z = M^T r)
Definition: Hypre.cxx:324
Seldon::HyprePreconditioner::nodl_scalar
int nodl_scalar
number of rows for an unknown and the number of unknowns
Definition: Hypre.hxx:43
Seldon::HyprePreconditioner::DofNumber
Vector< Vector< int > > * DofNumber
list of rows implied in the assembling step
Definition: Hypre.hxx:40
Seldon::HyprePreconditioner::SetSmoother
void SetSmoother(int type)
sets smoother to use for AMG
Definition: HypreInline.cxx:16
Seldon::HyprePreconditioner
class interfacing Hypre with Seldon (as a preconditioner)
Definition: Hypre.hxx:15
Seldon::HyprePreconditioner::Clear
void Clear()
erases the current object
Definition: Hypre.cxx:51
Seldon::HyprePreconditioner::SetPreconditioner
void SetPreconditioner(int type)
sets which preconditioning to use (among choices proposed in hypre)
Definition: HypreInline.cxx:8
Seldon::HyprePreconditioner::A
HYPRE_IJMatrix A
distributed matrix stored as in hypre
Definition: Hypre.hxx:19
Seldon::HyprePreconditioner::solver
HYPRE_Solver solver
hypre solver
Definition: Hypre.hxx:23
Seldon::HyprePreconditioner::print_level
int print_level
verbose level
Definition: Hypre.hxx:49
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::HyprePreconditioner::ConstructPreconditioner
void ConstructPreconditioner(DistributedMatrix< HYPRE_Complex, Prop, Storage, Allocator > &A0, bool keep_matrix=false)
main function constructing hypre preconditioning from a given sparse matrix
Definition: Hypre.cxx:161
Seldon::HyprePreconditioner::ProcNumber
Vector< int > * ProcNumber
list of processors implied in the assembling step
Definition: Hypre.hxx:37
Seldon::HyprePreconditioner::ShowMessages
void ShowMessages()
shows informations about preconditioning
Definition: HypreInline.cxx:32
Seldon::HyprePreconditioner::type_preconditioner
int type_preconditioner
hypre preconditioning selected
Definition: Hypre.hxx:52
Seldon::Preconditioner_Base
Base class for preconditioners.
Definition: Iterative.hxx:26