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

Method solveSystem

src/IB/CIBSaddlePointSolver.cpp:433–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431} // getCIBMobilitySolver
432
433bool
434CIBSaddlePointSolver::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
475void
476CIBSaddlePointSolver::initializeSolverState(Vec x, Vec b)

Callers 1

PCApply_SaddlePointMethod · 0.45

Calls 4

setHomogeneousBcMethod · 0.45
modifyRhsForBcsMethod · 0.45
imposeSolBcsMethod · 0.45

Tested by

no test coverage detected