StrumpackSparseSolver.hpp
1/*
2 * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3 * Regents of the University of California, through Lawrence Berkeley
4 * National Laboratory (subject to receipt of any required approvals
5 * from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * If you have questions about your rights to use or distribute this
8 * software, please contact Berkeley Lab's Technology Transfer
9 * Department at TTD@lbl.gov.
10 *
11 * NOTICE. This software is owned by the U.S. Department of Energy. As
12 * such, the U.S. Government has been granted for itself and others
13 * acting on its behalf a paid-up, nonexclusive, irrevocable,
14 * worldwide license in the Software to reproduce, prepare derivative
15 * works, and perform publicly and display publicly. Beginning five
16 * (5) years after the date permission to assert copyright is obtained
17 * from the U.S. Department of Energy, and subject to any subsequent
18 * five (5) year renewals, the U.S. Government is granted for itself
19 * and others acting on its behalf a paid-up, nonexclusive,
20 * irrevocable, worldwide license in the Software to reproduce,
21 * prepare derivative works, distribute copies to the public, perform
22 * publicly and display publicly, and to permit others to do so.
23 *
24 * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25 * (Lawrence Berkeley National Lab, Computational Research
26 * Division).
27 */
33#ifndef STRUMPACK_SPARSE_SOLVER_HPP
34#define STRUMPACK_SPARSE_SOLVER_HPP
35
36#include <new>
37#include <memory>
38#include <vector>
39#include <string>
40
41#include "SparseSolverBase.hpp"
42
46namespace strumpack {
47
48 // forward declarations
49 template<typename scalar_t,typename integer_t> class MatrixReordering;
50 template<typename scalar_t,typename integer_t> class EliminationTree;
51 class TaskTimer;
52
73 template<typename scalar_t,typename integer_t=int>
75 public SparseSolverBase<scalar_t,integer_t> {
76
82
83 public:
84
97 SparseSolver(int argc, char* argv[], bool verbose=true, bool root=true);
98
107 SparseSolver(bool verbose=true, bool root=true);
108
113
127
147 void set_csr_matrix(integer_t N,
148 const integer_t* row_ptr, const integer_t* col_ind,
149 const scalar_t* values, bool symmetric_pattern=false);
150
180 void update_matrix_values(integer_t N,
181 const integer_t* row_ptr,
182 const integer_t* col_ind,
183 const scalar_t* values,
184 bool symmetric_pattern=false);
185
205
206 private:
207 void setup_tree() override;
208 void setup_reordering() override;
209 int compute_reordering(const int* p, int base,
210 int nx, int ny, int nz,
211 int components, int width) override;
212 void separator_reordering() override;
213
214 SpMat_t* matrix() override { return mat_.get(); }
215 std::unique_ptr<SpMat_t> matrix_nonzero_diag() override {
216 return mat_->add_missing_diagonal(opts_.pivot_threshold());
217 }
218 Reord_t* reordering() override { return nd_.get(); }
219 Tree_t* tree() override { return tree_.get(); }
220 const SpMat_t* matrix() const override { return mat_.get(); }
221 const Reord_t* reordering() const override { return nd_.get(); }
222 const Tree_t* tree() const override { return tree_.get(); }
223
224 void permute_matrix_values();
225
226 ReturnCode solve_internal(const scalar_t* b, scalar_t* x,
227 bool use_initial_guess=false) override;
228 ReturnCode solve_internal(const DenseM_t& b, DenseM_t& x,
229 bool use_initial_guess=false) override;
230
231 void delete_factors_internal() override;
232
233 void transform_x0(DenseM_t& x, DenseM_t& xtmp);
234 void transform_b(const DenseM_t& b, DenseM_t& bloc);
235 void transform_x(DenseM_t& x, DenseM_t& xtmp);
236
237 std::unique_ptr<CSRMatrix<scalar_t,integer_t>> mat_;
238 std::unique_ptr<MatrixReordering<scalar_t,integer_t>> nd_;
239 std::unique_ptr<EliminationTree<scalar_t,integer_t>> tree_;
240
241 using SPBase_t = SparseSolverBase<scalar_t,integer_t>;
242 using SPBase_t::opts_;
243 using SPBase_t::is_root_;
244 using SPBase_t::matching_;
245 using SPBase_t::equil_;
246 using SPBase_t::factored_;
247 using SPBase_t::reordered_;
248 using SPBase_t::Krylov_its_;
249 };
250
251 template<typename scalar_t,typename integer_t>
252 using StrumpackSparseSolver = SparseSolver<scalar_t,integer_t>;
253
254} //end namespace strumpack
255
256#endif // STRUMPACK_SPARSE_SOLVER_HPP
Contains the definition of the base (abstract/pure virtual) sparse solver class.
Class for storing a compressed sparse row matrix (single node).
Definition: CSRMatrix.hpp:55
Abstract base class for compressed sparse matrix storage.
Definition: CompressedSparseMatrix.hpp:149
Like DenseMatrix, this class represents a matrix, stored in column major format, to allow direct use ...
Definition: DenseMatrix.hpp:1015
This class represents a matrix, stored in column major format, to allow direct use of BLAS/LAPACK rou...
Definition: DenseMatrix.hpp:138
Definition: SparseSolverBase.hpp:53
Definition: SparseSolverBase.hpp:52
SparseSolverBase is the virtual base for both the sequential/multithreaded and distributed sparse sol...
Definition: SparseSolverBase.hpp:78
SparseSolver is the main sequential or multithreaded sparse solver class.
Definition: StrumpackSparseSolver.hpp:75
void update_matrix_values(const CSRMatrix< scalar_t, integer_t > &A)
void update_matrix_values(integer_t N, const integer_t *row_ptr, const integer_t *col_ind, const scalar_t *values, bool symmetric_pattern=false)
SparseSolver(bool verbose=true, bool root=true)
SparseSolver(int argc, char *argv[], bool verbose=true, bool root=true)
void set_matrix(const CSRMatrix< scalar_t, integer_t > &A)
void set_csr_matrix(integer_t N, const integer_t *row_ptr, const integer_t *col_ind, const scalar_t *values, bool symmetric_pattern=false)
Definition: StrumpackOptions.hpp:43
ReturnCode
Enumeration for the possible return codes.
Definition: StrumpackParameters.hpp:50