56 PetscLogDouble mem1, mem2;
57 PetscMemoryGetCurrentUsage(&mem1);
60 KSPNormType norm_type;
61 KSPGetNormType(
solver_, &norm_type);
65 PCGetType(
pc_, &pc_type);
67 PetscPrintf(PETSC_COMM_WORLD,
68 "\n================================================");
69 PetscPrintf(PETSC_COMM_WORLD,
70 "\nLinear solver %s with %s preconditioner using %s", ksp_type,
71 pc_type, KSPNormTypes[norm_type]);
77 KSPConvergedReason reason;
78 KSPGetConvergedReason(
solver_, &reason);
80 bool converged =
true;
84 KSPGetIterationNumber(
solver_, &its);
85 PetscPrintf(PETSC_COMM_WORLD,
"\nconverged in %d iterations", its);
88 case KSP_CONVERGED_RTOL:
89 PetscPrintf(PETSC_COMM_WORLD,
90 " (relative convergence criterion fulfilled).");
92 case KSP_CONVERGED_ATOL:
93 PetscPrintf(PETSC_COMM_WORLD,
94 " (absolute convergence criterion fulfilled).");
97 PetscPrintf(PETSC_COMM_WORLD,
".");
100 PetscPrintf(PETSC_COMM_WORLD,
101 "\n================================================\n");
103 else if (reason == KSP_DIVERGED_ITS)
105 PetscPrintf(PETSC_COMM_WORLD,
106 "\nWarning: maximum number of iterations reached.\n");
111 if (reason == KSP_DIVERGED_INDEFINITE_PC)
113 PetscPrintf(PETSC_COMM_WORLD,
114 "\nDivergence because of indefinite preconditioner,");
115 PetscPrintf(PETSC_COMM_WORLD,
116 "\nTry to run again with "
117 "-pc_factor_shift_positive_definite option.\n");
119 else if (reason == KSP_DIVERGED_BREAKDOWN_BICG)
121 PetscPrintf(PETSC_COMM_WORLD,
122 "\nKSPBICG method was detected so the method could not "
123 "continue to enlarge the Krylov space.");
124 PetscPrintf(PETSC_COMM_WORLD,
125 "\nTry to run again with another solver.\n");
127 else if (reason == KSP_DIVERGED_NONSYMMETRIC)
129 PetscPrintf(PETSC_COMM_WORLD,
130 "\nMatrix or preconditioner is unsymmetric but KSP "
131 "requires symmetric.\n");
135 PetscPrintf(PETSC_COMM_WORLD,
136 "\nDivergence detected, use command option "
137 "-ksp_monitor or -log_summary to check the details.\n");
142 PetscMemoryGetCurrentUsage(&mem2);
145 "###Memory usage by solver. Before: %f After: %f Increase: %d\n", mem1,
146 mem2, (
int)(mem2 - mem1));