Actual source code: dlregisksp.c

petsc-3.13.4 2020-08-01
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","GKB","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", "pardecomp", "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: .seealso: PetscFinalize()
 25: @*/
 26: PetscErrorCode  PCFinalizePackage(void)
 27: {

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

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

 42:   Level: developer

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

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

 76:   PetscLogEventRegister("PCPATCHCreate",    PC_CLASSID, &PC_Patch_CreatePatches);
 77:   PetscLogEventRegister("PCPATCHComputeOp", PC_CLASSID, &PC_Patch_ComputeOp);
 78:   PetscLogEventRegister("PCPATCHSolve",     PC_CLASSID, &PC_Patch_Solve);
 79:   PetscLogEventRegister("PCPATCHApply",     PC_CLASSID, &PC_Patch_Apply);
 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);
 90:   /* Process Info */
 91:   {
 92:     PetscClassId  classids[1];

 94:     classids[0] = PC_CLASSID;
 95:     PetscInfoProcessClass("pc", 1, classids);
 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_PC_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: .seealso: PetscFinalize()
131: @*/
132: PetscErrorCode  KSPFinalizePackage(void)
133: {

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

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

149:   Level: developer

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

160:   if (KSPPackageInitialized) return(0);
161:   KSPPackageInitialized = PETSC_TRUE;
162:   /* Register Classes */
163:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
164:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
165:   PetscClassIdRegister("KSPGuess interface",&KSPGUESS_CLASSID);
166:   /* Register Constructors */
167:   KSPRegisterAll();
168:   /* Register matrix implementations packaged in KSP */
169:   KSPMatRegisterAll();
170:   /* Register KSP guesses implementations */
171:   KSPGuessRegisterAll();
172:   /* Register Events */
173:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
174:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
175:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
176:   PetscLogEventRegister("KSPSolveTranspos", KSP_CLASSID,&KSP_SolveTranspose);
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: {

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

222: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */