| 431 | } // getCIBMobilitySolver |
| 432 | |
| 433 | bool |
| 434 | CIBSaddlePointSolver::solveSystem(Vec x, Vec b) |
| 435 | { |
| 436 | IBTK_TIMER_START(t_solve_system); |
| 437 | |
| 438 | // Initialize the solver, when necessary. |
| 439 | const bool deallocate_after_solve = !d_is_initialized; |
| 440 | if (deallocate_after_solve) initializeSolverState(x, b); |
| 441 | |
| 442 | d_petsc_x = x; |
| 443 | VecCopy(b, d_petsc_b); |
| 444 | |
| 445 | // Modify RHS for inhomogeneous Bcs. |
| 446 | d_A->setHomogeneousBc(false); |
| 447 | d_A->modifyRhsForBcs(d_petsc_b); |
| 448 | d_A->setHomogeneousBc(true); |
| 449 | |
| 450 | // Solve the system. |
| 451 | KSPSolve(d_petsc_ksp, d_petsc_b, d_petsc_x); |
| 452 | KSPGetIterationNumber(d_petsc_ksp, &d_current_iterations); |
| 453 | KSPGetResidualNorm(d_petsc_ksp, &d_current_residual_norm); |
| 454 | |
| 455 | // Impose Solution Bcs. |
| 456 | d_A->setHomogeneousBc(false); |
| 457 | d_A->imposeSolBcs(d_petsc_x); |
| 458 | |
| 459 | // Determine the convergence reason. |
| 460 | KSPConvergedReason reason; |
| 461 | KSPGetConvergedReason(d_petsc_ksp, &reason); |
| 462 | const bool converged = (static_cast<int>(reason) > 0); |
| 463 | if (d_enable_logging) reportPETScKSPConvergedReason(d_object_name, reason, plog); |
| 464 | |
| 465 | // Invalidate d_petsc_x Vec. |
| 466 | d_petsc_x = nullptr; |
| 467 | |
| 468 | // Deallocate the solver, when necessary. |
| 469 | if (deallocate_after_solve) deallocateSolverState(); |
| 470 | |
| 471 | IBTK_TIMER_STOP(t_solve_system); |
| 472 | return converged; |
| 473 | } // solveSystem |
| 474 | |
| 475 | void |
| 476 | CIBSaddlePointSolver::initializeSolverState(Vec x, Vec b) |
no test coverage detected