Date: 2022-03-04T17:39:00+00:00

Actual source code: dlregisksp.c

      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_",NULL};
      7: const char *const *const PCSides              = PCSides_Shifted + 1;
      8: const char *const        PCASMTypes[]         = {"NONE","RESTRICT","INTERPOLATE","BASIC","PCASMType","PC_ASM_",NULL};
      9: const char *const        PCGASMTypes[]        = {"NONE","RESTRICT","INTERPOLATE","BASIC","PCGASMType","PC_GASM_",NULL};
     10: const char *const        PCCompositeTypes[]   = {"ADDITIVE","MULTIPLICATIVE","SYMMETRIC_MULTIPLICATIVE","SPECIAL","SCHUR","GKB","PCCompositeType","PC_COMPOSITE",NULL};
     11: const char *const        PCPARMSGlobalTypes[] = {"RAS","SCHUR","BJ","PCPARMSGlobalType","PC_PARMS_",NULL};
     12: const char *const        PCPARMSLocalTypes[]  = {"ILU0","ILUK","ILUT","ARMS","PCPARMSLocalType","PC_PARMS_",NULL};
     13: const char *const        PCPatchConstructTypes[] = {"star", "vanka", "pardecomp", "user", "python", "PCPatchSetConstructType", "PC_PATCH_", NULL};

     15: const char *const        PCFailedReasons_Shifted[] = {"SETUP_ERROR","FACTOR_NOERROR","FACTOR_STRUCT_ZEROPIVOT","FACTOR_NUMERIC_ZEROPIVOT","FACTOR_OUTMEMORY","FACTOR_OTHER","SUBPC_ERROR",NULL};
     16: const char *const *const PCFailedReasons       = PCFailedReasons_Shifted + 1;

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

     23:   Level: developer

     25: .seealso: PetscFinalize()
     26: @*/
     27: PetscErrorCode  PCFinalizePackage(void)
     28: {

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

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

     44:   Level: developer

     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: #if defined(PETSC_HAVE_HPDDM) && defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES)
     61:   PCHPDDMInitializePackage();
     62: #endif
     63:   /* Register Classes */
     64:   PetscClassIdRegister("Preconditioner",&PC_CLASSID);
     65:   /* Register Constructors */
     66:   PCRegisterAll();
     67:   /* Register Events */
     68:   PetscLogEventRegister("PCSetUp",          PC_CLASSID,&PC_SetUp);
     69:   PetscLogEventRegister("PCSetUpOnBlocks",  PC_CLASSID,&PC_SetUpOnBlocks);
     70:   PetscLogEventRegister("PCApply",          PC_CLASSID,&PC_Apply);
     71:   PetscLogEventRegister("PCMatApply",       PC_CLASSID,&PC_MatApply);
     72:   PetscLogEventRegister("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
     73:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
     74:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
     75:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
     76:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
     77:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);

     79:   PetscLogEventRegister("PCPATCHCreate",    PC_CLASSID, &PC_Patch_CreatePatches);
     80:   PetscLogEventRegister("PCPATCHComputeOp", PC_CLASSID, &PC_Patch_ComputeOp);
     81:   PetscLogEventRegister("PCPATCHSolve",     PC_CLASSID, &PC_Patch_Solve);
     82:   PetscLogEventRegister("PCPATCHApply",     PC_CLASSID, &PC_Patch_Apply);
     83:   PetscLogEventRegister("PCPATCHPrealloc",  PC_CLASSID, &PC_Patch_Prealloc);

     85:   PetscLogEventRegister("KSPSolve_FS_0",    KSP_CLASSID,&KSP_Solve_FS_0);
     86:   PetscLogEventRegister("KSPSolve_FS_1",    KSP_CLASSID,&KSP_Solve_FS_1);
     87:   PetscLogEventRegister("KSPSolve_FS_2",    KSP_CLASSID,&KSP_Solve_FS_2);
     88:   PetscLogEventRegister("KSPSolve_FS_3",    KSP_CLASSID,&KSP_Solve_FS_3);
     89:   PetscLogEventRegister("KSPSolve_FS_4",    KSP_CLASSID,&KSP_Solve_FS_4);
     90:   PetscLogEventRegister("KSPSolve_FS_Schu", KSP_CLASSID,&KSP_Solve_FS_S);
     91:   PetscLogEventRegister("KSPSolve_FS_Up",   KSP_CLASSID,&KSP_Solve_FS_U);
     92:   PetscLogEventRegister("KSPSolve_FS_Low",  KSP_CLASSID,&KSP_Solve_FS_L);
     93:   /* Process Info */
     94:   {
     95:     PetscClassId  classids[1];

     97:     classids[0] = PC_CLASSID;
     98:     PetscInfoProcessClass("pc", 1, classids);
     99:   }
    100:   /* Process summary exclusions */
    101:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
    102:   if (opt) {
    103:     PetscStrInList("pc",logList,',',&pkg);
    104:     if (pkg) {PetscLogEventExcludeClass(PC_CLASSID);}
    105:   }
    106:   /* Register data */
    107:   PetscObjectComposedDataRegister(&PetscMGLevelId);
    108:   /* Register package finalizer */
    109:   PetscRegisterFinalize(PCFinalizePackage);
    110:   return(0);
    111: }

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

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

    131:   Level: developer

    133: .seealso: PetscFinalize()
    134: @*/
    135: PetscErrorCode  KSPFinalizePackage(void)
    136: {

    140:   PetscFunctionListDestroy(&KSPList);
    141:   PetscFunctionListDestroy(&KSPGuessList);
    142:   PetscFunctionListDestroy(&KSPMonitorList);
    143:   PetscFunctionListDestroy(&KSPMonitorCreateList);
    144:   PetscFunctionListDestroy(&KSPMonitorDestroyList);
    145:   KSPPackageInitialized       = PETSC_FALSE;
    146:   KSPRegisterAllCalled        = PETSC_FALSE;
    147:   KSPMonitorRegisterAllCalled = PETSC_FALSE;
    148:   return(0);
    149: }

    151: /*@C
    152:   KSPInitializePackage - This function initializes everything in the KSP package. It is called
    153:   from PetscDLLibraryRegister_petscksp() when using dynamic libraries, and on the first call to KSPCreate()
    154:   when using shared or static libraries.

    156:   Level: developer

    158: .seealso: PetscInitialize()
    159: @*/
    160: PetscErrorCode KSPInitializePackage(void)
    161: {
    162:   char           logList[256];
    163:   PetscBool      opt,pkg,cls;

    167:   if (KSPPackageInitialized) return(0);
    168:   KSPPackageInitialized = PETSC_TRUE;
    169:   /* Register Classes */
    170:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
    171:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
    172:   PetscClassIdRegister("KSPGuess interface",&KSPGUESS_CLASSID);
    173:   /* Register Constructors */
    174:   KSPRegisterAll();
    175:   /* Register matrix implementations packaged in KSP */
    176:   KSPMatRegisterAll();
    177:   /* Register KSP guesses implementations */
    178:   KSPGuessRegisterAll();
    179:   /* Register Monitors */
    180:   KSPMonitorRegisterAll();
    181:   /* Register Events */
    182:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
    183:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
    184:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
    185:   PetscLogEventRegister("KSPSolveTranspos", KSP_CLASSID,&KSP_SolveTranspose);
    186:   PetscLogEventRegister("KSPMatSolve",      KSP_CLASSID,&KSP_MatSolve);
    187:   /* Process Info */
    188:   {
    189:     PetscClassId  classids[3];

    191:     classids[0] = KSP_CLASSID;
    192:     classids[1] = DMKSP_CLASSID;
    193:     classids[2] = KSPGUESS_CLASSID;
    194:     PetscInfoProcessClass("ksp", 1, &classids[0]);
    195:     PetscInfoProcessClass("dm", 1, &classids[1]);
    196:     PetscInfoProcessClass("kspguess", 1, &classids[2]);
    197:   }
    198:   /* Process summary exclusions */
    199:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
    200:   if (opt) {
    201:     PetscStrInList("ksp",logList,',',&pkg);
    202:     if (pkg) {PetscLogEventExcludeClass(KSP_CLASSID);}
    203:     PetscStrInList("dm",logList,',',&cls);
    204:     if (pkg || cls) {PetscLogEventExcludeClass(DMKSP_CLASSID);}
    205:     PetscStrInList("kspguess",logList,',',&cls);
    206:     if (pkg || cls) {PetscLogEventExcludeClass(KSPGUESS_CLASSID);}
    207:   }
    208:   /* Register package finalizer */
    209:   PetscRegisterFinalize(KSPFinalizePackage);
    210:   return(0);
    211: }

    213: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

    221:  */
    222: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
    223: {

    227:   PCInitializePackage();
    228:   KSPInitializePackage();
    229:   return(0);
    230: }

    232: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */