Actual source code: dlregisksp.c

petsc-3.7.1 2016-05-15
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;
 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: .keywords: Petsc, destroy, package, mathematica
 25: .seealso: PetscFinalize()
 26: @*/
 27: PetscErrorCode  PCFinalizePackage(void)
 28: {

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

 40: /*@C
 41:   PCInitializePackage - This function initializes everything in the PC package. It is called
 42:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PCCreate()
 43:   when using static libraries.

 45:   Level: developer

 47: .keywords: PC, initialize, package
 48: .seealso: PetscInitialize()
 49: @*/
 50: PetscErrorCode  PCInitializePackage(void)
 51: {
 52:   char           logList[256];
 53:   char           *className;
 54:   PetscBool      opt;

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

 78:   PetscLogEventRegister("KSPSolve_FS_0",    KSP_CLASSID,&KSP_Solve_FS_0);
 79:   PetscLogEventRegister("KSPSolve_FS_1",    KSP_CLASSID,&KSP_Solve_FS_1);
 80:   PetscLogEventRegister("KSPSolve_FS_2",    KSP_CLASSID,&KSP_Solve_FS_2);
 81:   PetscLogEventRegister("KSPSolve_FS_3",    KSP_CLASSID,&KSP_Solve_FS_3);
 82:   PetscLogEventRegister("KSPSolve_FS_4",    KSP_CLASSID,&KSP_Solve_FS_4);
 83:   PetscLogEventRegister("KSPSolve_FS_Schu", KSP_CLASSID,&KSP_Solve_FS_S);
 84:   PetscLogEventRegister("KSPSolve_FS_Up",   KSP_CLASSID,&KSP_Solve_FS_U);
 85:   PetscLogEventRegister("KSPSolve_FS_Low",  KSP_CLASSID,&KSP_Solve_FS_L);

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

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

122: 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: .keywords: Petsc, destroy, package, mathematica
132: .seealso: PetscFinalize()
133: @*/
134: PetscErrorCode  KSPFinalizePackage(void)
135: {

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

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

152:   Level: developer

154: .keywords: KSP, initialize, package
155: .seealso: PetscInitialize()
156: @*/
157: PetscErrorCode  KSPInitializePackage(void)
158: {
159:   char           logList[256];
160:   char           *className;
161:   PetscBool      opt;

165:   if (KSPPackageInitialized) return(0);
166:   KSPPackageInitialized = PETSC_TRUE;
167:   /* Register Classes */
168:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
169:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
170:   /* Register Constructors */
171:   KSPRegisterAll();
172:   /* Register matrix implementations packaged in KSP */
173:   KSPMatRegisterAll();
174:   /* Register Events */
175:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
176:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
177:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
178: 
179:   /* Process info exclusions */
180:   PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);
181:   if (opt) {
182:     PetscStrstr(logList, "ksp", &className);
183:     if (className) {
184:       PetscInfoDeactivateClass(KSP_CLASSID);
185:     }
186:   }
187:   /* Process summary exclusions */
188:   PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);
189:   if (opt) {
190:     PetscStrstr(logList, "ksp", &className);
191:     if (className) {
192:       PetscLogEventDeactivateClass(KSP_CLASSID);
193:     }
194:   }
195:   PetscRegisterFinalize(KSPFinalizePackage);
196:   return(0);
197: }

199: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

209:  */
210: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
211: {

215:   PCInitializePackage();
216:   KSPInitializePackage();
217:   return(0);
218: }

220: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */