| 420 | } // setPhysicalBoundaryHelper |
| 421 | |
| 422 | bool |
| 423 | KrylovMobilitySolver::solveSystem(Vec x, Vec b) |
| 424 | { |
| 425 | IBTK_TIMER_START(t_solve_system); |
| 426 | |
| 427 | // Initialize the solver, when necessary. |
| 428 | const bool deallocate_after_solve = !d_is_initialized; |
| 429 | if (deallocate_after_solve) initializeSolverState(x, b); |
| 430 | |
| 431 | #if !defined(NDEBUG) |
| 432 | TBOX_ASSERT(d_petsc_ksp); |
| 433 | #endif |
| 434 | |
| 435 | d_petsc_x = x; |
| 436 | VecCopy(b, d_petsc_b); |
| 437 | |
| 438 | // Solve the system using a PETSc KSP object. |
| 439 | KSPSolve(d_petsc_ksp, d_petsc_b, d_petsc_x); |
| 440 | KSPGetIterationNumber(d_petsc_ksp, &d_current_iterations); |
| 441 | KSPGetResidualNorm(d_petsc_ksp, &d_current_residual_norm); |
| 442 | |
| 443 | // Determine the convergence reason. |
| 444 | KSPConvergedReason reason; |
| 445 | KSPGetConvergedReason(d_petsc_ksp, &reason); |
| 446 | const bool converged = (static_cast<int>(reason) > 0); |
| 447 | if (d_enable_logging) reportPETScKSPConvergedReason(d_object_name, reason, plog); |
| 448 | |
| 449 | // Deallocate the solver, when necessary. |
| 450 | d_petsc_x = nullptr; |
| 451 | if (deallocate_after_solve) deallocateSolverState(); |
| 452 | |
| 453 | IBTK_TIMER_STOP(t_solve_system); |
| 454 | return converged; |
| 455 | } // solveSystem |
| 456 | |
| 457 | void |
| 458 | KrylovMobilitySolver::initializeSolverState(Vec x, Vec b) |
no test coverage detected