> So there are a couple options for exposing reason to the user.
>
> 1. Send the raw backend-specific enum to the user. Downside: user needs to
> write different code for each back end.
>
> 2. Always convert to some new libmesh enum. Downside: conversion from
> backend value to generic value is not injective (several values might be
> mapped to "unknown", so you have lost information that the user might want.
>
> 3. Create a new libmesh enum, but store the backend value. This can always
> be converted to a generic value when convenient.
>
> My comment regarding KSPConvergedReasons is that many PETSc users are
> familiar with the specific failure modes so it would be entirely reasonable
> to print it instead of translated strings. It is certainly much better than
> printing "Unknown/unsupported con(di)vergence".
>

Then I would suggest the following:

1. Replace the contents of PetscLinearSolver::print_converged_reason() by

KSPConvergedReason reason;
KSPGetConvergedReason(_ksp, &reason);
libMesh::out << "Linear solver convergence/divergence reason: " <<
KSPConvergedReasons[reason] << std::endl;

or similar.

2. Remove the this->clear() call from PetscNonlinearSolver::solve().
This prevents the _snes context pointer from being destroyed. In
PetscLinearSolver, the _ksp context pointer isn't destroyed either.

3. Introduce PetscNonlinearSolver::print_converged_reason()
analogously to the linear solver, using the maintained _snes pointer.

This way, maximum backwards compatibility is sustained, full access to
the convergence reason is granted via snes() at any time after the
solve(), no additional enums need to be implemented, and the linear
and nonlinear solvers are synchronized to a more common interface.

Or is there a particular reason for destroying the _snes context
immediately? Perhaps one should consider clear()ing at the beginning
of solve().

Roman

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to