Actual source code: dlregisksp.c

petsc-3.9.0 2018-04-07
Report Typos and Errors

  2:  #include <petsc/private/pcimpl.h>
  3:  #include <petsc/private/kspimpl.h>

  5: static const char *const PCSides_Shifted[]    = {"DEFAULT","LEFT","RIGHT","SYMMETRIC","PCSide","PC_",0};
  6: const char *const *const PCSides              = PCSides_Shifted + 1;
  7: const char *const        PCASMTypes[]         = {"NONE","RESTRICT","INTERPOLATE","BASIC","PCASMType","PC_ASM_",0};
  8: const char *const        PCGASMTypes[]        = {"NONE","RESTRICT","INTERPOLATE","BASIC","PCGASMType","PC_GASM_",0};
  9: const char *const        PCCompositeTypes[]   = {"ADDITIVE","MULTIPLICATIVE","SYMMETRIC_MULTIPLICATIVE","SPECIAL","SCHUR","PCCompositeType","PC_COMPOSITE",0};
 10: const char *const        PCPARMSGlobalTypes[] = {"RAS","SCHUR","BJ","PCPARMSGlobalType","PC_PARMS_",0};
 11: const char *const        PCPARMSLocalTypes[]  = {"ILU0","ILUK","ILUT","ARMS","PCPARMSLocalType","PC_PARMS_",0};

 13: const char *const        PCFailedReasons[]    = {"FACTOR_NOERROR","FACTOR_STRUCT_ZEROPIVOT","FACTOR_NUMERIC_ZEROPIVOT","FACTOR_OUTMEMORY","FACTOR_OTHER","SUBPC_ERROR",0};

 15: static PetscBool PCPackageInitialized = PETSC_FALSE;
 16: /*@C
 17:   PCFinalizePackage - This function destroys everything in the Petsc interface to the characteristics package. It is
 18:   called from PetscFinalize().

 20:   Level: developer

 22: .keywords: Petsc, destroy, package, mathematica
 23: .seealso: PetscFinalize()
 24: @*/
 25: PetscErrorCode  PCFinalizePackage(void)
 26: {

 30:   PetscFunctionListDestroy(&PCList);
 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() when using dynamic libraries, and on the first call to PCCreate()
 39:   when using static libraries.

 41:   Level: developer

 43: .keywords: PC, initialize, package
 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:   /* Register Classes */
 58:   PetscClassIdRegister("Preconditioner",&PC_CLASSID);
 59:   /* Register Constructors */
 60:   PCRegisterAll();
 61:   /* Register Events */
 62:   PetscLogEventRegister("PCSetUp",          PC_CLASSID,&PC_SetUp);
 63:   PetscLogEventRegister("PCSetUpOnBlocks",  PC_CLASSID,&PC_SetUpOnBlocks);
 64:   PetscLogEventRegister("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
 65:   PetscLogEventRegister("PCApply",          PC_CLASSID,&PC_Apply);
 66:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
 67:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
 68:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
 69:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
 70:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);

 72:   PetscLogEventRegister("KSPSolve_FS_0",    KSP_CLASSID,&KSP_Solve_FS_0);
 73:   PetscLogEventRegister("KSPSolve_FS_1",    KSP_CLASSID,&KSP_Solve_FS_1);
 74:   PetscLogEventRegister("KSPSolve_FS_2",    KSP_CLASSID,&KSP_Solve_FS_2);
 75:   PetscLogEventRegister("KSPSolve_FS_3",    KSP_CLASSID,&KSP_Solve_FS_3);
 76:   PetscLogEventRegister("KSPSolve_FS_4",    KSP_CLASSID,&KSP_Solve_FS_4);
 77:   PetscLogEventRegister("KSPSolve_FS_Schu", KSP_CLASSID,&KSP_Solve_FS_S);
 78:   PetscLogEventRegister("KSPSolve_FS_Up",   KSP_CLASSID,&KSP_Solve_FS_U);
 79:   PetscLogEventRegister("KSPSolve_FS_Low",  KSP_CLASSID,&KSP_Solve_FS_L);

 81:   /* Process info exclusions */
 82:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
 83:   if (opt) {
 84:     PetscStrInList("pc",logList,',',&pkg);
 85:     if (pkg) {PetscInfoDeactivateClass(PC_CLASSID);}
 86:   }
 87:   /* Process summary exclusions */
 88:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
 89:   if (opt) {
 90:     PetscStrInList("pc",logList,',',&pkg);
 91:     if (pkg) {PetscLogEventDeactivateClass(PC_CLASSID);}
 92:   }
 93:   /* Register data */
 94:   PetscObjectComposedDataRegister(&PetscMGLevelId);
 95:   /* Register package finalizer */
 96:   PetscRegisterFinalize(PCFinalizePackage);
 97:   return(0);
 98: }

