Segmentation fault during interpolation
13 months ago by
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:
The segmentation fault always occurs during the sol.interpolate() command.
# coding: utf-8 from fenics import * from dolfin import * tol = DOLFIN_EPS epsilon0 = 8.854187e-12 # F/m epsilonr = 1.0e6 epsilon = epsilon0*epsilonr def adaptive_Poisson(mesh, previous_solution, surface_charge_value) : Element = FiniteElement('Lagrange', mesh.ufl_cell(), 1) Space = FunctionSpace(mesh, Element) bc = DirichletBC(Space, 0., left) u = TrialFunction(Space) w = TestFunction(Space) equation = -dot(grad(w), grad(u))*dx + surface_charge_value*w*ds 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 = AdaptiveNonlinearVariationalSolver(problem, goal) 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, 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 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).
Thank you for your answers,
Please login to add an answer/comment or follow this question.