Date: 2022-08-02T03:14:38+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: {
     29:   PetscFunctionListDestroy(&PCList);
     30:   PetscFunctionListDestroy(&PCMGCoarseList);
     31:   PCPackageInitialized = PETSC_FALSE;
     32:   PCRegisterAllCalled  = PETSC_FALSE;
     33:   return 0;
     34: }

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

     41:   Level: developer

     43: .seealso: PetscInitialize()
     44: @*/
     45: PetscErrorCode  PCInitializePackage(void)
     46: {
     47:   char           logList[256];
     48:   PetscBool      opt,pkg;

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

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

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

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

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

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

    126:   Level: developer

    128: .seealso: PetscFinalize()
    129: @*/
    130: PetscErrorCode  KSPFinalizePackage(void)
    131: {
    132:   PetscFunctionListDestroy(&KSPList);
    133:   PetscFunctionListDestroy(&KSPGuessList);
    134:   PetscFunctionListDestroy(&KSPMonitorList);
    135:   PetscFunctionListDestroy(&KSPMonitorCreateList);
    136:   PetscFunctionListDestroy(&KSPMonitorDestroyList);
    137:   KSPPackageInitialized       = PETSC_FALSE;
    138:   KSPRegisterAllCalled        = PETSC_FALSE;
    139:   KSPMonitorRegisterAllCalled = PETSC_FALSE;
    140:   return 0;
    141: }

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

    148:   Level: developer

    150: .seealso: PetscInitialize()
    151: @*/
    152: PetscErrorCode KSPInitializePackage(void)
    153: {
    154:   char           logList[256];
    155:   PetscBool      opt,pkg,cls;

    157:   if (KSPPackageInitialized) return 0;
    158:   KSPPackageInitialized = PETSC_TRUE;
    159:   /* Register Classes */
    160:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
    161:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
    162:   PetscClassIdRegister("KSPGuess interface",&KSPGUESS_CLASSID);
    163:   /* Register Constructors */
    164:   KSPRegisterAll();
    165:   /* Register matrix implementations packaged in KSP */
    166:   KSPMatRegisterAll();
    167:   /* Register KSP guesses implementations */
    168:   KSPGuessRegisterAll();
    169:   /* Register Monitors */
    170:   KSPMonitorRegisterAll();
    171:   /* Register Events */
    172:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
    173:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
    174:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
    175:   PetscLogEventRegister("KSPSolveTranspos", KSP_CLASSID,&KSP_SolveTranspose);
    176:   PetscLogEventRegister("KSPMatSolve",      KSP_CLASSID,&KSP_MatSolve);
    177:   /* Process Info */
    178:   {
    179:     PetscClassId  classids[3];

    181:     classids[0] = KSP_CLASSID;
    182:     classids[1] = DMKSP_CLASSID;
    183:     classids[2] = KSPGUESS_CLASSID;
    184:     PetscInfoProcessClass("ksp", 1, &classids[0]);
    185:     PetscInfoProcessClass("dm", 1, &classids[1]);
    186:     PetscInfoProcessClass("kspguess", 1, &classids[2]);
    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: {
    214:   PCInitializePackage();
    215:   KSPInitializePackage();
    216:   return 0;
    217: }

    219: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */