예제 #1
0
void PETScKrylovLinearSolver::setNullspace(
    const bool contains_constant_vec,
    const std::vector<Pointer<SAMRAIVectorReal<NDIM, double> > >& nullspace_basis_vecs)
{
    deallocateNullspaceData();
    KrylovLinearSolver::setNullspace(contains_constant_vec, nullspace_basis_vecs);
    resetKSPNullspace();
    return;
} // setNullspace
void
PETScKrylovLinearSolver::deallocateSolverState()
{
    if (!d_is_initialized) return;

    IBTK_TIMER_START(t_deallocate_solver_state);

    int ierr;

    // Deallocate the operator and preconditioner states only if we are not
    // re-initializing the solver.
    if (!d_reinitializing_solver)
    {
        if (d_pc_solver) d_pc_solver->deallocateSolverState();
        if (d_A) d_A->deallocateOperatorState();
    }

    // Delete the solution and rhs vectors.
    PETScSAMRAIVectorReal::destroyPETScVector(d_petsc_x);
    d_petsc_x = NULL;
    d_x->freeVectorComponents();
    d_x.setNull();

    PETScSAMRAIVectorReal::destroyPETScVector(d_petsc_b);
    d_petsc_b = NULL;
    d_b->freeVectorComponents();
    d_b.setNull();

    // Deallocate the nullspace object.
    deallocateNullspaceData();

    // Destroy the KSP solver.
    if (d_managing_petsc_ksp)
    {
        ierr = KSPDestroy(&d_petsc_ksp);
        IBTK_CHKERRQ(ierr);
        d_petsc_ksp = NULL;
        d_solver_has_attached_nullspace = false;
    }

    // Indicate that the solver is NOT initialized.
    d_is_initialized = false;

    IBTK_TIMER_STOP(t_deallocate_solver_state);
    return;
} // deallocateSolverState