adapt(form, adapted_mesh) doesn't seem to work

Issue #391 resolved
Mike Welland created an issue

I'm trying to adapt a form based on an adapted mesh. It seems to think the form F is an error control object. Works fine with the FunctionMesh, and a nonlinearVariationalProblem (not included below). Thanks

MWE:

from dolfin import *

mesh = RectangleMesh(0,0, 1,1, 10,10)
V = FunctionSpace(mesh, "Lagrange", 1)
U = Function(V)
U.interpolate(Constant(1))
F = U*dx

mesh2 = refine(mesh)
adapt(V, mesh2)
adapt(F, mesh2)

error message:

Traceback (most recent call last):
  File "demoformAdapt.py", line 11, in <module>
    adapt(F, mesh2)
  File "/home/mwelland/fenics-14_petsc4Py/lib/python2.7/site-packages/dolfin/cpp/fem.py", line 4192, in adapt
    return _fem.adapt(*args)
TypeError: in method 'adapt', argument 1 of type 'dolfin::ErrorControl const &'

Comments (5)

  1. Marie Elisabeth Rognes

    The link between Python and cpp Forms is not working optimally. This should run

    adapt(Form(F), mesh2)
    

    Also, I recommend you use

    mesh2 = adapt(mesh)
    
  2. Mike Welland reporter

    Thanks Marie. Why do you recommend adapt over refine? I favour refine so I can run it in parallel (which I am having reasonable success with). Specifically, (in pseudocode:)

    mesh2 = refine(mesh)
    adapt(NonlinearVariationalProblem, mesh2)
    LagrangeInterpolator().interpolate(U.leaf_node(),U)
    solver(problem.leaf_node())
    

    I had to manually deactivate the interpolation routine in the adapt(Function) code, but otherwise it appears to be working in parallel.

  3. Marie Elisabeth Rognes

    I recommend adapt, because it keeps track of parent-to-child cell information, thus enabling adaption of MeshFunctions. (This feature will soon be available in parallel).

  4. Log in to comment