Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
Close
From: David Knezevic <dknez@MIT.EDU>  20090726 19:03:09
Attachments:
same_preconditioner_patch

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 
From: Roy Stogner <roystgnr@ic...>  20090726 19:30:30

On Sun, 26 Jul 2009, David Knezevic 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? Yeah, but put the bool in the base class. Even if we only have the PETSc implementation for now, it'll be good to use the same interface if/when we add more support.  Roy 
From: David Knezevic <dknez@MIT.EDU>  20090726 21:05:39

Roy Stogner wrote: > > > On Sun, 26 Jul 2009, David Knezevic 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? > > Yeah, but put the bool in the base class. Even if we only have the > PETSc implementation for now, it'll be good to use the same interface > if/when we add more support. >  > Roy Done. 
From: Derek Gaston <friedmud@gm...>  20090726 21:13:34

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 