18#include "libmesh/diagonal_matrix.h"
19#include "libmesh/numeric_vector.h"
20#include "libmesh/dense_matrix.h"
21#include "libmesh/dof_map.h"
22#include "libmesh/libmesh_common.h"
68 _diagonal->
init(m, m_l);
77 _diagonal->init(this->_dof_map->n_dofs(),
78 this->_dof_map->n_local_dofs(),
87 _diagonal->init(other, fast);
115 auto mat_copy = std::make_unique<DiagonalMatrix<T>>(this->comm());
119 mat_copy->init(*
this,
false);
130 auto mat_copy = std::make_unique<DiagonalMatrix<T>>(this->comm());
133 auto diag_copy = _diagonal->clone();
136 *mat_copy = std::move(*diag_copy);
152 return _diagonal->size();
159 return _diagonal->size();
166 return _diagonal->first_local_index();
173 return _diagonal->last_local_index();
180 return _diagonal->first_local_index();
187 return _diagonal->last_local_index();
195 _diagonal->set(i,
value);
203 _diagonal->add(i,
value);
209 const std::vector<numeric_index_type> & rows,
210 const std::vector<numeric_index_type> & cols)
215 for (
decltype(m) i = 0; i < m; ++i)
216 for (
decltype(n) j = 0; j < n; ++j)
218 auto global_i = rows[i];
219 auto global_j = cols[j];
220 if (global_i == global_j)
221 _diagonal->add(global_i, dm(i, j));
228 const std::vector<numeric_index_type> & dof_indices)
230 _diagonal->add_vector(dm.
diagonal(), dof_indices);
237 auto x_diagonal = _diagonal->zero_clone();
239 _diagonal->add(a, *x_diagonal);
247 return (*_diagonal)(i);
256 return _diagonal->l1_norm();
263 return _diagonal->linfty_norm();
270 return _diagonal->closed();
277 _diagonal->print(os);
297 *diagonal_dest = *_diagonal;
299 libmesh_error_msg(
"DenseMatrix<T>::get_transpose currently only accepts another DenseMatrix<T> "
308 std::vector<numeric_index_type> & indices,
309 std::vector<T> & values)
const
312 indices.push_back(i);
314 values.push_back((*_diagonal)(i));
323 for (
auto row : rows)
324 _diagonal->set(row, val);
DenseVector< T > diagonal() const
Return the matrix diagonal.
Defines a dense matrix for use in Finite Element-type computations.
Diagonal matrix class whose underlying storage is a vector.
virtual bool closed() 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.
virtual numeric_index_type m() const override
virtual void clear() override
Restores the SparseMatrix<T> to a pristine state.
virtual numeric_index_type col_start() const override
DiagonalMatrix(const Parallel::Communicator &comm)
Constructor; initializes the matrix to be empty, without any structure, i.e.
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 void zero_rows(std::vector< numeric_index_type > &rows, T val=0) override
Sets all row entries to 0 then puts diag_value in the diagonal entry.
virtual numeric_index_type row_start() const override
virtual numeric_index_type col_stop() const override
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 n() const override
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
virtual Real l1_norm() const override
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.
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override
Set the element (i,j) to value.
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 get_transpose(SparseMatrix< T > &dest) const override
Copies the transpose of the matrix into dest, which may be *this.
virtual void close() override
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
virtual numeric_index_type row_stop() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
virtual Real linfty_norm() const override
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
std::unique_ptr< NumericVector< T > > _diagonal
Underlying diagonal matrix storage.
const NumericVector< T > & diagonal() const
DiagonalMatrix & operator=(DiagonalMatrix &&)=default
virtual void zero() override
Set all entries to 0.
virtual void restore_original_nonzero_pattern() override
Reset the memory storage of the matrix.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual void zero()=0
Set all entries to zero.
virtual void get_diagonal(NumericVector< T > &dest) const =0
Copies the diagonal part of the matrix into dest.
The libMesh namespace provides an interface to certain functionality in the library.
ParallelType
Defines an enum for parallel data structure types.
dof_id_type numeric_index_type
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real