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.
Perhaps there are more elegant options?
Thanks to all of you for your prompt suggestions.
Cheers,
Dafang
On 12/04/2013 09:50 PM, Kirk, Benjamin (JSC-EG311) wrote:
> I believe we can access a pointer to the snes object already??
>
>> On Dec 4, 2013, at 7:32 PM, "Cody Permann" <[email protected]> wrote:
>>
>> There is an API in PETSc for getting that value programmatically.
>> Maybe it should be wrapped and made available in libMesh? We actually
>> could use that value in MOOSE too. Ideally that value would be
>> somewhat solver agnostic but that probably won't work in practice.
>>
>> Cody
>>
>> Sent from my iPhone
>>
>>> On Dec 4, 2013, at 7:02 PM, "Kirk, Benjamin (JSC-EG311)"
>>> <[email protected]> wrote:
>>>
>>> -snes_info or -snes_monitor, on the command line IIRC, will cause snes to
>>> be verbose.
>>>
>>> -help will print additional options.
>>>
>>>> On Dec 4, 2013, at 5:54 PM, "Dafang Wang" <[email protected]> wrote:
>>>>
>>>> Dear all,
>>>>
>>>> I am solving a nonlinear system by using functional calls like
>>>> "systemA.solve();". In my
>>>> program I need to judge whether the solve succeeds or fails to converge
>>>> (Getting the
>>>> diverge reason would be even better). Is there any Libmesh function doing
>>>> such a job?
>>>>
>>>> I understand that Libmesh's nonlinear solve invokes Petsc SNES which
>>>> returns a bunch of
>>>> converge reasons. However, I need to hard code the convergence check in my
>>>> program, so I
>>>> am wondering if I can do this at the libmesh level.
>>>>
>>>> Any suggestions would be greatly appreciated.
>>>>
>>>> Cheers,
>>>> Dafang
>>>> --
>>>> Dafang Wang, Ph.D.
>>>> Postdoctoral Fellow
>>>> Institute of Computational Medicine
>>>> Hackerman Hall, Room 218
>>>> Johns Hopkins University, Baltimore, 21218
>>>> http://lagniappe.icm.jhu.edu/~dwang/
>>>>
>>>> ------------------------------------------------------------------------------
>>>> 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
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/libmesh-users
>>> ------------------------------------------------------------------------------
>>> 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
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/libmesh-users
--
Dafang Wang, Ph.D
Postdoctoral Fellow
Institute of Computational Medicine
Department of Biomedical Engineering
Johns Hopkins University
Hackerman Hall Room 218
Baltimore, MD, 21218
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users