38 #include "PetscVecTools.hpp"
39 #include "PCBlockDiagonal.hpp"
41 #include "Warnings.hpp"
60 PCBlockDiagonal::~PCBlockDiagonal()
65 std::cout <<
" -- Block diagonal preconditioner profile information: " << std::endl;
66 std::cout <<
"\t mScatterTime: " <<
mPCContext.mScatterTime << std::endl;
67 std::cout <<
"\t mA1PreconditionerTime: " <<
mPCContext.mA1PreconditionerTime << std::endl;
68 std::cout <<
"\t mA2PreconditionerTime: " <<
mPCContext.mA2PreconditionerTime << std::endl;
69 std::cout <<
"\t mGatherTime: " <<
mPCContext.mGatherTime << std::endl;
93 Mat system_matrix, dummy;
94 #if ( PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=5 )
95 KSPGetOperators(rKspObject, &system_matrix, &dummy);
98 KSPGetOperators(rKspObject, &system_matrix, &dummy, &flag);
102 MatGetSize(system_matrix, &num_rows, &num_columns);
103 assert(num_rows==num_columns);
105 PetscInt num_local_rows, num_local_columns;
106 MatGetLocalSize(system_matrix, &num_local_rows, &num_local_columns);
110 if ((num_rows%2 != 0) || (num_local_rows%2 != 0))
112 TERMINATE(
"Wrong matrix parallel layout detected in PCLDUFactorisation.");
116 unsigned subvector_num_rows = num_rows/2;
117 unsigned subvector_local_rows = num_local_rows/2;
139 assert(global_size == num_rows/2);
143 ISCreateStride(PETSC_COMM_WORLD, high-low, 2*low, 2, &A11_local_rows);
144 ISCreateStride(PETSC_COMM_WORLD, global_size, 0, 2, &A11_columns);
146 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 1) //PETSc 3.1 or later
147 MatGetSubMatrix(system_matrix, A11_local_rows, A11_local_rows,
150 MatGetSubMatrix(system_matrix, A11_local_rows, A11_columns, PETSC_DECIDE,
165 assert(global_size == num_rows/2);
169 ISCreateStride(PETSC_COMM_WORLD, high-low, 2*low+1, 2, &A22_local_rows);
170 ISCreateStride(PETSC_COMM_WORLD, global_size, 1, 2, &A22_columns);
172 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 1) //PETSc 3.1 or later
173 MatGetSubMatrix(system_matrix, A22_local_rows, A22_local_rows,
176 MatGetSubMatrix(system_matrix, A22_local_rows, A22_columns, PETSC_DECIDE,
186 #if (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 2) //PETSc 2.2
212 PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL);
214 if (pc_set_error != 0)
216 WARNING(
"PETSc hypre preconditioning library is not installed");
219 PetscPopErrorHandler();
223 PetscOptionsSetValue(
"-pc_hypre_type",
"euclid");
224 PetscOptionsSetValue(
"-pc_hypre_euclid_levels",
"0");
233 #if ( PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=5 )
247 PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL);
250 PetscPopErrorHandler();
253 PetscOptionsSetValue(
"-pc_hypre_type",
"boomeramg");
254 PetscOptionsSetValue(
"-pc_hypre_boomeramg_max_iter",
"1");
255 PetscOptionsSetValue(
"-pc_hypre_boomeramg_strong_threshold",
"0.0");
256 PetscOptionsSetValue(
"-pc_hypre_boomeramg_coarsen_type",
"HMIS");
293 #if ( PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=5 )
304 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 1) //PETSc 3.1 or later
305 PetscErrorCode PCBlockDiagonalApply(PC pc_object,
Vec x,
Vec y)
309 PCShellGetContext(pc_object, &pc_context);
311 PetscErrorCode PCBlockDiagonalApply(
void* pc_context,
Vec x,
Vec y)
317 assert(block_diag_context!=NULL);
void PCBlockDiagonalCreate(KSP &rKspObject)
#define TERMINATE(message)
static double GetElapsedTime()
PCBlockDiagonalContext mPCContext
VecScatter A11_scatter_ctx
PCBlockDiagonal(KSP &rKspObject)
VecScatter A22_scatter_ctx
void PCBlockDiagonalSetUp()