Actual source code: dlregisksp.c

petsc-3.5.1 2014-08-06
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: 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: }

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

 43:   Level: developer

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

 56:   if (PCPackageInitialized) return(0);
 57:   PCPackageInitialized = PETSC_TRUE;
 58:   /* Initialize subpackages */
 59:   PCGAMGInitializePackage();
 60:   /* Register Classes */
 61:   PetscClassIdRegister("Preconditioner",&PC_CLASSID);
 62:   /* Register Constructors */
 63:   PCRegisterAll();
 64:   /* Register Events */
 65:   PetscLogEventRegister("PCSetUp",          PC_CLASSID,&PC_SetUp);
 66:   PetscLogEventRegister("PCSetUpOnBlocks",  PC_CLASSID,&PC_SetUpOnBlocks);
 67:   PetscLogEventRegister("PCApplyOnBlocks",  PC_CLASSID,&PC_ApplyOnBlocks);
 68:   PetscLogEventRegister("PCApplyOnMproc",   PC_CLASSID,&PC_ApplyOnMproc);
 69:   PetscLogEventRegister("PCApply",          PC_CLASSID,&PC_Apply);
 70:   PetscLogEventRegister("PCApplyCoarse",    PC_CLASSID,&PC_ApplyCoarse);
 71:   PetscLogEventRegister("PCApplyMultiple",  PC_CLASSID,&PC_ApplyMultiple);
 72:   PetscLogEventRegister("PCApplySymmLeft",  PC_CLASSID,&PC_ApplySymmetricLeft);
 73:   PetscLogEventRegister("PCApplySymmRight", PC_CLASSID,&PC_ApplySymmetricRight);
 74:   PetscLogEventRegister("PCModifySubMatri", PC_CLASSID,&PC_ModifySubMatrices);
 75:   /* Process info exclusions */
 76:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
 77:   if (opt) {
 78:     PetscStrstr(logList, "pc", &className);
 79:     if (className) {
 80:       PetscInfoDeactivateClass(PC_CLASSID);
 81:     }
 82:   }
 83:   /* Process summary exclusions */
 84:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
 85:   if (opt) {
 86:     PetscStrstr(logList, "pc", &className);
 87:     if (className) {
 88:       PetscLogEventDeactivateClass(PC_CLASSID);
 89:     }
 90:   }
 91:   PetscRegisterFinalize(PCFinalizePackage);
 92:   return(0);
 93: }

 95: const char *const KSPCGTypes[]                  = {"SYMMETRIC","HERMITIAN","KSPCGType","KSP_CG_",0};
 96: const char *const KSPGMRESCGSRefinementTypes[]  = {"REFINE_NEVER", "REFINE_IFNEEDED", "REFINE_ALWAYS","KSPGMRESRefinementType","KSP_GMRES_CGS_",0};
 97: const char *const KSPNormTypes_Shifted[]        = {"DEFAULT","NONE","PRECONDITIONED","UNPRECONDITIONED","NATURAL","KSPNormType","KSP_NORM_",0};
 98: const char *const*const KSPNormTypes = KSPNormTypes_Shifted + 1;
 99: const char *const KSPConvergedReasons_Shifted[] = {"DIVERGED_INDEFINITE_MAT","DIVERGED_NANORINF","DIVERGED_INDEFINITE_PC",
100:                                                    "DIVERGED_NONSYMMETRIC", "DIVERGED_BREAKDOWN_BICG","DIVERGED_BREAKDOWN",
101:                                                    "DIVERGED_DTOL","DIVERGED_ITS","DIVERGED_NULL","","CONVERGED_ITERATING",
102:                                                    "CONVERGED_RTOL_NORMAL","CONVERGED_RTOL","CONVERGED_ATOL","CONVERGED_ITS",
103:                                                    "CONVERGED_CG_NEG_CURVE","CONVERGED_CG_CONSTRAINED","CONVERGED_STEP_LENGTH",
104:                                                    "CONVERGED_HAPPY_BREAKDOWN","CONVERGED_ATOL_NORMAL","KSPConvergedReason","KSP_",0};
105: const char *const*KSPConvergedReasons = KSPConvergedReasons_Shifted + 10;

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

114:   Level: developer

116: .keywords: Petsc, destroy, package, mathematica
117: .seealso: PetscFinalize()
118: @*/
119: PetscErrorCode  KSPFinalizePackage(void)
120: {

124:   PetscFunctionListDestroy(&KSPList);
125:   KSPPackageInitialized = PETSC_FALSE;
126:   KSPRegisterAllCalled  = PETSC_FALSE;
127:   return(0);
128: }

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

137:   Level: developer

139: .keywords: KSP, initialize, package
140: .seealso: PetscInitialize()
141: @*/
142: PetscErrorCode  KSPInitializePackage(void)
143: {
144:   char           logList[256];
145:   char           *className;
146:   PetscBool      opt;

150:   if (KSPPackageInitialized) return(0);
151:   KSPPackageInitialized = PETSC_TRUE;
152:   /* Register Classes */
153:   PetscClassIdRegister("Krylov Solver",&KSP_CLASSID);
154:   PetscClassIdRegister("DMKSP interface",&DMKSP_CLASSID);
155:   /* Register Constructors */
156:   KSPRegisterAll();
157:   /* Register matrix implementations packaged in KSP */
158:   KSPMatRegisterAll();
159:   /* Register Events */
160:   PetscLogEventRegister("KSPGMRESOrthog",   KSP_CLASSID,&KSP_GMRESOrthogonalization);
161:   PetscLogEventRegister("KSPSetUp",         KSP_CLASSID,&KSP_SetUp);
162:   PetscLogEventRegister("KSPSolve",         KSP_CLASSID,&KSP_Solve);
163:   /* Process info exclusions */
164:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
165:   if (opt) {
166:     PetscStrstr(logList, "ksp", &className);
167:     if (className) {
168:       PetscInfoDeactivateClass(KSP_CLASSID);
169:     }
170:   }
171:   /* Process summary exclusions */
172:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
173:   if (opt) {
174:     PetscStrstr(logList, "ksp", &className);
175:     if (className) {
176:       PetscLogEventDeactivateClass(KSP_CLASSID);
177:     }
178:   }
179:   PetscRegisterFinalize(KSPFinalizePackage);
180:   return(0);
181: }

183: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

193:  */
194: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void)
195: {

199:   PCInitializePackage();
200:   KSPInitializePackage();
201:   return(0);
202: }

204: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */