max_dimension parameter of adaptive solver does nothing

Issue #1017 new
Alexander Gary Zimmerman created an issue

In the following, the max_iterations parameter behaves as expected; but the max_dimension parameter does nothing:

import fenics


exact_u = fenics.Expression(
        '1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)

f = fenics.Constant(-6.0)


mesh = fenics.UnitSquareMesh(2, 2)

V = fenics.FunctionSpace(mesh, fenics.FiniteElement('P', mesh.ufl_cell(), 1))


u = fenics.TrialFunction(V)

v = fenics.TestFunction(V)

dot, grad = fenics.dot, fenics.grad

dx = fenics.dx

a = dot(grad(v), grad(u))*dx

L = v*f*dx


def boundary(x, on_boundary):

    return on_boundary

bc = fenics.DirichletBC(V, exact_u, boundary)

solution = fenics.Function(V)

problem = fenics.LinearVariationalProblem(a, L, u = solution, bcs = bc)


solver = fenics.AdaptiveLinearVariationalSolver(
    problem = problem, goal = solution*dx)

solver.parameters["max_dimension"] = 10

solver.parameters["max_iterations"] = 4

goal_tolerance = 1.e-4

solver.solve(goal_tolerance)

From reading the GenericAdaptiveVariationalSolver code, I would expect the adaptive solver to return after exceeding a number of degrees of freedom equal to max_dimension, but instead it continues iterating until exceeding max_iterations.

I am using FEniCS 2017.2.0; but the drop-down menu in the form for creating this issue has latest options 2017.1 or dev. I didn't touch the Priority or Milestone options; but I would personally consider this to be a major bug. Applying AMR to new problems is impractical without a working max_dimension parameter.

Here's a plot of the solution:

fenics.plot(solution.leaf_node())

fenics.plot(mesh.leaf_node())

poisson_amr.png

As you can see, there are many more than ten degrees of freedom. Before the onset of AMR, there are already nine degrees of freedom; so only one iteration should be allowed.

Comments (3)

  1. Log in to comment