1 /* 2 Defines the interface functions for the Krylov subspace accelerators. 3 */ 4 #ifndef __PETSCKSP_H 5 #define __PETSCKSP_H 6 #include "petscpc.h" 7 PETSC_EXTERN_CXX_BEGIN 8 9 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPInitializePackage(const char[]); 10 11 /*S 12 KSP - Abstract PETSc object that manages all Krylov methods 13 14 Level: beginner 15 16 Concepts: Krylov methods 17 18 .seealso: KSPCreate(), KSPSetType(), KSPType, SNES, TS, PC, KSP 19 S*/ 20 typedef struct _p_KSP* KSP; 21 22 /*E 23 KSPType - String with the name of a PETSc Krylov method or the creation function 24 with an optional dynamic library name, for example 25 http://www.mcs.anl.gov/petsc/lib.a:mykspcreate() 26 27 Level: beginner 28 29 .seealso: KSPSetType(), KSP 30 E*/ 31 #define KSPRICHARDSON "richardson" 32 #define KSPCHEBYCHEV "chebychev" 33 #define KSPCG "cg" 34 #define KSPCGNE "cgne" 35 #define KSPSTCG "stcg" 36 #define KSPGMRES "gmres" 37 #define KSPFGMRES "fgmres" 38 #define KSPLGMRES "lgmres" 39 #define KSPTCQMR "tcqmr" 40 #define KSPBCGS "bcgs" 41 #define KSPBCGSL "bcgsl" 42 #define KSPCGS "cgs" 43 #define KSPTFQMR "tfqmr" 44 #define KSPCR "cr" 45 #define KSPLSQR "lsqr" 46 #define KSPPREONLY "preonly" 47 #define KSPQCG "qcg" 48 #define KSPBICG "bicg" 49 #define KSPMINRES "minres" 50 #define KSPSYMMLQ "symmlq" 51 #define KSPLCD "lcd" 52 #define KSPType const char* 53 54 /* Logging support */ 55 extern PetscCookie PETSCKSP_DLLEXPORT KSP_COOKIE; 56 57 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPCreate(MPI_Comm,KSP *); 58 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetType(KSP,KSPType); 59 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetUp(KSP); 60 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetUpOnBlocks(KSP); 61 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSolve(KSP,Vec,Vec); 62 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSolveTranspose(KSP,Vec,Vec); 63 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPDestroy(KSP); 64 65 extern PetscFList KSPList; 66 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPRegisterAll(const char[]); 67 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPRegisterDestroy(void); 68 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPRegister(const char[],const char[],const char[],PetscErrorCode (*)(KSP)); 69 70 /*MC 71 KSPRegisterDynamic - Adds a method to the Krylov subspace solver package. 72 73 Synopsis: 74 PetscErrorCode KSPRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(KSP)) 75 76 Not Collective 77 78 Input Parameters: 79 + name_solver - name of a new user-defined solver 80 . path - path (either absolute or relative) the library containing this solver 81 . name_create - name of routine to create method context 82 - routine_create - routine to create method context 83 84 Notes: 85 KSPRegisterDynamic() may be called multiple times to add several user-defined solvers. 86 87 If dynamic libraries are used, then the fourth input argument (routine_create) 88 is ignored. 89 90 Sample usage: 91 .vb 92 KSPRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a, 93 "MySolverCreate",MySolverCreate); 94 .ve 95 96 Then, your solver can be chosen with the procedural interface via 97 $ KSPSetType(ksp,"my_solver") 98 or at runtime via the option 99 $ -ksp_type my_solver 100 101 Level: advanced 102 103 Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR}, 104 and others of the form ${any_environmental_variable} occuring in pathname will be 105 replaced with appropriate values. 106 If your function is not being put into a shared library then use KSPRegister() instead 107 108 .keywords: KSP, register 109 110 .seealso: KSPRegisterAll(), KSPRegisterDestroy() 111 112 M*/ 113 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 114 #define KSPRegisterDynamic(a,b,c,d) KSPRegister(a,b,c,0) 115 #else 116 #define KSPRegisterDynamic(a,b,c,d) KSPRegister(a,b,c,d) 117 #endif 118 119 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetType(KSP,KSPType *); 120 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetPreconditionerSide(KSP,PCSide); 121 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetPreconditionerSide(KSP,PCSide*); 122 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetTolerances(KSP,PetscReal*,PetscReal*,PetscReal*,PetscInt*); 123 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetTolerances(KSP,PetscReal,PetscReal,PetscReal,PetscInt); 124 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetInitialGuessNonzero(KSP,PetscTruth); 125 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetInitialGuessNonzero(KSP,PetscTruth *); 126 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetInitialGuessKnoll(KSP,PetscTruth); 127 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetInitialGuessKnoll(KSP,PetscTruth*); 128 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetComputeEigenvalues(KSP,PetscTruth*); 129 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetComputeEigenvalues(KSP,PetscTruth); 130 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetComputeSingularValues(KSP,PetscTruth*); 131 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetComputeSingularValues(KSP,PetscTruth); 132 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetRhs(KSP,Vec *); 133 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetSolution(KSP,Vec *); 134 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetResidualNorm(KSP,PetscReal*); 135 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetIterationNumber(KSP,PetscInt*); 136 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetNullSpace(KSP,MatNullSpace); 137 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetNullSpace(KSP,MatNullSpace*); 138 139 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetPC(KSP,PC); 140 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetPC(KSP,PC*); 141 142 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetMonitor(KSP,PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*),void *,PetscErrorCode (*)(void*)); 143 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPClearMonitor(KSP); 144 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetMonitorContext(KSP,void **); 145 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetResidualHistory(KSP,PetscReal*[],PetscInt *); 146 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetResidualHistory(KSP,PetscReal[],PetscInt,PetscTruth); 147 148 /* not sure where to put this */ 149 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCKSPGetKSP(PC,KSP*); 150 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCBJacobiGetSubKSP(PC,PetscInt*,PetscInt*,KSP*[]); 151 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCASMGetSubKSP(PC,PetscInt*,PetscInt*,KSP*[]); 152 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCFieldSplitGetSubKSP(PC,PetscInt*,KSP*[]); 153 154 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPBuildSolution(KSP,Vec,Vec *); 155 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPBuildResidual(KSP,Vec,Vec,Vec *); 156 157 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPRichardsonSetScale(KSP,PetscReal); 158 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPChebychevSetEigenvalues(KSP,PetscReal,PetscReal); 159 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPComputeExtremeSingularValues(KSP,PetscReal*,PetscReal*); 160 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPComputeEigenvalues(KSP,PetscInt,PetscReal*,PetscReal*,PetscInt *); 161 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPComputeEigenvaluesExplicitly(KSP,PetscInt,PetscReal*,PetscReal*); 162 163 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESSetRestart(KSP, PetscInt); 164 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESSetHapTol(KSP,PetscReal); 165 166 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESSetPreAllocateVectors(KSP); 167 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESSetOrthogonalization(KSP,PetscErrorCode (*)(KSP,PetscInt)); 168 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESModifiedGramSchmidtOrthogonalization(KSP,PetscInt); 169 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESClassicalGramSchmidtOrthogonalization(KSP,PetscInt); 170 171 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGMRESSetAugDim(KSP,PetscInt); 172 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGMRESSetConstant(KSP); 173 174 /*E 175 KSPGMRESCGSRefinementType - How the classical (unmodified) Gram-Schmidt is performed. 176 177 Level: advanced 178 179 .seealso: KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESSetOrthogonalization(), 180 KSPGMRESSetCGSRefinementType(), KSPGMRESModifiedGramSchmidtOrthogonalization() 181 182 E*/ 183 typedef enum {KSP_GMRES_CGS_REFINE_NEVER, KSP_GMRES_CGS_REFINE_IFNEEDED, KSP_GMRES_CGS_REFINE_ALWAYS} KSPGMRESCGSRefinementType; 184 extern const char *KSPGMRESCGSRefinementTypes[]; 185 /*MC 186 KSP_GMRES_CGS_REFINE_NEVER - Just do the classical (unmodified) Gram-Schmidt process 187 188 Level: advanced 189 190 Note: Possible unstable, but the fastest to compute 191 192 .seealso: KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESSetOrthogonalization(), 193 KSPGMRESSetCGSRefinementType(), KSP_GMRES_CGS_REFINE_IFNEEDED, KSP_GMRES_CGS_REFINE_ALWAYS, 194 KSPGMRESModifiedGramSchmidtOrthogonalization() 195 M*/ 196 197 /*MC 198 KSP_GMRES_CGS_REFINE_IFNEEDED - Do the classical (unmodified) Gram-Schmidt process and one step of 199 iterative refinement if an estimate of the orthogonality of the resulting vectors indicates 200 poor orthogonality. 201 202 Level: advanced 203 204 Note: This is slower than KSP_GMRES_CGS_REFINE_NEVER because it requires an extra norm computation to 205 estimate the orthogonality but is more stable. 206 207 .seealso: KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESSetOrthogonalization(), 208 KSPGMRESSetCGSRefinementType(), KSP_GMRES_CGS_REFINE_NEVER, KSP_GMRES_CGS_REFINE_ALWAYS, 209 KSPGMRESModifiedGramSchmidtOrthogonalization() 210 M*/ 211 212 /*MC 213 KSP_GMRES_CGS_REFINE_NEVER - Do two steps of the classical (unmodified) Gram-Schmidt process. 214 215 Level: advanced 216 217 Note: This is roughly twice the cost of KSP_GMRES_CGS_REFINE_NEVER because it performs the process twice 218 but it saves the extra norm calculation needed by KSP_GMRES_CGS_REFINE_IFNEEDED. 219 220 You should only use this if you absolutely know that the iterative refinement is needed. 221 222 .seealso: KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESSetOrthogonalization(), 223 KSPGMRESSetCGSRefinementType(), KSP_GMRES_CGS_REFINE_IFNEEDED, KSP_GMRES_CGS_REFINE_ALWAYS, 224 KSPGMRESModifiedGramSchmidtOrthogonalization() 225 M*/ 226 227 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESSetCGSRefinementType(KSP,KSPGMRESCGSRefinementType); 228 229 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPFGMRESModifyPCNoChange(KSP,PetscInt,PetscInt,PetscReal,void*); 230 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPFGMRESModifyPCKSP(KSP,PetscInt,PetscInt,PetscReal,void*); 231 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPFGMRESSetModifyPC(KSP,PetscErrorCode (*)(KSP,PetscInt,PetscInt,PetscReal,void*),void*,PetscErrorCode(*)(void*)); 232 233 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPQCGSetTrustRegionRadius(KSP,PetscReal); 234 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPQCGGetQuadratic(KSP,PetscReal*); 235 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPQCGGetTrialStepNorm(KSP,PetscReal*); 236 237 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPBCGSLSetXRes(KSP,PetscReal); 238 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPBCGSLSetPol(KSP,PetscTruth); 239 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPBCGSLSetEll(KSP,int); 240 241 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetFromOptions(KSP); 242 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPAddOptionsChecker(PetscErrorCode (*)(KSP)); 243 244 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSingularValueMonitor(KSP,PetscInt,PetscReal,void *); 245 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPDefaultMonitor(KSP,PetscInt,PetscReal,void *); 246 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPTrueMonitor(KSP,PetscInt,PetscReal,void *); 247 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPDefaultSMonitor(KSP,PetscInt,PetscReal,void *); 248 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPVecViewMonitor(KSP,PetscInt,PetscReal,void *); 249 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGMRESKrylovMonitor(KSP,PetscInt,PetscReal,void *); 250 251 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPUnwindPreconditioner(KSP,Vec,Vec); 252 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPDefaultBuildSolution(KSP,Vec,Vec*); 253 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPDefaultBuildResidual(KSP,Vec,Vec,Vec *); 254 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPInitialResidual(KSP,Vec,Vec,Vec,Vec,Vec); 255 256 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetOperators(KSP,Mat,Mat,MatStructure); 257 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetOperators(KSP,Mat*,Mat*,MatStructure*); 258 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetOptionsPrefix(KSP,const char[]); 259 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPAppendOptionsPrefix(KSP,const char[]); 260 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetOptionsPrefix(KSP,const char*[]); 261 262 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetDiagonalScale(KSP,PetscTruth); 263 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetDiagonalScale(KSP,PetscTruth*); 264 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetDiagonalScaleFix(KSP,PetscTruth); 265 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetDiagonalScaleFix(KSP,PetscTruth*); 266 267 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPView(KSP,PetscViewer); 268 269 /*E 270 KSPNormType - Norm that is passed in the Krylov convergence 271 test routines. 272 273 Level: advanced 274 275 Notes: this must match finclude/petscksp.h 276 277 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPSetNormType(), 278 KSPSetConvergenceTest() 279 E*/ 280 typedef enum {KSP_NO_NORM = 0,KSP_PRECONDITIONED_NORM = 1,KSP_UNPRECONDITIONED_NORM = 2,KSP_NATURAL_NORM = 3} KSPNormType; 281 extern const char *KSPNormTypes[]; 282 /*MC 283 KSP_NO_NORM - Do not compute a norm during the Krylov process. This will 284 possibly save some computation but means the convergence test cannot 285 be based on a norm of a residual etc. 286 287 Level: advanced 288 289 Note: Some Krylov methods need to compute a residual norm and then this option is ignored 290 291 .seealso: KSPNormType, KSPSetNormType(), KSP_PRECONDITIONED_NORM, KSP_UNPRECONDITIONED_NORM, KSP_NATURAL_NORM 292 M*/ 293 294 /*MC 295 KSP_PRECONDITIONED_NORM - Compute the norm of the preconditioned residual and pass that to the 296 convergence test routine. 297 298 Level: advanced 299 300 .seealso: KSPNormType, KSPSetNormType(), KSP_NO_NORM, KSP_UNPRECONDITIONED_NORM, KSP_NATURAL_NORM, KSPSetConvergenceTest() 301 M*/ 302 303 /*MC 304 KSP_UNPRECONDITIONED_NORM - Compute the norm of the true residual (b - A*x) and pass that to the 305 convergence test routine. 306 307 Level: advanced 308 309 .seealso: KSPNormType, KSPSetNormType(), KSP_NO_NORM, KSP_PRECONDITIONED_NORM, KSP_NATURAL_NORM, KSPSetConvergenceTest() 310 M*/ 311 312 /*MC 313 KSP_NATURAL_NORM - Compute the 'natural norm' of residual sqrt((b - A*x)*B*(b - A*x)) and pass that to the 314 convergence test routine. 315 316 Level: advanced 317 318 .seealso: KSPNormType, KSPSetNormType(), KSP_NO_NORM, KSP_PRECONDITIONED_NORM, KSP_UNPRECONDITIONED_NORM, KSPSetConvergenceTest() 319 M*/ 320 321 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetNormType(KSP,KSPNormType); 322 323 /*E 324 KSPConvergedReason - reason a Krylov method was said to 325 have converged or diverged 326 327 Level: beginner 328 329 Notes: this must match finclude/petscksp.h 330 331 Developer note: The string versions of these are in 332 src/ksp/ksp/interface/itfunc.c called convergedreasons. 333 If these enums are changed you must change those. 334 335 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPSetTolerances() 336 E*/ 337 typedef enum {/* converged */ 338 KSP_CONVERGED_RTOL = 2, 339 KSP_CONVERGED_ATOL = 3, 340 KSP_CONVERGED_ITS = 4, 341 KSP_CONVERGED_STCG_NEG_CURVE = 5, 342 KSP_CONVERGED_STCG_CONSTRAINED = 6, 343 KSP_CONVERGED_STEP_LENGTH = 7, 344 /* diverged */ 345 KSP_DIVERGED_NULL = -2, 346 KSP_DIVERGED_ITS = -3, 347 KSP_DIVERGED_DTOL = -4, 348 KSP_DIVERGED_BREAKDOWN = -5, 349 KSP_DIVERGED_BREAKDOWN_BICG = -6, 350 KSP_DIVERGED_NONSYMMETRIC = -7, 351 KSP_DIVERGED_INDEFINITE_PC = -8, 352 KSP_DIVERGED_NAN = -9, 353 KSP_DIVERGED_INDEFINITE_MAT = -10, 354 355 KSP_CONVERGED_ITERATING = 0} KSPConvergedReason; 356 extern const char **KSPConvergedReasons; 357 358 /*MC 359 KSP_CONVERGED_RTOL - norm(r) <= rtol*norm(b) 360 361 Level: beginner 362 363 See KSPNormType and KSPSetNormType() for possible norms that may be used. By default 364 for left preconditioning it is the 2-norm of the preconditioned residual, and the 365 2-norm of the residual for right preconditioning 366 367 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 368 369 M*/ 370 371 /*MC 372 KSP_CONVERGED_ATOL - norm(r) <= atol 373 374 Level: beginner 375 376 See KSPNormType and KSPSetNormType() for possible norms that may be used. By default 377 for left preconditioning it is the 2-norm of the preconditioned residual, and the 378 2-norm of the residual for right preconditioning 379 380 Level: beginner 381 382 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 383 384 M*/ 385 386 /*MC 387 KSP_DIVERGED_DTOL - norm(r) >= dtol*norm(b) 388 389 Level: beginner 390 391 See KSPNormType and KSPSetNormType() for possible norms that may be used. By default 392 for left preconditioning it is the 2-norm of the preconditioned residual, and the 393 2-norm of the residual for right preconditioning 394 395 Level: beginner 396 397 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 398 399 M*/ 400 401 /*MC 402 KSP_DIVERGED_ITS - Ran out of iterations before any convergence criteria was 403 reached 404 405 Level: beginner 406 407 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 408 409 M*/ 410 411 /*MC 412 KSP_CONVERGED_ITS - Used by the KSPPREONLY solver after the single iteration of the 413 preconditioner is applied. 414 415 416 Level: beginner 417 418 419 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 420 421 M*/ 422 423 /*MC 424 KSP_DIVERGED_BREAKDOWN - A breakdown in the Krylov method was detected so the 425 method could not continue to enlarge the Krylov space. 426 427 Level: beginner 428 429 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 430 431 M*/ 432 433 /*MC 434 KSP_DIVERGED_BREAKDOWN_BICG - A breakdown in the KSPBICG method was detected so the 435 method could not continue to enlarge the Krylov space. 436 437 438 Level: beginner 439 440 441 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 442 443 M*/ 444 445 /*MC 446 KSP_DIVERGED_NONSYMMETRIC - It appears the operator or preconditioner is not 447 symmetric and this Krylov method (KSPCG, KSPMINRES, KSPCR) requires symmetry 448 449 Level: beginner 450 451 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 452 453 M*/ 454 455 /*MC 456 KSP_DIVERGED_INDEFINITE_PC - It appears the preconditioner is indefinite (has both 457 positive and negative eigenvalues) and this Krylov method (KSPCG) requires it to 458 be positive definite 459 460 Level: beginner 461 462 Notes: This can happen with the PCICC preconditioner, use -pc_factor_shift_positive_definite to force 463 the PCICC preconditioner to generate a positive definite preconditioner 464 465 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 466 467 M*/ 468 469 /*MC 470 KSP_CONVERGED_ITERATING - This flag is returned if you call KSPGetConvergedReason() 471 while the KSPSolve() is still running. 472 473 Level: beginner 474 475 .seealso: KSPSolve(), KSPGetConvergedReason(), KSPConvergedReason, KSPSetTolerances() 476 477 M*/ 478 479 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSetConvergenceTest(KSP,PetscErrorCode (*)(KSP,PetscInt,PetscReal,KSPConvergedReason*,void*),void *); 480 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetConvergenceContext(KSP,void **); 481 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPDefaultConverged(KSP,PetscInt,PetscReal,KSPConvergedReason*,void *); 482 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSkipConverged(KSP,PetscInt,PetscReal,KSPConvergedReason*,void *); 483 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPGetConvergedReason(KSP,KSPConvergedReason *); 484 485 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPComputeExplicitOperator(KSP,Mat *); 486 487 /*E 488 KSPCGType - Determines what type of CG to use 489 490 Level: beginner 491 492 .seealso: KSPCGSetType() 493 E*/ 494 typedef enum {KSP_CG_SYMMETRIC=0,KSP_CG_HERMITIAN=1} KSPCGType; 495 extern const char *KSPCGTypes[]; 496 497 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPCGSetType(KSP,KSPCGType); 498 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSTCGSetRadius(KSP,PetscReal); 499 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPSTCGGetQuadratic(KSP,PetscReal*); 500 501 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCPreSolve(PC,KSP); 502 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCPostSolve(PC,KSP); 503 504 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGMonitorCreate(const char[],const char[],int,int,int,int,PetscDrawLG*); 505 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGMonitor(KSP,PetscInt,PetscReal,void*); 506 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGMonitorDestroy(PetscDrawLG); 507 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGTrueMonitorCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*); 508 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGTrueMonitor(KSP,PetscInt,PetscReal,void*); 509 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT KSPLGTrueMonitorDestroy(PetscDrawLG); 510 511 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCShellSetPreSolve(PC,PetscErrorCode (*)(void*,KSP,Vec,Vec)); 512 EXTERN PetscErrorCode PETSCKSP_DLLEXPORT PCShellSetPostSolve(PC,PetscErrorCode (*)(void*,KSP,Vec,Vec)); 513 514 PETSC_EXTERN_CXX_END 515 #endif 516