Most refinement algorithms do not set parent entities data

Issue #105 resolved
Jan Blechta created an issue

Check this and this question.

BisectionRefinement (serial) is only algorithm which sets parent cells and this code passes:

mesh = UnitSquareMesh(2, 2)

cf = CellFunction('bool', mesh, True)
mesh1 = refine(mesh, cf)

f = CellFunction("size_t", mesh)
f_refined = adapt(f, mesh1)

But UniformMeshRefinement

mesh = UnitSquareMesh(2, 2)

mesh1 = refine(mesh)

f = CellFunction("size_t", mesh)
f_refined = adapt(f, mesh1)

and also ParallelRefinementND and RegularCutRefinement raises

*** Error:   Unable to adapt mesh function.
*** Reason:  Unable to extract information about parent mesh entites.
*** Where:   This error was encountered inside adapt.cpp.

because they do not set parent_cells.

Comments (20)

  1. Chris Richardson

    ParallelRefinementND cannot (easily) support parent entities if load balancing (repartitioning) is also used, as parent entities could be on different processes. It should be fine if there is no repartitioning.

  2. Chris Richardson
    • changed milestone to 1.6

    New PlazaRefinementND method sets parent_cell, but the whole parent-child relation will probably be migrated to a different object, e.g. MeshHierarchy

  3. Former user Account Deleted

    Hi, I ran into this issue in a freshly installed dolfin 1.6.0dev and found this bugreport.

    As it should be solved, I doubt I am doing something wrong, so here's a brief summary of what I am doing.

    I have two "related" problems, P1 and P2. They are related in the sense that I solve P1, then use its solution as a coefficient in P2 and solve it adaptively. Once this is done, I want to refine P1 to be run on the new mesh. To do so I set up a LinearVariationalProblem for P1 and try to call adapt(LinearVariationalProblem,Mesh) passing P1 and the mesh [if I pass mesh->leaf_node() it segfaults].

    P1 and P2 are defined on the same mesh initially.

    I set parameters["refinement_algorithm"] = "plaza_with_parent_faces"

    I am running in serial al the moment.

    Thanks for any help.

  4. Jan Blechta reporter

    @massimiliano_leoni, could you provide a minimal working example to reproduce the problem?

  5. Former user Account Deleted

    I can try, but I have to move code through a few files so it might take a while :)

  6. Former user Account Deleted

    Ok, here should be everything you need to reproduce. I am sorry it is not small, but I think it's rather minimal.

    While shrinking, I realised that if you delete the parts relative to the neumann BCs, it segfaults somewhere else. These parts are: Fracture2Dv.ufl:15 Fracture2Dv.ufl:25 Fracture2Du.ufl:15 Fracture2Du.ufl:25 fiber2D.cpp:143-155, 172,203-213,278-281

    I am not including a CMakeLists as I made a mess of mine to produce this.

  7. Jan Blechta reporter

    I get

    $ ffc -ldolfin Fracture2Dv.ufl
    *** FFC: Unable to extract all indices.
    

    with FEniCS dev. Which FEniCS version do you use?

  8. Former user Account Deleted

    There's error control in that ufl, use flag -e.

    I'll see if I can strip down further.

  9. Former user Account Deleted

    Also, I noticed there's a definition missing in the one I uploaded previously, due to crazy copy-pasting among files. Use this instead

  10. Jan Blechta reporter

    The stacktrace

    #0  0x00007ffff75aea10 in dolfin::dolfin_error(std::string, std::string, std::string, ...)@plt ()
       from /usr/users/blechta/opt/fenics-dev/r0d0_fenics-dep/master/lib/libdolfin.so.1.6
    #1  0x00007ffff76bc2db in dolfin::adapt (mesh_function=..., adapted_mesh=...)
        at /usr/users/blechta/fenics/fenics-dev-dbg/src/dolfin/dolfin/adaptivity/adapt.cpp:563
    #2  0x00007ffff76bd211 in dolfin::adapt (form=..., adapted_mesh=..., adapt_coefficients=adapt_coefficients@entry=true)
        at /usr/users/blechta/fenics/fenics-dev-dbg/src/dolfin/dolfin/adaptivity/adapt.cpp:271
    #3  0x00007ffff76bfd37 in dolfin::adapt (problem=..., adapted_mesh=...)
        at /usr/users/blechta/fenics/fenics-dev-dbg/src/dolfin/dolfin/adaptivity/adapt.cpp:308
    #4  0x00000000004386cb in main (argc=<optimized out>, argv=<optimized out>) at /usr/users/blechta/fenics/issue105/fiber2d/fiber2D.cpp:320
    
  11. Chris Richardson

    The mesh you are passing has no parent, so cannot extract parent entities. Try putting:

    std::cout << "Has parent = " << mesh->has_parent() << std::endl;
    

    before your call to adapt.

  12. Former user Account Deleted

    Hey, sorry for the late reply, I had guests this week.

    @chris_richardson as you expected, I get "Has parent = 0", so this could be the problem. How do I take care of this? I tried uncommenting *mesh = mesh->leaf_node() but nothing changed.

    I thought these issues were taken care of automatically, can you explain me what I am supposed to do in general to get adaptation to work?

    @blechta I removed all the time stuff and tuned the parameters so that it breaks at the first solve, now it's even shorter. I attach only the file I modified

  13. Former user Account Deleted

    Hi again, I didn't get if Chris' comment contains the solution to my problem. How do I assign a parent to the mesh?

  14. Former user Account Deleted

    Ok, I figured out that I had to use child_shared_ptr() instead of leaf_node. I think I found another bug now, I'll file another bug report :)

  15. Log in to comment