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