26 n_loc_rows_(PETSC_DECIDE),
27 n_loc_cols_(mat_opt.n_local_cols)
44 n_loc_rows_(PETSC_DECIDE),
45 n_loc_cols_(mat_opt.n_local_cols)
61 n_loc_rows_(A.n_loc_rows_),
62 n_loc_cols_(A.n_loc_cols_),
63 start_rank_(A.start_rank_),
64 end_rank_(A.end_rank_)
66 MatConvert(A.
A_, MATSAME, MAT_INITIAL_MATRIX, &
A_);
81 MatCopy(A.
A_,
A_, DIFFERENT_NONZERO_PATTERN);
86 MatConvert(A.
A_, MATSAME, MAT_INITIAL_MATRIX, &
A_);
96 const PetscScalar one = 1.0;
97 const PetscInt nrows =
static_cast<PetscInt
>(row_pos.size());
103 MatSetOption(
A_, MAT_NO_OFF_PROC_ZERO_ROWS, PETSC_TRUE);
106 MatSetOption(
A_, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
110 MatZeroRows(
A_, nrows, &row_pos[0], one, PETSC_NULLPTR, PETSC_NULLPTR);
114 MatZeroRows(
A_, 0, PETSC_NULLPTR, one, PETSC_NULLPTR, PETSC_NULLPTR);
119 const PetscViewerFormat vw_format)
122 PetscViewerASCIIOpen(PETSC_COMM_WORLD, file_name.c_str(), &
viewer);
123 PetscViewerPushFormat(
viewer, vw_format);
127 PetscObjectSetName((PetscObject)
A_,
"Stiffness_matrix");
142 MatCreate(PETSC_COMM_WORLD, &
A_);
145 MatSetType(
A_, MATAIJ);
146 MatSetFromOptions(
A_);
148 MatSeqAIJSetPreallocation(
A_, d_nz, PETSC_NULLPTR);
149 MatMPIAIJSetPreallocation(
A_, d_nz, PETSC_NULLPTR, o_nz, PETSC_NULLPTR);
Declaration of class PETScMatrix, which provides an interface to PETSc matrix routines.
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.
PETScMatrix & operator=(PETScMatrix const &A)
void create(const PetscInt d_nz, const PetscInt o_nz)
Create the matrix, configure memory allocation and set the related member data.
PetscInt end_rank_
Ending index in a 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...
PetscInt ncols_
Number of the global columns.
void viewer(const std::string &file_name, const PetscViewerFormat vw_format=PETSC_VIEWER_ASCII_MATLAB)
PetscInt start_rank_
Starting index in a rank.
bool finalizeMatrixAssembly(MAT_T &)
This a struct data containing the configuration information to create a PETSc type matrix.
PetscInt o_nz
Number of nonzeros per row in the off-diagonal portion of local submatrix (same value is used for all...
bool is_global_size
Flag for the type of size, which is one of arguments of the constructor of class PETScMatrix true: th...
PetscInt d_nz
Number of nonzeros per row in the diagonal portion of local submatrix (same value is used for all loc...