Actual source code: dlregisksp.c

petsc-master 2020-07-14
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[]    = {"FACTOR_NOERROR","FACTOR_STRUCT_ZEROPIVOT","FACTOR_NUMERIC_ZEROPIVOT","FACTOR_OUTMEMORY","FACTOR_OTHER","SUBPC_ERROR",NULL};

 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("PCMatApply",       PC_CLASSID,&PC_MatApply);
 70:   PetscLogEventRegister("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
 71:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
 72:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
 73:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
 74:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
 75:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);

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

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

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

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

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

129:   Level: developer

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_petscksp() when using dynamic libraries, and on the first call to KSPCreate()
148:   when using shared or static libraries.

150:   Level: developer

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

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

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

205: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

213:  */
214: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
215: {

219:   PCInitializePackage();
220:   KSPInitializePackage();
221:   return(0);
222: }

224: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */