MCPcopy Create free account
hub / github.com/IBAMR/IBAMR / resetWrappedKSP

Method resetWrappedKSP

ibtk/src/solvers/impls/PETScKrylovLinearSolver.cpp:423–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

421} // common_ctor
422
423void
424PETScKrylovLinearSolver::resetWrappedKSP(KSP& petsc_ksp)
425{
426#if !defined(NDEBUG)
427 TBOX_ASSERT(!d_managing_petsc_ksp);
428#endif
429 d_petsc_ksp = petsc_ksp;
430 if (!d_petsc_ksp) return;
431 int ierr;
432
433 // Set d_petsc_comm to be the MPI communicator used by the supplied KSP.
434 ierr = PetscObjectGetComm(reinterpret_cast<PetscObject>(d_petsc_ksp), &d_petsc_comm);
435 IBTK_CHKERRQ(ierr);
436
437 // Set d_ksp_type to correspond to the KSP type used by the supplied KSP.
438 const char* ksp_type;
439 ierr = KSPGetType(d_petsc_ksp, &ksp_type);
440 IBTK_CHKERRQ(ierr);
441 d_ksp_type = std::string(ksp_type);
442
443 // Set d_options_prefix to correspond to that used by the supplied KSP.
444 const char* options_prefix;
445 ierr = KSPGetOptionsPrefix(d_petsc_ksp, &options_prefix);
446 IBTK_CHKERRQ(ierr);
447 d_options_prefix = options_prefix;
448
449 // Setup operators and preconditioners.
450 if (d_user_provided_mat)
451 {
452 resetKSPOperators();
453 }
454 else
455 {
456 // Create a LinearOperator wrapper to correspond to the PETSc Mat used
457 // by the KSP.
458 Mat petsc_mat;
459 ierr = KSPGetOperators(d_petsc_ksp, &petsc_mat, nullptr);
460 IBTK_CHKERRQ(ierr);
461 d_A = new PETScMatLOWrapper(d_object_name + "::Mat Wrapper", petsc_mat);
462 d_A->setHomogeneousBc(d_homogeneous_bc);
463 d_A->setSolutionTime(d_solution_time);
464 d_A->setTimeInterval(d_current_time, d_new_time);
465 }
466
467 if (d_user_provided_pc)
468 {
469 resetKSPPC();
470 }
471 else
472 {
473 // Create a LinearSolver wrapper to correspond to the PETSc PC used by
474 // the KSP.
475 PC petsc_pc;
476 ierr = KSPGetPC(d_petsc_ksp, &petsc_pc);
477 IBTK_CHKERRQ(ierr);
478 d_pc_solver = new PETScPCLSWrapper(d_object_name + "::PC Wrapper", petsc_pc);
479 d_pc_solver->setHomogeneousBc(true);
480 d_pc_solver->setSolutionTime(d_solution_time);

Callers 2

initializeSolverStateMethod · 0.80
resetWrappedSNESMethod · 0.80

Calls 3

setHomogeneousBcMethod · 0.45
setSolutionTimeMethod · 0.45
setTimeIntervalMethod · 0.45

Tested by

no test coverage detected