This strikes me as functionality that should be put into the
Preconditioner base class and corresponding PetscPreconditioner
class. If you're getting this specific about preconditioner behavior
you should probably be using those classes directly.
Derek
Sent from my iPhone
On Jul 26, 2009, at 1:02 PM, David Knezevic <dknez@...> wrote:
> I've found the attached patch useful to be useful for problems where
> the system matrix is the same for successive solves. Worth checking
> in?
>
>  Dave
> Index: include/numerics/petsc_linear_solver.h
> ===================================================================
>  include/numerics/petsc_linear_solver.h (revision 3439)
> +++ include/numerics/petsc_linear_solver.h (working copy)
> @@ 210,6 +210,14 @@
> * con(di)verged.
> */
> virtual void print_converged_reason();
> +
> + /**
> + * Boolean flag to indicate whether we want to use an identical
> + * preconditioner to the previous solve. This saves substantial
> + * work in the case that the system matrix is unchanged on
> + * successive solves.
> + */
> + bool same_preconditioner;
>
> private:
>
> @@ 260,6 +268,8 @@
> this>_preconditioner_type = ILU_PRECOND;
> else
> this>_preconditioner_type = BLOCK_JACOBI_PRECOND;
> +
> + same_preconditioner = false;
> }
>
>
> Index: src/numerics/petsc_linear_solver.C
> ===================================================================
>  src/numerics/petsc_linear_solver.C (revision 3439)
> +++ src/numerics/petsc_linear_solver.C (working copy)
> @@ 449,9 +449,18 @@
> #else
>
> // Set operators. The input matrix works as the preconditioning
> matrix
>  ierr = KSPSetOperators(_ksp, matrix>mat(), precond>mat(),
>  SAME_NONZERO_PATTERN);
>  CHKERRABORT(libMesh::COMM_WORLD,ierr);
> + if(!same_preconditioner)
> + {
> + ierr = KSPSetOperators(_ksp, matrix>mat(), precond>mat(),
> + SAME_NONZERO_PATTERN);
> + CHKERRABORT(libMesh::COMM_WORLD,ierr);
> + }
> + else
> + {
> + ierr = KSPSetOperators(_ksp, matrix>mat(), precond>mat(),
> + SAME_PRECONDITIONER);
> + CHKERRABORT(libMesh::COMM_WORLD,ierr);
> + }
>
> // Set the tolerances for the iterative solver. Use the user
> supplied
> // tolerance for the relative residual & leave the others at
> default values.
> 
> 
> 
> 
> _______________________________________________
> Libmeshdevel mailing list
> Libmeshdevel@...
> https://lists.sourceforge.net/lists/listinfo/libmeshdevel
