20 #ifndef LIBMESH_EIGEN_SPARSE_MATRIX_H 21 #define LIBMESH_EIGEN_SPARSE_MATRIX_H 23 #include "libmesh/libmesh_config.h" 25 #ifdef LIBMESH_HAVE_EIGEN 28 #include "libmesh/sparse_matrix.h" 29 #include "libmesh/eigen_core_support.h" 41 template <
typename T>
class DenseMatrix;
87 *
this = cast_ref<const EigenSparseMatrix<T> &>(v);
107 virtual void clear ()
override;
109 virtual void zero ()
override;
111 virtual std::unique_ptr<SparseMatrix<T>>
zero_clone ()
const override;
113 virtual std::unique_ptr<SparseMatrix<T>>
clone ()
const override;
131 const T
value)
override;
135 const T
value)
override;
138 const std::vector<numeric_index_type> & rows,
139 const std::vector<numeric_index_type> & cols)
override;
142 const std::vector<numeric_index_type> & dof_indices)
override;
162 std::vector<numeric_index_type> & indices,
163 std::vector<T> & values)
const override;
185 #endif // #ifdef LIBMESH_HAVE_EIGEN 186 #endif // #ifdef LIBMESH_EIGEN_SPARSE_MATRIX_H The EigenSparseMatrix class wraps a sparse matrix object from the Eigen library.
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1) override
Initialize SparseMatrix with the specified sizes.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
Add value to the element (i,j).
virtual numeric_index_type m() const override
virtual void close() override
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
Eigen::Triplet< T, eigen_idx_type > TripletType
virtual numeric_index_type row_stop() const override
bool _closed
Flag indicating if the matrix has been closed yet.
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
This class provides an interface to Eigen iterative solvers that is compatible with the libMesh Linea...
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
const Parallel::Communicator & comm() const
EigenSparseMatrix & operator=(const EigenSparseMatrix &)=default
virtual ~EigenSparseMatrix()=default
The libMesh namespace provides an interface to certain functionality in the library.
DataType _mat
Actual Eigen::SparseMatrix<> we are wrapping.
virtual void get_transpose(SparseMatrix< T > &dest) const override
Copies the transpose of the matrix into dest, which may be *this.
virtual void zero() override
Set all entries to 0.
virtual numeric_index_type n() const override
virtual bool closed() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.
dof_id_type numeric_index_type
EigenSparseMatrix(const Parallel::Communicator &comm)
Constructor; initializes the matrix to be empty, without any structure, i.e.
Eigen::SparseMatrix< Number, Eigen::RowMajor, eigen_idx_type > EigenSM
virtual SparseMatrix< T > & operator=(const SparseMatrix< T > &v) override
This looks like a copy assignment operator, but note that, unlike normal copy assignment operators...
virtual numeric_index_type col_stop() const override
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
EigenSM DataType
Convenient typedefs.
virtual numeric_index_type row_start() const override
virtual void print_personal(std::ostream &os=libMesh::out) const override
Print the contents of the matrix to the screen in a package-personalized style, if available...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real linfty_norm() const override
virtual numeric_index_type col_start() const override
virtual void clear() override
Restores the SparseMatrix<T> to a pristine state.
virtual void get_row(numeric_index_type i, std::vector< numeric_index_type > &indices, std::vector< T > &values) const override
Get a row from the matrix.
virtual SolverPackage solver_package() override
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
virtual Real l1_norm() const override
SolverPackage
Defines an enum for various linear solver packages.
Defines a dense matrix for use in Finite Element-type computations.
void print(std::ostream &os=libMesh::out, const bool sparse=false) const
Print the contents of the matrix to the screen in a uniform style, regardless of matrix/solver packag...
This class provides a nice interface to the Eigen C++-based data structures for serial vectors...
ParallelType
Defines an enum for parallel data structure types.
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override
Add the full matrix dm to the SparseMatrix.