FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
cusolver.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
8
9#include <kernel/solver/base.hpp>
10#include <kernel/lafem/dense_vector.hpp>
11#include <kernel/lafem/sparse_matrix_csr.hpp>
12
13namespace FEAT
14{
15 namespace Solver
16 {
17 namespace Intern
18 {
19 int cuda_lu(int n, int nnzA, const double * csrValA, const int * csrRowPtrA, const int * csrColIndA,
20 const double * b, double * x);
21
22 int cuda_qr(int m, int nnz, const double * csrValA, const int * csrRowPtrA, const int * csrColIndA,
23 const double * b, double * x);
24 }
25
36 class CuSolverLU :
37 public SolverBase<LAFEM::DenseVector<double, unsigned int>>
38 {
39 private:
42
43 public:
51 _system_matrix(system_matrix)
52 {
53 }
54
56 virtual String name() const override
57 {
58 return "CuSolverLU";
59 }
60
72 {
73 int status = Intern::cuda_lu((int)x.size(), (int)_system_matrix.used_elements(), _system_matrix.val(), (const int*) _system_matrix.row_ptr(), (const int*) _system_matrix.col_ind(), b.elements(), x.elements());
74
75 return (status == 0) ? Status::success : Status::aborted;
76 }
77 };
78
89 class CuSolverQR :
90 public SolverBase<LAFEM::DenseVector<double, unsigned int>>
91 {
92 private:
95 public:
103 _system_matrix(system_matrix)
104 {
105 }
106
108 virtual String name() const override
109 {
110 return "CuSolverQR";
111 }
112
114 {
115 int status = Intern::cuda_qr((int)x.size(), (int)_system_matrix.used_elements(), _system_matrix.val(), (const int*) _system_matrix.row_ptr(), (const int*) _system_matrix.col_ind(), b.elements(), x.elements());
116
117 return (status == 0) ? Status::success : Status::aborted;
118 }
119 };
120 } // namespace LAFEM
121} // namespace FEAT
FEAT Kernel base header.
Index size() const
Returns the containers size.
Definition: container.hpp:1136
Dense data vector class template.
DT_ * elements()
Get a pointer to the data array.
CSR based sparse matrix.
IT_ * col_ind()
Retrieve column indices array.
DT_ * val()
Retrieve non zero element array.
Index used_elements() const
Retrieve non zero element count.
IT_ * row_ptr()
Retrieve row start index array.
CuSolverLU solver class.
Definition: cusolver.hpp:38
CuSolverLU(const LAFEM::SparseMatrixCSR< double, unsigned int > &system_matrix)
Constructor.
Definition: cusolver.hpp:50
virtual String name() const override
Returns the name of the solver.
Definition: cusolver.hpp:56
const LAFEM::SparseMatrixCSR< double, unsigned int > & _system_matrix
system matrix
Definition: cusolver.hpp:41
virtual Status apply(LAFEM::DenseVector< double, unsigned int > &x, const LAFEM::DenseVector< double, unsigned int > &b) override
Solves a linear system with the factorized system matrix.
Definition: cusolver.hpp:71
CuSolverQR solver class.
Definition: cusolver.hpp:91
virtual Status apply(LAFEM::DenseVector< double, unsigned int > &x, const LAFEM::DenseVector< double, unsigned int > &b) override
Solver application method.
Definition: cusolver.hpp:113
const LAFEM::SparseMatrixCSR< double, unsigned int > & _system_matrix
system matrix
Definition: cusolver.hpp:94
CuSolverQR(const LAFEM::SparseMatrixCSR< double, unsigned int > &system_matrix)
Constructor.
Definition: cusolver.hpp:102
virtual String name() const override
Returns the name of the solver.
Definition: cusolver.hpp:108
Polymorphic solver interface.
Definition: base.hpp:183
String class implementation.
Definition: string.hpp:46
Status
Solver status return codes enumeration.
Definition: base.hpp:47
@ success
solving successful (convergence criterion fulfilled)
@ aborted
premature abort (solver aborted due to internal errors or preconditioner failure)
FEAT namespace.
Definition: adjactor.hpp:12