Actual source code: dlregisksp.c

petsc-3.14.0 2020-09-29
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_",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)
 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:   KSPPackageInitialized = PETSC_FALSE;
143:   KSPRegisterAllCalled  = PETSC_FALSE;
144:   return(0);
145: }

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

152:   Level: developer

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

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

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

207: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

215:  */
216: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
217: {

221:   PCInitializePackage();
222:   KSPInitializePackage();
223:   return(0);
224: }

226: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */