54 PETScMatrix(
const PetscInt nrows,
const PetscInt ncols,
69 MatAssemblyBegin(
A_, asm_type);
70 MatAssemblyEnd(
A_, asm_type);
113 void set(
const PetscInt i,
const PetscInt j,
const PetscScalar value)
115 MatSetValue(
A_, i, j, value, INSERT_VALUES);
124 void add(
const PetscInt i,
const PetscInt j,
const PetscScalar value)
126 MatSetValue(
A_, i, j, value, ADD_VALUES);
145 template <
class T_DENSE_MATRIX>
147 const T_DENSE_MATRIX& sub_matrix)
153 std::vector<PetscInt> cols;
154 cols.reserve(indices.
columns.size());
155 for (
auto col : indices.
columns)
161 cols.push_back(std::abs(col));
164 add(indices.
rows, cols, sub_matrix);
174 template <
class T_DENSE_MATRIX>
175 void add(std::vector<PetscInt>
const& row_pos,
176 std::vector<PetscInt>
const& col_pos,
177 const T_DENSE_MATRIX& sub_mat);
208 void viewer(
const std::string& file_name,
209 const PetscViewerFormat vw_format = PETSC_VIEWER_ASCII_MATLAB);
248 void create(
const PetscInt d_nz,
const PetscInt o_nz);
251 const MatAssemblyType asm_type);
254 template <
class T_DENSE_MATRIX>
256 std::vector<PetscInt>
const& col_pos,
257 const T_DENSE_MATRIX& sub_mat)
259 const PetscInt nrows =
static_cast<PetscInt
>(row_pos.size());
260 const PetscInt ncols =
static_cast<PetscInt
>(col_pos.size());
262 MatSetValues(
A_, nrows, &row_pos[0], ncols, &col_pos[0], &sub_mat(0, 0),
273 PETScMatrix& mat,
const MatAssemblyType asm_type = MAT_FINAL_ASSEMBLY);
Define data for the configuration of PETSc matrix and linear solver.
Declaration of class PETScVector, which provides an interface to PETSc vector routines.
Wrapper class for PETSc matrix routines for matrix.
PetscInt n_loc_cols_
Number of the local columns.
PetscInt getNumberOfLocalRows() const
Get the number of local rows.
PETScMatrix & operator=(PETScMatrix const &A)
PetscInt getNumberOfColumns() const
Get the number of columns.
void add(RowColumnIndices< PetscInt > const &indices, const T_DENSE_MATRIX &sub_matrix)
Add sub-matrix at positions given by global indices, in which negative index indicates ghost entry.
void setZero()
Set all entries to zero.
void create(const PetscInt d_nz, const PetscInt o_nz)
Create the matrix, configure memory allocation and set the related member data.
Mat const & getRawMatrix() const
PetscInt getRangeEnd() const
Get the end global index of the rows in the same rank.
void set(const PetscInt i, const PetscInt j, const PetscScalar value)
Set a single entry with a value.
PetscInt end_rank_
Ending index in a rank.
Mat & getRawMatrix()
Get matrix reference.
PetscInt getRangeBegin() const
Get the start global index of the rows of the same rank.
void finalizeAssembly(const MatAssemblyType asm_type=MAT_FINAL_ASSEMBLY)
Perform MPI collection of assembled entries in buffer.
PetscInt n_loc_rows_
Number of the local rows.
PetscInt nrows_
Number of the global rows.
void setRowsColumnsZero(std::vector< PetscInt > const &row_pos)
Set the specified rows to zero except diagonal entries, i.e. , where This function must be called by...
PetscInt ncols_
Number of the global columns.
void viewer(const std::string &file_name, const PetscViewerFormat vw_format=PETSC_VIEWER_ASCII_MATLAB)
friend bool finalizeMatrixAssembly(PETScMatrix &mat, const MatAssemblyType asm_type)
General interface for the matrix assembly.
void add(const PetscInt i, const PetscInt j, const PetscScalar value)
Add value to a single entry.
PetscInt getNumberOfRows() const
Get the number of rows.
PetscInt start_rank_
Starting index in a rank.
PetscInt getNumberOfLocalColumns() const
Get the number of local columns.
bool finalizeMatrixAssembly(MAT_T &)
This a struct data containing the configuration information to create a PETSc type matrix.
LineIndex const & columns