VertexCFD  0.0-dev
VertexCFD_LinearSolvers_SuperLU.hpp
1 #ifndef VERTEXCFD_LINEARSOLVERS_SUPERLUSOLVER_HPP
2 #define VERTEXCFD_LINEARSOLVERS_SUPERLUSOLVER_HPP
3 
4 #include "VertexCFD_LinearSolvers_LocalDirectSolver.hpp"
5 
6 // superlu_ddefs.h includes C macro that conflicts with some
7 // cuda libraries include files. So let's include it after
8 // everything else
9 #define GPU_ACC
10 #include <superlu_ddefs.h>
11 
12 namespace VertexCFD
13 {
14 namespace LinearSolvers
15 {
16 //---------------------------------------------------------------------------//
17 // Local preconditioner/solver using SuperLU for on-GPU solves.
18 //---------------------------------------------------------------------------//
20 {
21  static_assert(std::is_same<int_t, int>::value,
22  "SuperLU should be build with int_t=int");
23 
24  private:
25  // >>> DATA
26 
27  // Matrix
28  SuperMatrix _A;
29 
30  // Host-side matrix data
31  int* _A_rowptr_host;
32  int* _A_colind_host;
33  double* _A_values_host;
34 
35  // Persistent SuperLU info
36  gridinfo_t _grid;
37  superlu_dist_options_t _options;
38  dLUstruct_t _LUstruct;
39  dScalePermstruct_t _ScalePermstruct;
40  dSOLVEstruct_t _SOLVEstruct;
41 
42  // Status flags
43  bool _matrix_set;
44  bool _initialized;
45  bool _computed;
46  bool _factored;
47 
48  int _num_rows;
49 
50  public:
51  // Constructor
52  SuperLUSolver();
53 
54  ~SuperLUSolver();
55 
56  // Update internal matrix
57  void setMatrix(Teuchos::RCP<const Tpetra::RowMatrix<>> A) override;
58 
59  // Inherited interface from LocalDirectSolver
60  void initialize() override;
61  void compute() override;
62 
63  // Inherited interface from LocalDirectSolver
64  void
65  solve(const Tpetra::MultiVector<>& b, Tpetra::MultiVector<>& x) override;
66 };
67 
68 //---------------------------------------------------------------------------//
69 
70 } // namespace LinearSolvers
71 } // namespace VertexCFD
72 
73 #endif // VERTEXCFD_LINEARSOLVERS_SUPERLUSOLVER_HPP
VertexCFD::LinearSolvers::SuperLUSolver
Definition: VertexCFD_LinearSolvers_SuperLU.hpp:20
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23
VertexCFD::LinearSolvers::LocalDirectSolver
Definition: VertexCFD_LinearSolvers_LocalDirectSolver.hpp:19