93 loc_size_A(other.loc_size_A), loc_size_B(other.loc_size_B), state(other.state),
94 Compl(other.Compl), ds_(other.ds_)
96 MatCopy(other.
IA,
IA, DIFFERENT_NONZERO_PATTERN);
97 MatCopy(other.
IAB,
IAB, DIFFERENT_NONZERO_PATTERN);
146 PetscErrorCode ierr = 0;
148 MatStructure mat_subset_pattern;
149 PetscScalar *rhs_array, *sol_array;
151 mat_reuse=MAT_REUSE_MATRIX;
152 mat_subset_pattern=SUBSET_NONZERO_PATTERN;
154 mat_reuse=MAT_INITIAL_MATRIX;
155 mat_subset_pattern=DIFFERENT_NONZERO_PATTERN;
160 VecGetArray(
rhs_, &rhs_array);
161 VecCreateMPIWithArray(PETSC_COMM_WORLD,1,
loc_size_A,PETSC_DETERMINE,rhs_array,&(
RHS1));
165 VecCreateMPIWithArray(PETSC_COMM_WORLD,1,
loc_size_A,PETSC_DETERMINE,sol_array,&(
Sol1));
170 VecRestoreArray(
rhs_, &rhs_array);
173 VecGetArray(
Sol2, &sol_array );
176 VecRestoreArray(
Sol2, &sol_array );
204 ierr+=MatMatMult(
IA,
B, mat_reuse, 1.0 ,&(
IAB));
207 ierr+=MatMatMult(
Bt,
IAB, mat_reuse, 1.9 ,&(
xA));
225 OLD_ASSERT( ierr == 0,
"PETSC Error during calculation of Schur complement.\n");
269 if (
ds_ != NULL)
delete ds_;
277 PetscInt ncols, pos_start, pos_start_IA;
279 MatReuse mat_reuse=MAT_REUSE_MATRIX;
283 MatGetOwnershipRange(
matrix_,&pos_start,PETSC_NULL);
284 MatGetOwnershipRange(
IA,&pos_start_IA,PETSC_NULL);
287 const PetscInt *cols;
288 const PetscScalar *vals;
292 unsigned int mat_block=1;
293 for(
unsigned int loc_row=0; loc_row < processed_rows.size(); loc_row++) {
294 if (processed_rows[loc_row] != 0)
continue;
296 PetscInt min=std::numeric_limits<int>::max(), max=-1, size_submat;
299 MatGetRow(
matrix_, loc_row + pos_start, &ncols, &cols, PETSC_NULL);
300 for (PetscInt i=0; i<ncols; i++) {
301 if (cols[i] < pos_start || cols[i] >= pos_start+
loc_size_A) {
312 size_submat = max - min + 1;
313 OLD_ASSERT(ncols-b_vals == size_submat,
"Submatrix cannot contains empty values.\n");
315 MatRestoreRow(
matrix_, loc_row + pos_start, &ncols, &cols, PETSC_NULL);
316 arma::mat submat2(size_submat, size_submat);
318 for (PetscInt i=0; i<size_submat; i++) {
319 processed_rows[ loc_row + i ] = mat_block;
320 submat_rows.push_back( i + loc_row + pos_start_IA );
321 MatGetRow(
matrix_, i + loc_row + pos_start, &ncols, &cols, &vals);
322 for (PetscInt j=0; j<ncols; j++) {
323 if (cols[j] >= pos_start && cols[j] < pos_start+
loc_size_A) {
324 submat2( i, cols[j] - loc_row - pos_start ) = vals[j];
327 MatRestoreRow(
matrix_, i + loc_row + pos_start, &ncols, &cols, &vals);
330 arma::mat invmat = submat2.i();
332 const PetscInt* rows = &submat_rows[0];
333 MatSetValues(
IA, submat_rows.size(), rows, submat_rows.size(), rows, invmat.memptr(), INSERT_VALUES);
338 MatAssemblyBegin(
IA, MAT_FINAL_ASSEMBLY);
339 MatAssemblyEnd(
IA, MAT_FINAL_ASSEMBLY);
348 return std::numeric_limits<double>::infinity();
382 START_TIMER(
"SchurComplemet::resolve without form schur");
404 if (
B != NULL )
chkerr(MatDestroy(&
B));
406 if (
C != NULL )
chkerr(MatDestroy(&
C));
419 if (
ds_ != NULL)
delete ds_;