100: const char *const KSPCGTypes[]                  = {"SYMMETRIC","HERMITIAN","KSPCGType","KSP_CG_",0};
101: const char *const KSPGMRESCGSRefinementTypes[]  = {"REFINE_NEVER", "REFINE_IFNEEDED", "REFINE_ALWAYS","KSPGMRESRefinementType","KSP_GMRES_CGS_",0};
102: const char *const KSPNormTypes_Shifted[]        = {"DEFAULT","NONE","PRECONDITIONED","UNPRECONDITIONED","NATURAL","KSPNormType","KSP_NORM_",0};
103: const char *const*const KSPNormTypes = KSPNormTypes_Shifted + 1;
104: const char *const KSPConvergedReasons_Shifted[] = {"DIVERGED_PCSETUP_FAILED","DIVERGED_INDEFINITE_MAT","DIVERGED_NANORINF","DIVERGED_INDEFINITE_PC",
105:                                                    "DIVERGED_NONSYMMETRIC", "DIVERGED_BREAKDOWN_BICG","DIVERGED_BREAKDOWN",
106:                                                    "DIVERGED_DTOL","DIVERGED_ITS","DIVERGED_NULL","","CONVERGED_ITERATING",
107:                                                    "CONVERGED_RTOL_NORMAL","CONVERGED_RTOL","CONVERGED_ATOL","CONVERGED_ITS",
108:                                                    "CONVERGED_CG_NEG_CURVE","CONVERGED_CG_CONSTRAINED","CONVERGED_STEP_LENGTH",
109:                                                    "CONVERGED_HAPPY_BREAKDOWN","CONVERGED_ATOL_NORMAL","KSPConvergedReason","KSP_",0};
110: const char *const*KSPConvergedReasons = KSPConvergedReasons_Shifted + 11;
111: const char *const KSPFCDTruncationTypes[] = {"STANDARD","NOTAY","KSPFCDTruncationTypes","KSP_FCD_TRUNC_TYPE_",0};

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

118:   Level: developer

120: .keywords: Petsc, destroy, package, mathematica
121: .seealso: PetscFinalize()
122: @*/
123: PetscErrorCode  KSPFinalizePackage(void)
124: {

128:   PetscFunctionListDestroy(&KSPList);
129:   PetscFunctionListDestroy(&KSPGuessList);
130:   KSPPackageInitialized = PETSC_FALSE;
131:   KSPRegisterAllCalled  = PETSC_FALSE;
132:   return(0);
133: }

135: /*@C
136:   KSPInitializePackage - This function initializes everything in the KSP package. It is called
137:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to KSPCreate()
138:   when using static libraries.

140:   Level: developer

142: .keywords: KSP, initialize, package
143: .seealso: PetscInitialize()
144: @*/
145: PetscErrorCode  KSPInitializePackage(void)
146: {
147:   char           logList[256];
148:   PetscBool      opt,pkg,cls;

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

193: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

201:  */
202: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
203: {

207:   PCInitializePackage();
208:   KSPInitializePackage();
209:   return(0);
210: }

212: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */