43 PetscLogDouble mem1, mem2;
44 PetscMemoryGetCurrentUsage(&mem1);
47 KSPNormType norm_type;
48 KSPGetNormType(
solver_, &norm_type);
52 PCGetType(
pc_, &pc_type);
54 PetscPrintf(PETSC_COMM_WORLD,
55 "\n================================================");
56 PetscPrintf(PETSC_COMM_WORLD,
57 "\nLinear solver %s with %s preconditioner using %s", ksp_type,
58 pc_type, KSPNormTypes[norm_type]);
64 KSPConvergedReason reason;
65 KSPGetConvergedReason(
solver_, &reason);
67 bool converged =
true;
71 KSPGetIterationNumber(
solver_, &its);
72 PetscPrintf(PETSC_COMM_WORLD,
"\nconverged in %d iterations", its);
75 case KSP_CONVERGED_RTOL:
76 PetscPrintf(PETSC_COMM_WORLD,
77 " (relative convergence criterion fulfilled).");
79 case KSP_CONVERGED_ATOL:
80 PetscPrintf(PETSC_COMM_WORLD,
81 " (absolute convergence criterion fulfilled).");
84 PetscPrintf(PETSC_COMM_WORLD,
".");
87 PetscPrintf(PETSC_COMM_WORLD,
88 "\n================================================\n");
90 else if (reason == KSP_DIVERGED_ITS)
92 PetscPrintf(PETSC_COMM_WORLD,
93 "\nWarning: maximum number of iterations reached.\n");
98 if (reason == KSP_DIVERGED_INDEFINITE_PC)
100 PetscPrintf(PETSC_COMM_WORLD,
101 "\nDivergence because of indefinite preconditioner,");
102 PetscPrintf(PETSC_COMM_WORLD,
103 "\nTry to run again with "
104 "-pc_factor_shift_positive_definite option.\n");
106 else if (reason == KSP_DIVERGED_BREAKDOWN_BICG)
108 PetscPrintf(PETSC_COMM_WORLD,
109 "\nKSPBICG method was detected so the method could not "
110 "continue to enlarge the Krylov space.");
111 PetscPrintf(PETSC_COMM_WORLD,
112 "\nTry to run again with another solver.\n");
114 else if (reason == KSP_DIVERGED_NONSYMMETRIC)
116 PetscPrintf(PETSC_COMM_WORLD,
117 "\nMatrix or preconditioner is unsymmetric but KSP "
118 "requires symmetric.\n");
122 PetscPrintf(PETSC_COMM_WORLD,
123 "\nDivergence detected, use command option "
124 "-ksp_monitor or -log_summary to check the details.\n");
129 PetscMemoryGetCurrentUsage(&mem2);
132 "###Memory usage by solver. Before: %f After: %f Increase: %d\n", mem1,
133 mem2, (
int)(mem2 - mem1));