Actual source code: dlregisksp.c

petsc-master 2019-08-18
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:   /* 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("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
 67:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
 68:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
 69:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
 70:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
 71:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);

 73:   PetscLogEventRegister("PCPATCHCreate",    PC_CLASSID, &PC_Patch_CreatePatches);
 74:   PetscLogEventRegister("PCPATCHComputeOp", PC_CLASSID, &PC_Patch_ComputeOp);
 75:   PetscLogEventRegister("PCPATCHSolve",     PC_CLASSID, &PC_Patch_Solve);
 76:   PetscLogEventRegister("PCPATCHApply",     PC_CLASSID, &PC_Patch_Apply);
 77:   PetscLogEventRegister("PCPATCHScatter",   PC_CLASSID, &PC_Patch_Scatter);
 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);

 89:   /* Process info exclusions */
 90:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
 91:   if (opt) {
 92:     PetscStrInList("pc",logList,',',&pkg);
 93:     if (pkg) {PetscInfoDeactivateClass(PC_CLASSID);}
 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_",0};
109: const char *const KSPGMRESCGSRefinementTypes[]  = {"REFINE_NEVER", "REFINE_IFNEEDED", "REFINE_ALWAYS","KSPGMRESRefinementType","KSP_GMRES_CGS_",0};
110: const char *const KSPNormTypes_Shifted[]        = {"DEFAULT","NONE","PRECONDITIONED","UNPRECONDITIONED","NATURAL","KSPNormType","KSP_NORM_",0};
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_",0};
118: const char *const*KSPConvergedReasons = KSPConvergedReasons_Shifted + 11;
119: const char *const KSPFCDTruncationTypes[] = {"STANDARD","NOTAY","KSPFCDTruncationTypes","KSP_FCD_TRUNC_TYPE_",0};

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: {

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

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

147:   Level: developer

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

158:   if (KSPPackageInitialized) return(0);
159:   KSPPackageInitialized = PETSC_TRUE;
160:   /* Register Classes */
161:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
162:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
163:   PetscClassIdRegister("KSPGuess interface",&KSPGUESS_CLASSID);
164:   /* Register Constructors */
165:   KSPRegisterAll();
166:   /* Register matrix implementations packaged in KSP */
167:   KSPMatRegisterAll();
168:   /* Register KSP guesses implementations */
169:   KSPGuessRegisterAll();
170:   /* Register Events */
171:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
172:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
173:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
174:   /* Process info exclusions */
175:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
176:   if (opt) {
177:     PetscStrInList("ksp",logList,',',&pkg);
178:     if (pkg) {PetscInfoDeactivateClass(KSP_CLASSID);}
179:     PetscStrInList("dm",logList,',',&cls);
180:     if (pkg || cls) {PetscInfoDeactivateClass(DMKSP_CLASSID);}
181:     PetscStrInList("kspguess",logList,',',&cls);
182:     if (pkg || cls) {PetscInfoDeactivateClass(KSPGUESS_CLASSID);}
183:   }
184:   /* Process summary exclusions */
185:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
186:   if (opt) {
187:     PetscStrInList("ksp",logList,',',&pkg);
188:     if (pkg) {PetscLogEventExcludeClass(KSP_CLASSID);}
189:     PetscStrInList("dm",logList,',',&cls);
190:     if (pkg || cls) {PetscLogEventExcludeClass(DMKSP_CLASSID);}
191:     PetscStrInList("kspguess",logList,',',&cls);
192:     if (pkg || cls) {PetscLogEventExcludeClass(KSPGUESS_CLASSID);}
193:   }
194:   /* Register package finalizer */
195:   PetscRegisterFinalize(KSPFinalizePackage);
196:   return(0);
197: }

199: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

207:  */
208: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
209: {

213:   PCInitializePackage();
214:   KSPInitializePackage();
215:   return(0);
216: }

218: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */