Segmentation fault when constructing variational form

Issue #325 invalid
Sean Lim created an issue

Hi,

I seem to be getting a segmentation fault when trying to construct a variational form. Here is the code that reproduces the error:

from dolfin import *
from numpy import *

# interval [a,b]
N = 100
a = -10.0
b = 10.0
grid = IntervalMesh(N, a, b) # 50 cells, 51 vertices

V = FunctionSpace(grid,"Lagrange", 1)

v = TestFunction(V)
u_next = Function(V)
u_curr = Function(V)
u_prev = Function(V)

c = Constant(1.0)

# initial condition
u_curr.interpolate(Expression("(x[0]>=-ep)*(x[0]<=0.0)*(1/ep * x[0] + 1.0) + (x[0]<=ep)*(x[0]>0.0)*(-1/ep * x[0] + 1.0)", ep = 1.0))
u_prev.assign(u_curr)

f = Constant(0)

# choosing a timestep
dt = 1/100.0

######################################################

# writing the neumann BCs
class AbsorbingBoundaryLeft(SubDomain):
    def inside(self,x,on_boundary):
        return x[0] <= a + DOLFIN_EPS and on_boundary  # first domain is x=a

absorbing_boundary_left = AbsorbingBoundaryLeft() # creating an instance of the Absorbing BC
exterior_facet_domains = FacetFunction("uint",grid)
exterior_facet_domains.set_all(0)
absorbing_boundary_left.mark(exterior_facet_domains,1)

dss = Measure("ds")[exterior_facet_domains]

#####################################################

F = inner(v, (u_next - 2*u_curr + u_prev)/Constant(dt*dt))*dx + inner(grad(u_next), grad(v))*dx + inner(v,(u_next-u_curr)/Constant(dt))*dss(0) + inner(v,(u_curr-u_prev)/Constant(dt))*dss(1)     # implicit time-stepping

And here is the backtrace:

Starting program: /usr/bin/python dalembert.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff654f2b1 in ?? () from /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so
(gdb) bt
#0  0x00007ffff654f2b1 in ?? () from /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so
#1  0x00007ffff5d9ceac in ?? () from /usr/lib/python2.7/dist-packages/numpy/core/_dotblas.so
#2  0x000000000052c6d5 in PyEval_EvalFrameEx ()
#3  0x000000000055c594 in PyEval_EvalCodeEx ()
#4  0x00000000005b7392 in PyEval_EvalCode ()
#5  0x0000000000469663 in ?? ()
#6  0x00000000004699e3 in PyRun_FileExFlags ()
#7  0x0000000000469f1c in PyRun_SimpleFileExFlags ()
#8  0x000000000046ab81 in Py_Main ()
#9  0x00007ffff7817ec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, argv=0x7fffffffe088, init=<optimised out>, fini=<optimised out>, 
    rtld_fini=<optimised out>, stack_end=0x7fffffffe078) at libc-start.c:287
#10 0x000000000057497e in _start ()

I am running dolfin 1.4.0 on Ubuntu 14.04. Thank you!

Comments (4)

  1. Stefan Jakobsson

    There are functions inner in both dolfin and numpy. Your code apply the numpy version to dolfin objects. Remove from numpy import *.

  2. Log in to comment