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

Suppress DEBUG / INFO output

+2 votes

Hey,

I've build an iterative solver which solves Poisson's equation every iteration step using FEniCS. Some annoying thing about this is the return of many lines of DEBUG and INFO output. If one runs for example this piece of code,

from dolfin import *

domain = Rectangle(0, 0, 1, 1)
domain.set_subdomain(1, Rectangle(.2, .55, 0.8, .6))
domain.set_subdomain(2, Rectangle(.2, .45, .8, .4))

# Generate and plot mesh
mesh2d = Mesh(domain, 45)
plot(mesh2d, "2D mesh")

# Set plate regions
def upperplate(x):
    return (x[0] > 0.2 + DOLFIN_EPS and x[0] < 0.8 - DOLFIN_EPS 
            and x[1] > 0.55 + DOLFIN_EPS and x[1] < 0.6 - DOLFIN_EPS)

def lowerplate(x):
    return (x[0] > 0.2 + DOLFIN_EPS and x[0] < 0.8 - DOLFIN_EPS 
            and x[1] > 0.4 + DOLFIN_EPS and x[1] < 0.45 - DOLFIN_EPS)

# Define the variational problem
V = FunctionSpace(mesh2d,"Lagrange",1)
uu = Constant(5.0)
ul = Constant(0.0)
bcu = DirichletBC(V,uu,upperplate)
bcl = DirichletBC(V,ul,lowerplate)
bcs = [bcu,bcl]

u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0.0)
g = Constant(0.0)
a = inner(grad(u),grad(v))*dx
L = f*v*dx + g*v*ds

#Compute solution
u=Function(V)
solve(a==L, u, bcs)

plot(u, interactive=True)

which can be used to compute poisson's equation for a parallel capacitor plate system, one gets following output back:

DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
INFO:FFC:Adjusting missing element domain to Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2).
INFO:FFC:Adjusting missing element domain to Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2).
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.

Especially for an iterative solver, this results in pages of DEBUG / INFO output. Is there an elegant way to disable this output, besides of suppressing all output by something like:

clear_output(stdout=False)

?

Thanks in advance,

Adriaan

asked May 19, 2014 by Adriaan FEniCS Novice (660 points)

2 Answers

0 votes

Some of this output might be left over debugging output that should be removed but you can in general try:

set_log_level(WARNING)
# or 
# set_log_level(ERROR)
answered May 20, 2014 by Marie E. Rognes FEniCS User (5,380 points)

Thanks, but this still doesn't work... If I want for example disable the DEBUG output when making a FunctionSpace, I write:

set_log_level(WARNING)
F = FunctionSpace(UnitSquareMesh(32,32), 'Lagrange', 1)

But I still get two lines of DEBUG info. I also tried other options, like ERROR, DEBUG, or set_log_level(False), but still doesn't help.
Am I making a mistake?

+1 vote
answered Aug 26, 2015 by Xuefeng LIU FEniCS Novice (240 points)

Thx, the answer in the link finally worked out for me!

...