[petsc-users] petsc4py and python's logging module
Lisandro Dalcin
dalcinl at gmail.com
Mon May 29 14:55:52 CDT 2017
On 29 May 2017 at 19:17, David Nolte <dnolte at dim.uchile.cl> wrote:
> Dear all,
>
> is it possible to use python's logging module
> (https://docs.python.org/2/howto/logging.html) to handle PETSc output in
> python, such as the residuals during a KSP/SNES solve?
> I log my solver's activity to a file using the logging module, it would
> be great to include the PETSc output aswell.
>
Not sure if this is what you really want, but you could...
1) Use {ksp|snes}.setConvergenceHistory() before solve, then
{ksp|snes}.getConvergenceHistory() after solve, you will get arrays
with the residual history, then you can do whatever you want with
them.
2) Implement a KSP/SNES monitor in a Python function and call
{ksp|snes}.setMonitor(), then you can use python's logging inside your
monitor function.
--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/
4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 0109
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa
Office Phone: +966 12 808-0459
More information about the petsc-users
mailing list