Actual source code: dlregisksp.c
petsc-3.10.5 2019-03-28
Report Typos and Errors

      2:  #include <petsc/private/pcimpl.h>
      3:  #include <petsc/private/pcpatchimpl.h>
      4:  #include <petsc/private/kspimpl.h>

      6: static const char *const PCSides_Shifted[]    = {"DEFAULT","LEFT","RIGHT","SYMMETRIC","PCSide","PC_",0};
      7: const char *const *const PCSides              = PCSides_Shifted + 1;
      8: const char *const        PCASMTypes[]         = {"NONE","RESTRICT","INTERPOLATE","BASIC","PCASMType","PC_ASM_",0};
      9: const char *const        PCGASMTypes[]        = {"NONE","RESTRICT","INTERPOLATE","BASIC","PCGASMType","PC_GASM_",0};
     10: const char *const        PCCompositeTypes[]   = {"ADDITIVE","MULTIPLICATIVE","SYMMETRIC_MULTIPLICATIVE","SPECIAL","SCHUR","PCCompositeType","PC_COMPOSITE",0};
     11: const char *const        PCPARMSGlobalTypes[] = {"RAS","SCHUR","BJ","PCPARMSGlobalType","PC_PARMS_",0};
     12: const char *const        PCPARMSLocalTypes[]  = {"ILU0","ILUK","ILUT","ARMS","PCPARMSLocalType","PC_PARMS_",0};
     13: const char *const        PCPatchConstructTypes[] = {"star", "vanka", "user", "python", "PCPatchSetConstructType", "PC_PATCH_", 0};

     15: const char *const        PCFailedReasons[]    = {"FACTOR_NOERROR","FACTOR_STRUCT_ZEROPIVOT","FACTOR_NUMERIC_ZEROPIVOT","FACTOR_OUTMEMORY","FACTOR_OTHER","SUBPC_ERROR",0};

     17: static PetscBool PCPackageInitialized = PETSC_FALSE;
     18: /*@C
     19:   PCFinalizePackage - This function destroys everything in the Petsc interface to the characteristics package. It is
     20:   called from PetscFinalize().

     22:   Level: developer

     24: .keywords: Petsc, destroy, package, mathematica
     25: .seealso: PetscFinalize()
     26: @*/
     27: PetscErrorCode  PCFinalizePackage(void)
     28: {

     32:   PetscFunctionListDestroy(&PCList);
     33:   PCPackageInitialized = PETSC_FALSE;
     34:   PCRegisterAllCalled  = PETSC_FALSE;
     35:   return(0);
     36: }

     38: /*@C
     39:   PCInitializePackage - This function initializes everything in the PC package. It is called
     40:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PCCreate()
     41:   when using static libraries.

     43:   Level: developer

     45: .keywords: PC, initialize, package
     46: .seealso: PetscInitialize()
     47: @*/
     48: PetscErrorCode  PCInitializePackage(void)
     49: {
     50:   char           logList[256];
     51:   PetscBool      opt,pkg;

     55:   if (PCPackageInitialized) return(0);
     56:   PCPackageInitialized = PETSC_TRUE;
     57:   /* Initialize subpackages */
     58:   PCGAMGInitializePackage();
     59:   PCBDDCInitializePackage();
     60:   /* Register Classes */
     61:   PetscClassIdRegister("Preconditioner",&PC_CLASSID);
     62:   /* Register Constructors */
     63:   PCRegisterAll();
     64:   /* Register Events */
     65:   PetscLogEventRegister("PCSetUp",          PC_CLASSID,&PC_SetUp);
     66:   PetscLogEventRegister("PCSetUpOnBlocks",  PC_CLASSID,&PC_SetUpOnBlocks);
     67:   PetscLogEventRegister("PCApply",          PC_CLASSID,&PC_Apply);
     68:   PetscLogEventRegister("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
     69:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
     70:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
     71:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
     72:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
     73:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);

     75:   PetscLogEventRegister("PCPATCHCreate",    PC_CLASSID, &PC_Patch_CreatePatches);
     76:   PetscLogEventRegister("PCPATCHComputeOp", PC_CLASSID, &PC_Patch_ComputeOp);
     77:   PetscLogEventRegister("PCPATCHSolve",     PC_CLASSID, &PC_Patch_Solve);
     78:   PetscLogEventRegister("PCPATCHApply",     PC_CLASSID, &PC_Patch_Apply);
     79:   PetscLogEventRegister("PCPATCHScatter",   PC_CLASSID, &PC_Patch_Scatter);
     80:   PetscLogEventRegister("PCPATCHPrealloc",  PC_CLASSID, &PC_Patch_Prealloc);

     82:   PetscLogEventRegister("KSPSolve_FS_0",    KSP_CLASSID,&KSP_Solve_FS_0);
     83:   PetscLogEventRegister("KSPSolve_FS_1",    KSP_CLASSID,&KSP_Solve_FS_1);
     84:   PetscLogEventRegister("KSPSolve_FS_2",    KSP_CLASSID,&KSP_Solve_FS_2);
     85:   PetscLogEventRegister("KSPSolve_FS_3",    KSP_CLASSID,&KSP_Solve_FS_3);
     86:   PetscLogEventRegister("KSPSolve_FS_4",    KSP_CLASSID,&KSP_Solve_FS_4);
     87:   PetscLogEventRegister("KSPSolve_FS_Schu", KSP_CLASSID,&KSP_Solve_FS_S);
     88:   PetscLogEventRegister("KSPSolve_FS_Up",   KSP_CLASSID,&KSP_Solve_FS_U);
     89:   PetscLogEventRegister("KSPSolve_FS_Low",  KSP_CLASSID,&KSP_Solve_FS_L);

     91:   /* Process info exclusions */
     92:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
     93:   if (opt) {
     94:     PetscStrInList("pc",logList,',',&pkg);
     95:     if (pkg) {PetscInfoDeactivateClass(PC_CLASSID);}
     96:   }
     97:   /* Process summary exclusions */
     98:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
     99:   if (opt) {
    100:     PetscStrInList("pc",logList,',',&pkg);
    101:     if (pkg) {PetscLogEventExcludeClass(PC_CLASSID);}
    102:   }
    103:   /* Register data */
    104:   PetscObjectComposedDataRegister(&PetscMGLevelId);
    105:   /* Register package finalizer */
    106:   PetscRegisterFinalize(PCFinalizePackage);
    107:   return(0);
    108: }

    110: const char *const KSPCGTypes[]                  = {"SYMMETRIC","HERMITIAN","KSPCGType","KSP_CG_",0};
    111: const char *const KSPGMRESCGSRefinementTypes[]  = {"REFINE_NEVER", "REFINE_IFNEEDED", "REFINE_ALWAYS","KSPGMRESRefinementType","KSP_GMRES_CGS_",0};
    112: const char *const KSPNormTypes_Shifted[]        = {"DEFAULT","NONE","PRECONDITIONED","UNPRECONDITIONED","NATURAL","KSPNormType","KSP_NORM_",0};
    113: const char *const*const KSPNormTypes = KSPNormTypes_Shifted + 1;
    114: const char *const KSPConvergedReasons_Shifted[] = {"DIVERGED_PCSETUP_FAILED","DIVERGED_INDEFINITE_MAT","DIVERGED_NANORINF","DIVERGED_INDEFINITE_PC",
    115:                                                    "DIVERGED_NONSYMMETRIC", "DIVERGED_BREAKDOWN_BICG","DIVERGED_BREAKDOWN",
    116:                                                    "DIVERGED_DTOL","DIVERGED_ITS","DIVERGED_NULL","","CONVERGED_ITERATING",
    117:                                                    "CONVERGED_RTOL_NORMAL","CONVERGED_RTOL","CONVERGED_ATOL","CONVERGED_ITS",
    118:                                                    "CONVERGED_CG_NEG_CURVE","CONVERGED_CG_CONSTRAINED","CONVERGED_STEP_LENGTH",
    119:                                                    "CONVERGED_HAPPY_BREAKDOWN","CONVERGED_ATOL_NORMAL","KSPConvergedReason","KSP_",0};
    120: const char *const*KSPConvergedReasons = KSPConvergedReasons_Shifted + 11;
    121: const char *const KSPFCDTruncationTypes[] = {"STANDARD","NOTAY","KSPFCDTruncationTypes","KSP_FCD_TRUNC_TYPE_",0};

    123: static PetscBool KSPPackageInitialized = PETSC_FALSE;
    124: /*@C
    125:   KSPFinalizePackage - This function destroys everything in the Petsc interface to the KSP package. It is
    126:   called from PetscFinalize().

    128:   Level: developer

    130: .keywords: Petsc, destroy, package, mathematica
    131: .seealso: PetscFinalize()
    132: @*/
    133: PetscErrorCode  KSPFinalizePackage(void)
    134: {

    138:   PetscFunctionListDestroy(&KSPList);
    139:   PetscFunctionListDestroy(&KSPGuessList);
    140:   KSPPackageInitialized = PETSC_FALSE;
    141:   KSPRegisterAllCalled  = PETSC_FALSE;
    142:   return(0);
    143: }

    145: /*@C
    146:   KSPInitializePackage - This function initializes everything in the KSP package. It is called
    147:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to KSPCreate()
    148:   when using static libraries.

    150:   Level: developer

    152: .keywords: KSP, initialize, package
    153: .seealso: PetscInitialize()
    154: @*/
    155: PetscErrorCode  KSPInitializePackage(void)
    156: {
    157:   char           logList[256];
    158:   PetscBool      opt,pkg,cls;

    162:   if (KSPPackageInitialized) return(0);
    163:   KSPPackageInitialized = PETSC_TRUE;
    164:   /* Register Classes */
    165:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
    166:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
    167:   PetscClassIdRegister("KSPGuess interface",&KSPGUESS_CLASSID);
    168:   /* Register Constructors */
    169:   KSPRegisterAll();
    170:   /* Register matrix implementations packaged in KSP */
    171:   KSPMatRegisterAll();
    172:   /* Register KSP guesses implementations */
    173:   KSPGuessRegisterAll();
    174:   /* Register Events */
    175:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
    176:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
    177:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
    178:   /* Process info exclusions */
    179:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
    180:   if (opt) {
    181:     PetscStrInList("ksp",logList,',',&pkg);
    182:     if (pkg) {PetscInfoDeactivateClass(KSP_CLASSID);}
    183:     PetscStrInList("dm",logList,',',&cls);
    184:     if (pkg || cls) {PetscInfoDeactivateClass(DMKSP_CLASSID);}
    185:     PetscStrInList("kspguess",logList,',',&cls);
    186:     if (pkg || cls) {PetscInfoDeactivateClass(KSPGUESS_CLASSID);}
    187:   }
    188:   /* Process summary exclusions */
    189:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
    190:   if (opt) {
    191:     PetscStrInList("ksp",logList,',',&pkg);
    192:     if (pkg) {PetscLogEventExcludeClass(KSP_CLASSID);}
    193:     PetscStrInList("dm",logList,',',&cls);
    194:     if (pkg || cls) {PetscLogEventExcludeClass(DMKSP_CLASSID);}
    195:     PetscStrInList("kspguess",logList,',',&cls);
    196:     if (pkg || cls) {PetscLogEventExcludeClass(KSPGUESS_CLASSID);}
    197:   }
    198:   /* Register package finalizer */
    199:   PetscRegisterFinalize(KSPFinalizePackage);
    200:   return(0);
    201: }

    203: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

    205: /*
    206:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

    208:   This one registers all the KSP and PC methods that are in the basic PETSc libpetscksp
    209:   library.

    211:  */
    212: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
    213: {

    217:   PCInitializePackage();
    218:   KSPInitializePackage();
    219:   return(0);
    220: }

    222: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */