Hi,

I'm quite a new user of deal.ii but I'm using petsc for years. I decided to
write starting from your previous discussion on command line arguments
since my arguments are strongly related.

I see that from deal, the convergence test is always performed as
norm_of_residual_calculated_by_petsc against
tolerance_of_deal_solver_control (using SolverBase::convergence_test). I
wish to use test for the relative residual (i.e. comparing
norm_of_residual_calculated_by_petsc against some_factor*initial_residual)
as a stopping criterion, but I cannot see how this can be done from source
code (as deal.ii philosophy prescribes :-) ) from my application. As an
example, I'm thus proposing the patch attached below for CG solver in
petsc_solver.cc .

Moreover, with the actual dev version of deal (I'm using rev 25383) passing
the total number of iterations from command line overrides the total number
of iterations specified in the constructor of the solver_control object
(and this is what I want in a Petsc philosophy). On the other hand, such an
override doesn't happen specyfing the iterative tolerances, since the
convergence test is owned by the deal convergence_test function.

I think that if the philosophy of my patch will be accepted,
petsc_owns_solver_convergence should be a protected member of PetscSolver
class and should initialized to false in the constructor if not provided
(in order to guarantie that all existing deal applications don't break).

With the patch above, I can specify -ksp_max_it max_number_of_iteration
-ksp_rtol reltol_value -ksp_atol abstol_value -ksp_divtol divergence_value
from command line and let PETSc use them.

As a note aside: I'm using Petsc-dev, so I don't know if it is acceptable
for PETSc versions minor than 3.2.0

Stefano

2011/12/16 Vijay S. Mahadevan <[email protected]>

> > That would be excellent. Let me know when you have something and we'll
> check> it all in together with the original patch.
>
> I added the documentation to petsc_solver.h at the appropriate
> location for SolverBase and the patch for the same is below. I only
> provided a basic pointer to the options available and the
> documentation, user manuals at the PETSc site provide enough details
> to help any user wanting to experiment. The ideas also extend to all
> of the PETScWrapper classes and perhaps moving this documentation to
> somewhere common would avoid duplication of the same information
> regarding command line options. If you feel the documentation is
> inadequate or if you want some more information on something specific,
> do let me know.
>
> Index: petsc_solver.h
> ===================================================================
> --- petsc_solver.h      (revision 24832)
> +++ petsc_solver.h      (working copy)
> @@ -69,6 +69,18 @@
>  * is the appropriate argument for the sequential case (which is why it is
> the
>  * default argument), so this error only shows up in parallel mode.
>  *
> + * Optionally, the user can create a solver derived from the SolverBase
> class
> + * and can set the default arguments necessary to solve the linear
> system of equations
> + * with SolverControl. These default options can be overridden by
> specifying command line
> + * arguments of the form -ksp_*. For example,
> -ksp_monitor_true_residual prints out true
> + * residual norm (unpreconditioned) at each iteration and -ksp_view
> provides information
> + * about the linear solver and the preconditioner used in the current
> context. The type
> + * of the solver can also be changed during runtime by specifying
> -ksp_type {richardson,
> + * cg, gmres, fgmres, ..} to dynamically test the optimal solver
> along with a suitable
> + * preconditioner set using -pc_type {jacobi, bjacobi, ilu, lu, ..}.
> There are several
> + * other command line options available to modify the behavior of the
> PETSc linear solver
> + * and can be obtained from the documentation and manual pages at
> http://www.mcs.anl.gov/petsc.
> + *
>  * @ingroup PETScWrappers
>  * @author Wolfgang Bangerth, 2004
>  */
>
>
> I also have another suggestion regarding the SolverBase class. It
> might be useful to add a set_prefix(std::string&) method to
> SolverBase. This would allow the user to name their linear solvers
> with say set_prefix("poisson_") which in turn would call
> KSPAppendOptionsPrefix on the KSP object. Then, all command line
> arguments will be of the form -poisson_ksp_* and any general option
> provided by the user as -ksp_* will not be propagated to this specific
> solver. This would be useful when you perform some nested solves where
> you could use FGMRes on the outer loop and perform GMRes solves
> inside, with different options provided for each solver from command
> line.
>
> Vijay
>
> On Thu, Dec 15, 2011 at 7:25 AM, Wolfgang Bangerth
> <[email protected]> wrote:
> >
> >> This is what I was going for. Yes and that's the PETSc philosophy.
> >> Coming from mostly a PETSc background, I found it incomprehensible to
> >> see the command line options ignored until I saw the code. But I
> >> figured the deal.II philosophy is different in this sense but
> >> nevertheless a little confusing. All the Mat, Vec, PC options are
> >> being set from command line while the KSP options are being ignored.
> >
> >
> > I didn't even realize that you can do that when using deal.II. It
> certainly
> > wasn't a design goal when writing the PETSc wrappers but if it works much
> > the better.
> >
> >
> >
> >> I can definitely send you something to clarify these aspects so that
> >> you can add them to the documentation.
> >
> >
> > That would be excellent. Let me know when you have something and we'll
> check
> > it all in together with the original patch.
> >
> > Best
> >  W.
> >
> >
> > ------------------------------------------------------------------------
> > Wolfgang Bangerth               email:            [email protected]
> >                                www: http://www.math.tamu.edu/~bangerth/
> >
> _______________________________________________
> dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii
>



-- 
Stefano

Attachment: example_cg_patch.diff
Description: Binary data

_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to