Actual source code: dlregisksp.c

petsc-3.8.3 2017-12-09
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:   char           *className;
 50:   PetscBool      opt;

 54:   if (PCPackageInitialized) return(0);
 55:   PCPackageInitialized = PETSC_TRUE;
 56:   /* Initialize subpackages */
 57:   PCGAMGInitializePackage();
 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("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
 66:   PetscLogEventRegister("PCApplyOnMproc",   PC_CLASSID,&PC_ApplyOnMproc);
 67:   PetscLogEventRegister("PCApply",          PC_CLASSID,&PC_Apply);
 68:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
 69:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
 70:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
 71:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
 72:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);

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

 83:   /* Process info exclusions */
 84:   PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);
 85:   if (opt) {
 86:     PetscStrstr(logList, "pc", &className);
 87:     if (className) {
 88:       PetscInfoDeactivateClass(PC_CLASSID);
 89:     }
 90:   }
 91:   /* Process summary exclusions */
 92:   PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);
 93:   if (opt) {
 94:     PetscStrstr(logList, "pc", &className);
 95:     if (className) {
 96:       PetscLogEventDeactivateClass(PC_CLASSID);
 97:     }
 98:   }
 99:   /* Register data */
100:   PetscObjectComposedDataRegister(&PetscMGLevelId);
101:   PetscRegisterFinalize(PCFinalizePackage);
102:   return(0);
103: }

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

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

123:   Level: developer

125: .keywords: Petsc, destroy, package, mathematica
126: .seealso: PetscFinalize()
127: @*/
128: PetscErrorCode  KSPFinalizePackage(void)
129: {

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

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

145:   Level: developer

147: .keywords: KSP, initialize, package
148: .seealso: PetscInitialize()
149: @*/
150: PetscErrorCode  KSPInitializePackage(void)
151: {
152:   char           logList[256];
153:   char           *className;
154:   PetscBool      opt;

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("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
172:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
173:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
174: 
175:   /* Process info exclusions */
176:   PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);
177:   if (opt) {
178:     PetscStrstr(logList, "ksp", &className);
179:     if (className) {
180:       PetscInfoDeactivateClass(KSP_CLASSID);
181:     }
182:   }
183:   /* Process summary exclusions */
184:   PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);
185:   if (opt) {
186:     PetscStrstr(logList, "ksp", &className);
187:     if (className) {
188:       PetscLogEventDeactivateClass(KSP_CLASSID);
189:     }
190:   }
191:   PetscRegisterFinalize(KSPFinalizePackage);
192:   return(0);
193: }

195: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

203:  */
204: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
205: {

209:   PCInitializePackage();
210:   KSPInitializePackage();
211:   return(0);
212: }

214: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */