This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

FEniCS suppresses PETSc debug output

+1 vote

hi,

i would like to use PETSc, with some matrices / vectors assembled by FEniCS. I just noticed that i am missing some PETSc debug output if i call fenics.interpolate() before the actual PETSc code.

I run the following example:

import sys, petsc4py
petsc4py.init(sys.argv)

import fenics
from petsc4py import PETSc

mesh = fenics.RectangleMesh(fenics.Point(-2, -2), fenics.Point(2, 2), 10,10)
V = fenics.FunctionSpace(mesh, "CG", 1)
u0 = fenics.Expression("exp(-a*pow(x[0], 2) - a*pow(x[1], 2))", degree=2, a=5)

#fenics.interpolate(u0, V) # this line changes the debug output

ts = PETSc.TS().create(comm=PETSc.COMM_WORLD)
ts.setType(ts.Type.ARKIMEX)
ts.setTime(0.0)
ts.setTimeStep(0.1)
ts.setMaxTime(360)
ts.setMaxSteps(2000)
ts.setMaxSNESFailures(-1)
x = PETSc.Vec().createSeq(10, comm=PETSc.COMM_WORLD)
ts.solve(x)

,which gives to following readable error-message:

Traceback (most recent call last):
  File "test.py", line 21, in <module>
    ts.solve(x)
  File "PETSc/TS.pyx", line 542, in petsc4py.PETSc.TS.solve (src/petsc4py.PETSc.c:182480)
petsc4py.PETSc.Error: error code 83
[0] TSSolve() line 3285 in /build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/interface/ts.c
[0] TSStep() line 3101 in /build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/interface/ts.c
[0] TSStep_ARKIMEX() line 810 in /build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/impls/arkimex    /arkimex.c
[0] TSComputeIFunction() line 723 in /build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/interface/ts.c
[0]   
[0] Must call TSSetRHSFunction() and / or TSSetIFunction()

if i now uncomment the interpolate statement the output changes to:

Traceback (most recent call last):
  File "test.py", line 21, in <module>
    ts.solve(x)
  File "PETSc/TS.pyx", line 542, in petsc4py.PETSc.TS.solve (src/petsc4py.PETSc.c:182480)
petsc4py.PETSc.Error: error code 83

The human readable debug message is gone.

Does anybody have an explaination for this? can anybody reproduce this behaviour? is this a bug or can i somehow set the PETSc debug loglevel?

best wishes
Florian

asked Mar 31, 2017 by florian_bruckner FEniCS Novice (380 points)

Yes, I can reproduce it with the latest development version. You might want to report an issue on Bitbucket.

1 Answer

0 votes

The PETSc error messages seem to be handled by the PetscDolfinErrorHandler() within the SubSystemsManager-class. The corresponding messages are only printed if log_level is set to TRACE or smaller.

So finally I get the following output, which contains the desired log messages (but also lots of other messages).

Elapsed wall, usr, sys time: 6.92e-07, 0, 0 (Number distributed mesh entities)
Elapsed wall, usr, sys time: 0.000116175, 0, 0 (Init dofmap from UFC dofmap)
Computing mesh entities of dimension 1
Elapsed wall, usr, sys time: 9.0111e-05, 0, 0 (Compute entities dim = 1)
Requesting connectivity 1 - 2.
Requesting connectivity 2 - 1.
Computing mesh connectivity 1 - 2 from transpose.
Elapsed wall, usr, sys time: 3.2968e-05, 0, 0 (Compute connectivity 1-2)  
Determining node ownership for parallel dof map
Finished determining dof ownership for parallel dof map 
Elapsed wall, usr, sys time: 8.41e-07, 0, 0 (SCOTCH: call SCOTCH_graphBuild)
Elapsed wall, usr, sys time: 9.357e-06, 0, 0 (SCOTCH: call SCOTCH_graphOrder)
Elapsed wall, usr, sys time: 7.3177e-05, 0, 0 (Compute SCOTCH graph re-ordering)
Elapsed wall, usr, sys time: 0.000542679, 0, 0 (Init dofmap)
DEBUG: [at /usr/lib/python2.7/dist-packages/dolfin/functions/expression.py:879 in _auto_select_element_from_shape()]
DEBUG: Automatic selection of expression element: <CG2 on a None>
Initializing PETSc (ignoring command-line arguments).
Elapsed wall, usr, sys time: 4.5001e-05, 0, 0 (Init PETSc)
Elapsed wall, usr, sys time: 7.448e-06, 0, 0 (Apply (PETScVector)) 
Elapsed wall, usr, sys time: 1.45e-06, 0, 0 (Apply (PETScVector))
Elapsed wall, usr, sys time: 0.000198863, 0, 0 (Init dof vector)
Elapsed wall, usr, sys time: 2.012e-06, 0, 0 (Apply (PETScVector)) 
Elapsed wall, usr, sys time: 1.211e-06, 0, 0 (Apply (PETScVector))
PetscDolfinErrorHandler: line '723', function 'TSComputeIFunction', file '/build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/interface/ts.c',
                       : error code '83' (  ), message follows:
------------------------------------------------------------------------------
Must call TSSetRHSFunction() and / or TSSetIFunction()
------------------------------------------------------------------------------
PetscDolfinErrorHandler: line '810', function 'TSStep_ARKIMEX', file '/build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/impls/arkimex/arkimex.c',
                       : error code '83' (  ), message follows:
------------------------------------------------------------------------------

------------------------------------------------------------------------------
PetscDolfinErrorHandler: line '3101', function 'TSStep', file '/build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/interface/ts.c', 
                       : error code '83' (  ), message follows:
------------------------------------------------------------------------------

------------------------------------------------------------------------------
PetscDolfinErrorHandler: line '3285', function 'TSSolve', file '/build/petsc-16ivCo/petsc-3.6.2.dfsg1/src/ts/interface/ts.c',
                       : error code '83' (  ), message follows:
------------------------------------------------------------------------------

------------------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 23, in <module>
    ts.solve(x)
  File "PETSc/TS.pyx", line 542, in petsc4py.PETSc.TS.solve (src/petsc4py.PETSc.c:182480)
petsc4py.PETSc.Error: error code 83

Maybe it would be nice to same a petsc_log_level or something.

best wishes
Florian

answered Apr 3, 2017 by florian_bruckner FEniCS Novice (380 points)
...