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

Method solveSystem

src/IB/KrylovMobilitySolver.cpp:422–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420} // setPhysicalBoundaryHelper
421
422bool
423KrylovMobilitySolver::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
457void
458KrylovMobilitySolver::initializeSolverState(Vec x, Vec b)

Callers 1

MatVecMult_KMInvMethod · 0.45

Calls 1

Tested by

no test coverage detected