# Segmentation fault during interpolation

256
views
1
13 months ago by
Hi everyone,

I am solving a problem that requires an adaptive solver and load ramping for convergence.
Since I was always confronted with segmentation faults, I made this very simple problem that recreates the issue:
# coding: utf-8

from fenics import *
from dolfin import *

tol = DOLFIN_EPS

epsilon0 = 8.854187e-12 # F/m
epsilonr = 1.0e6
epsilon = epsilon0*epsilonr

Element = FiniteElement('Lagrange', mesh.ufl_cell(), 1)
Space = FunctionSpace(mesh, Element)

bc = DirichletBC(Space, 0., left)

u = TrialFunction(Space)
w = TestFunction(Space)

sol = Function(Space)
print('before interpolation')
sol.interpolate(previous_solution) #assign the previous solution as starting value
print('after interpolation')

R = action(equation, sol)
DR = derivative(R, sol)
problem = NonlinearVariationalProblem(R, sol, bc, DR)

goal = sol*dx
solver_tol = 1.0e-8
solver.solve(solver_tol)
solver.summary()

return mesh.leaf_node(), sol.leaf_node()

class LeftBoundary(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and near(x[0], 0, tol)

left = LeftBoundary()

domain_length = 1.
mesh = IntervalMesh(500, 0, domain_length)
surface_charge_value = 1.0e-3
sol = Constant(0)

for ll in range(100) :
print('solving interation: ', ll)

mesh, sol = adaptive_Poisson(mesh, sol, surface_charge_value)

surface_charge_value = 1.1*surface_charge_value

​
The segmentation fault always occurs during the sol.interpolate() command.
The weird thing is that the program crashes in a random iteration and not necessarily in the first.

Does anyone know what I am doing wrong or how I can solve this problem?
I am running Fenics 2017.1.0 in Anaconda 4.4.0. The OS is Kubuntu 17.04 and the machine has 64 GB of RAM (thus not a problem of insufficient memory).