20 #ifndef __TPETRA_MATRIX_H 21 #define __TPETRA_MATRIX_H 31 #include <Teuchos_GlobalMPISession.hpp> 32 #include <Teuchos_oblackholestream.hpp> 33 #include <Tpetra_CrsMatrix.hpp> 34 #include <Tpetra_DefaultPlatform.hpp> 35 #include <Tpetra_Vector.hpp> 36 #include <Tpetra_Version.hpp> 38 #include <dolfin/common/types.h> 39 #include "GenericMatrix.h" 44 class GenericLinearAlgebraFactory;
64 typedef Tpetra::CrsMatrix<double, int, dolfin::la_index>
matrix_type;
66 typedef Tpetra::CrsGraph<int, dolfin::la_index>
graph_type;
68 typedef Tpetra::Map<int, dolfin::la_index>
map_type;
91 std::size_t
size(std::size_t dim)
const;
94 std::pair<std::int64_t, std::int64_t>
local_range(std::size_t dim)
const;
97 std::size_t
nnz()
const;
103 virtual void apply(std::string mode);
109 virtual std::string
str(
bool verbose)
const;
114 virtual std::shared_ptr<GenericMatrix>
copy()
const;
127 virtual void get(
double* block,
132 virtual void set(
const double* block,
137 virtual void set_local(
const double* block,
142 virtual void add(
const double* block,
147 virtual void add_local(
const double* block,
153 bool same_nonzero_pattern);
156 virtual void getrow(std::size_t row,
157 std::vector<std::size_t>& columns,
158 std::vector<double>& values)
const;
161 virtual void setrow(std::size_t row,
162 const std::vector<std::size_t>& columns,
163 const std::vector<double>& values);
209 double norm(std::string norm_type)
const;
215 Teuchos::RCP<matrix_type>
mat()
219 Teuchos::RCP<const matrix_type>
mat()
const 223 static void graphdump(
const Teuchos::RCP<const graph_type> graph);
228 Teuchos::RCP<matrix_type> _matA;
232 std::array<std::shared_ptr<const IndexMap>, 2> index_map;
virtual void mult(const GenericVector &x, GenericVector &y) const
Compute matrix-vector product y = Ax.
Definition: TpetraMatrix.cpp:572
double norm(std::string norm_type) const
Return norm of matrix.
Definition: TpetraMatrix.cpp:695
virtual std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: TpetraMatrix.cpp:788
virtual void ident_local(std::size_t m, const dolfin::la_index *rows)
Set given rows (local row indices) to identity matrix.
Definition: TpetraMatrix.cpp:538
virtual void add_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
Add block of values using local indices.
Definition: TpetraMatrix.cpp:365
Tpetra::CrsGraph< int, dolfin::la_index > graph_type
Graph type (local index, global index)
Definition: TpetraMatrix.h:66
std::size_t size(std::size_t dim) const
Return size of given dimension.
Definition: TpetraMatrix.cpp:184
std::pair< std::int64_t, std::int64_t > local_range(std::size_t dim) const
Return local ownership range.
Definition: TpetraMatrix.cpp:205
virtual bool is_symmetric(double tol) const
Test if matrix is symmetric.
Definition: TpetraMatrix.cpp:772
virtual void zero_local(std::size_t m, const dolfin::la_index *rows)
Set given rows (local row indices) to zero.
Definition: TpetraMatrix.cpp:492
Tpetra::Map< int, dolfin::la_index > map_type
Map type (local index, global index)
Definition: TpetraMatrix.h:68
virtual void set_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
Set block of values using local indices.
Definition: TpetraMatrix.cpp:318
Definition: TpetraMatrix.h:58
virtual void init_vector(GenericVector &z, std::size_t dim) const
Definition: TpetraMatrix.cpp:249
virtual std::shared_ptr< GenericMatrix > copy() const
Return copy of matrix.
Definition: TpetraMatrix.cpp:71
Teuchos::RCP< matrix_type > mat()
Return Teuchos reference counted pointer to raw matrix.
Definition: TpetraMatrix.h:215
Definition: TensorLayout.h:41
Base class for LinearAlgebra factories.
Definition: GenericLinearAlgebraFactory.h:46
virtual void zero()
Set all entries to zero and keep any sparse structure.
Definition: TpetraMatrix.cpp:737
virtual void add(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
Add block of values using global indices.
Definition: TpetraMatrix.cpp:349
Teuchos::RCP< const matrix_type > mat() const
Return Teuchos reference counted pointer to raw matrix (const)
Definition: TpetraMatrix.h:219
void init(const TensorLayout &tensor_layout)
Initialize zero tensor using tensor layout.
Definition: TpetraMatrix.cpp:76
virtual const TpetraMatrix & operator/=(double a)
Divide matrix by given number.
Definition: TpetraMatrix.cpp:756
virtual void set_diagonal(const GenericVector &x)
Set diagonal of a matrix.
Definition: TpetraMatrix.cpp:659
virtual void ident(std::size_t m, const dolfin::la_index *rows)
Set given rows (global row indices) to identity matrix.
Definition: TpetraMatrix.cpp:510
virtual GenericLinearAlgebraFactory & factory() const
Return linear algebra backend factory.
Definition: TpetraMatrix.cpp:778
virtual const TpetraMatrix & operator*=(double a)
Multiply matrix by given number.
Definition: TpetraMatrix.cpp:746
virtual void setrow(std::size_t row, const std::vector< std::size_t > &columns, const std::vector< double > &values)
Set values for given row.
Definition: TpetraMatrix.cpp:442
virtual void axpy(double a, const GenericMatrix &A, bool same_nonzero_pattern)
Add multiple of given matrix (AXPY operation)
Definition: TpetraMatrix.cpp:397
MPI_Comm mpi_comm() const
Return MPI communicator.
Definition: TpetraMatrix.cpp:726
This class defines a common interface for matrices.
Definition: GenericMatrix.h:46
static void graphdump(const Teuchos::RCP< const graph_type > graph)
Print out a graph, for debugging.
Definition: TpetraMatrix.cpp:802
PetscInt la_index
Index type for compatibility with linear algebra backend(s)
Definition: types.h:32
virtual void transpmult(const GenericVector &x, GenericVector &y) const
Definition: TpetraMatrix.cpp:601
bool empty() const
Return true if empty.
Definition: TpetraMatrix.cpp:244
TpetraMatrix()
Create empty matrix.
Definition: TpetraMatrix.cpp:43
virtual const GenericMatrix & operator=(const GenericMatrix &A)
Assignment operator.
Definition: TpetraMatrix.cpp:766
virtual void get_diagonal(GenericVector &x) const
Get diagonal of a matrix.
Definition: TpetraMatrix.cpp:629
Tpetra::CrsMatrix< double, int, dolfin::la_index > matrix_type
Matrix type (scalar, local index, global index)
Definition: TpetraMatrix.h:64
virtual void apply(std::string mode)
Finalize assembly of tensor. The mode parameter is ignored.
Definition: TpetraMatrix.cpp:711
virtual ~TpetraMatrix()
Destructor.
Definition: TpetraMatrix.cpp:66
std::size_t nnz() const
Return number of non-zero entries in matrix (collective)
Definition: TpetraMatrix.cpp:236
This class defines a common interface for vectors.
Definition: GenericVector.h:47
virtual void getrow(std::size_t row, std::vector< std::size_t > &columns, std::vector< double > &values) const
Get non-zero values of given row.
Definition: TpetraMatrix.cpp:414