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

Segfault when saving solution to PVD file

+1 vote

Hello,

I am building FEniCS from source and tried to run the basic demo poisson code. Here is the output:

Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving linear variational problem.
Segmentation fault

There are no other error messages. I found that the code resulting in the seg fault was when I tried saving the solution to a file (the last two lines):

from dolfin import *

mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)

def boundary(x): 
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
g = Expression("sin(5*x[0])")
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds

u = Function(V)
solve(a == L, u, bc)

file = File("poisson.pvd") 
file << u

I tried changing it to write to an XML file, but it still resulted in a seg fault.

Thank you!

asked Jul 12, 2017 by AXu2020 FEniCS Novice (130 points)
edited Jul 12, 2017 by AXu2020

1 Answer

0 votes

Try to add another parenthesis in your Expression for g and it should run without any seg fault, i.e

g = Expression("sin(5*x[0])")
answered Jul 12, 2017 by finsberg FEniCS User (2,360 points)

That was a typo, my bad! The error still persists.

The code ran in my environment. Are you sure you have enough free disk space?

Yes, the disk space should not be an issue. I have FEniCS Docker image on my local system, and everything works fine, but there seems to be issues on the cluster on which I am working. So, I'm thinking that I may have been missing something when I built FEniCS from source.

try instant-clean or dijitso clean and try again.

I have already tried to clear the instant cache, but the result is the same.

Hi,

I'm also running into similar problems as AXu2020 and have tried the solutions proposed by wilhelmbraun and finsberg with no success. Anyone else understand what's going wrong?

Thanks!

...