On Wed, Dec 4, 2013 at 11:18 PM, Dafang Wang <dafang.w...@jhu.edu> wrote: > Hi, > > I finally made things work by managing to access the SNES object from > Libmesh. It works as follows: > > NonlinearImplicitSystem system; > system.solve(); > libMesh::PetscNonlinearSolver<Real> *tp = > > dynamic_cast<libMesh::PetscNonlinearSolver<Real>*>(system.nonlinear_solver.get()); > int reason = tp->get_converged_reason(); > > One caveat: get_converged_reason() is a member function of the class > PetscNonlinearSolver only but not a member function of the base class > NonLinearSolver (i.e., system.nonlinear_solver). Therefore a dynamic > cast is needed.
Yeah, this is about how I was thinking it would work. The dynamic_cast isn't too bad here in my opinion. > Perhaps there are more elegant options? You can always architect something similar to DiffSolver::solve_result(), which tries to return a solver-package agnostic code, but 1.) You'd be duplicating what's already in petsc_diff_solver.C 2.) It's somewhat arbitrary how we map PETSc's converged reasons to a generic DiffSolver::SolveResult. 3.) It's not actually that "generic" because it will be heavily based on PETSc's ConvergedReason's. It sounds like you want to do something specific based on a particular PETSc ConvergedReason, so I'd probably just stick with that approach. -- John ------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users