Beispiel #1
0
void PETSC_STDCALL   pcfactorsetfill_(PC pc,PetscReal *fill, int *__ierr ){
*__ierr = PCFactorSetFill(
	(PC)PetscToPointer((pc) ),*fill);
}
Beispiel #2
0
void
SolverLinearPetsc<T>::setPetscPreconditionerType()
{

    int ierr = 0;
#if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)
    ierr = PCFactorSetMatSolverPackage( M_pc,MATSOLVERUMFPACK );

    if ( ierr )
    {
        ierr = PCFactorSetMatSolverPackage( M_pc,MATSOLVERSUPERLU );

        if ( ierr )
        {
            ierr = PCFactorSetMatSolverPackage( M_pc,MATSOLVERPETSC );
        }
    }

#elif (PETSC_VERSION_MAJOR >= 3)
    ierr = PCFactorSetMatSolverPackage( M_pc,MAT_SOLVER_UMFPACK );

    if ( ierr )
    {
        ierr = PCFactorSetMatSolverPackage( M_pc,MAT_SOLVER_SUPERLU );

        if ( ierr )
        {
            ierr = PCFactorSetMatSolverPackage( M_pc,MAT_SOLVER_PETSC );
        }
    }

#endif
    DVLOG(2) << "[SolverLinearPetsc] preconditioner type:  " << this->preconditionerType() << "\n";

    switch ( this->preconditionerType() )
    {
    case IDENTITY_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCNONE );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case CHOLESKY_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCCHOLESKY );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case ICC_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCICC );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case ILU_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCILU );
        CHKERRABORT( this->worldComm().globalComm(),ierr );

        if ( this->vm().count( "pc-factor-levels" ) )
        {
            PCFactorSetLevels( M_pc,this->vm()["pc-factor-levels"].template as<int>() );
        }

        else
            PCFactorSetLevels( M_pc,3 );

        if ( this->vm().count( "pc-factor-fill" ) )
        {
            PCFactorSetFill( M_pc,this->vm()["pc-factor-fill"].template as<double>() );
        }

        else
            PCFactorSetFill( M_pc,40 );

        return;

    case LU_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCLU );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case ASM_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCASM );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

#if PETSC_VERSION_GREATER_OR_EQUAL_THAN( 3,2,0 )
    case GASM_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCGASM );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;
#endif

    case JACOBI_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCJACOBI );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case BLOCK_JACOBI_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCBJACOBI );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case SOR_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCSOR );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case EISENSTAT_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCEISENSTAT );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

#if !((PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR <= 1) && (PETSC_VERSION_SUBMINOR <= 1))

    case USER_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCMAT );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;
#endif

    case SHELL_PRECOND:
        ierr = PCSetType ( M_pc, ( char* ) PCSHELL );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case FIELDSPLIT_PRECOND:
        ierr = PCSetType( M_pc,( char* ) PCFIELDSPLIT );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        ierr = PCFieldSplitSetType( M_pc,PC_COMPOSITE_SCHUR );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    case ML_PRECOND:
        ierr = PCSetType( M_pc,( char* ) PCML );
        CHKERRABORT( this->worldComm().globalComm(),ierr );
        return;

    default:
        std::cerr << "ERROR:  Unsupported PETSC Preconditioner: "
                  << this->preconditionerType()       << std::endl
                  << "Continuing with PETSC defaults" << std::endl;
    }

}