Hi Derek,

I tried SNESetFunctionDomainError() but I could not use it correctly 
within libmesh. The function takes an SNES object as the input. I 
acquire the SNES object from the libmesh using the following code:

PetscNonlinearSolver<Real> *tp = 
dynamic_cast<PetscNonlinearSolver<Real>*>(system.nonlinear_solver.get());
SNESSetFunctionDomainError(tp->snes() );

However, I got the following error during execution:
[13]PETSC ERROR: VecAssemblyBegin_MPI() line 1012 in 
/data1/trayanova/petsc/3.4.3/src/vec/vec/impls/mpi/pdvec.c
[13]PETSC ERROR: VecAssemblyBegin() line 220 in 
/data1/trayanova/petsc/3.4.3/src/vec/vec/interface/vector.c
[13]PETSC ERROR: close() line 953 in 
"unknowndirectory/"/data1/trayanova/libmesh/0.9.2.2/install/include/libmesh/petsc_vector.h

Was I using the correct way to extract the SNES context from the libmesh 
nonlinear system?

Thanks,
Dafang

On 12/11/2,014 12:23 AM, Derek Gaston wrote:
> Yep - that's exactly what SNESetFunctionDomainError() is for... so 
> you're in luck!
>
> On Thu, Dec 11, 2014 at 12:07 AM, Dafang Wang <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Hi Derek,
>
>     Thank you for your suggestions. I am doing a "normal" Newton solve
>     with SNES. Since my residual vector is prone to explosion, I want
>     to keep monitoring it and to interrupt SNES when the residual
>     explodes.
>
>     Cheers,
>     Dafang
>
>
>     On 12/10/2014 11:43 PM, Derek Gaston wrote:
>>     If you're using PETSc and doing a "normal" Newton solve then you
>>     can try to use SNESSetFunctionDomainError() (
>>     
>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetFunctionDomainError.html
>>     ) and then return... and hopefully PETSc will clean up for you.
>>
>>     However, if you're doing JFNK and that residual evaluation is
>>     being done for a finite differenced mat-vec then there are
>>     issues.  See this thread:
>>     http://lists.mcs.anl.gov/pipermail/petsc-users/2014-August/022597.html
>>
>>     Derek
>>
>>     On Wed, Dec 10, 2014 at 9:57 PM, Kirk, Benjamin (JSC-EG311)
>>     <[email protected] <mailto:[email protected]>> wrote:
>>
>>         Not sure any of the examples show this, but you can use a
>>         usual C++ try/catch approach. Just be careful an error is
>>         thrown consistently across all processors, even if it is
>>         identified only on one (or a subset).
>>
>>
>>
>>         > On Dec 10, 2014, at 8:30 PM, Dafang Wang
>>         <[email protected] <mailto:[email protected]>> wrote:
>>         >
>>         > Hi,
>>         >
>>         > Is there a way to exit a nonlinear-system-solving process
>>         from the function
>>         > "residual_and_jacobian()" or "jacobian()" without
>>         terminating the program? For example, I
>>         > am dealing with code as follows:
>>         >
>>         > //Point A.
>>         > system.solve();
>>         >
>>         > Then something bad happens in my
>>         "system.residual_and_jacobian()" function, and I want to
>>         > return to Point A and proceed.  Does libmesh allow such an
>>         action?
>>         >
>>         > Any suggestions or comments will be appreciated.
>>         >
>>         > Thanks,
>>         > 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/
>>         <http://lagniappe.icm.jhu.edu/%7Edwang/>
>>         >
>>         >
>>         
>> ------------------------------------------------------------------------------
>>         > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT
>>         Server
>>         > from Actuate! Instantly Supercharge Your Business Reports
>>         and Dashboards
>>         > with Interactivity, Sharing, Native Excel Exports, App
>>         Integration & more
>>         > Get technology previously reserved for billion-dollar
>>         corporations, FREE
>>         >
>>         
>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>>         > _______________________________________________
>>         > Libmesh-users mailing list
>>         > [email protected]
>>         <mailto:[email protected]>
>>         > https://lists.sourceforge.net/lists/listinfo/libmesh-users
>>
>>         
>> ------------------------------------------------------------------------------
>>         Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>         from Actuate! Instantly Supercharge Your Business Reports and
>>         Dashboards
>>         with Interactivity, Sharing, Native Excel Exports, App
>>         Integration & more
>>         Get technology previously reserved for billion-dollar
>>         corporations, FREE
>>         
>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>>         _______________________________________________
>>         Libmesh-users mailing list
>>         [email protected]
>>         <mailto:[email protected]>
>>         https://lists.sourceforge.net/lists/listinfo/libmesh-users
>>
>>
>
>     -- 
>     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/
>     <http://lagniappe.icm.jhu.edu/%7Edwang/>
>
>

-- 
Dafang Wang, Ph.D
Postdoctoral Fellow
Institute of Computational Medicine
Department of Biomedical Engineering
Johns Hopkins University
Hackerman Hall Room 218
Baltimore, MD, 21218
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to