20 nrows_ = PETSC_DECIDE;
21 ncols_ = PETSC_DECIDE;
36 nrows_ = PETSC_DECIDE;
37 ncols_ = PETSC_DECIDE;
53 PetscCallAbort(PETSC_COMM_WORLD,
54 MatConvert(A.
A_, MATSAME, MAT_INITIAL_MATRIX, &
A_));
69 PetscCallAbort(PETSC_COMM_WORLD,
70 MatCopy(A.
A_,
A_, DIFFERENT_NONZERO_PATTERN));
75 PetscCallAbort(PETSC_COMM_WORLD,
76 MatConvert(A.
A_, MATSAME, MAT_INITIAL_MATRIX, &
A_));
86 const PetscScalar one = 1.0;
87 const PetscInt nrows =
static_cast<PetscInt
>(row_pos.size());
93 PetscCallAbort(PETSC_COMM_WORLD,
94 MatSetOption(
A_, MAT_NO_OFF_PROC_ZERO_ROWS, PETSC_TRUE));
97 PetscCallAbort(PETSC_COMM_WORLD,
98 MatSetOption(
A_, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE));
102 PetscCallAbort(PETSC_COMM_WORLD,
103 MatZeroRows(
A_, nrows, &row_pos[0], one, PETSC_NULLPTR,
108 PetscCallAbort(PETSC_COMM_WORLD,
109 MatZeroRows(
A_, 0, PETSC_NULLPTR, one, PETSC_NULLPTR,
115 const PetscViewerFormat vw_format)
118 PetscViewerASCIIOpen(PETSC_COMM_WORLD, file_name.c_str(), &
viewer);
119 PetscViewerPushFormat(
viewer, vw_format);
123 PetscObjectSetName((PetscObject)
A_,
"Stiffness_matrix");
138 PetscCallAbort(PETSC_COMM_WORLD, MatCreate(PETSC_COMM_WORLD, &
A_));
139 PetscCallAbort(PETSC_COMM_WORLD,
142 PetscCallAbort(PETSC_COMM_WORLD, MatSetType(
A_, MATAIJ));
143 PetscCallAbort(PETSC_COMM_WORLD, MatSetFromOptions(
A_));
145 PetscCallAbort(PETSC_COMM_WORLD,
146 MatSeqAIJSetPreallocation(
A_, d_nz, PETSC_NULLPTR));
147 PetscCallAbort(PETSC_COMM_WORLD,
148 MatMPIAIJSetPreallocation(
A_, d_nz, PETSC_NULLPTR, o_nz,
153 PetscCallAbort(PETSC_COMM_WORLD,
155 PetscCallAbort(PETSC_COMM_WORLD, MatGetSize(
A_, &
nrows_, &
ncols_));
156 PetscCallAbort(PETSC_COMM_WORLD,
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...