Hierarhical mesh

Hello everyone,

I have an interest in building of a time-dependent phase-field solver with the possibility of mesh adaptivity. I want to ask if there are some examples in the usage of

When constructor of HierarchicalMesh is called following Error occurs:
AttributeError: module ‘dolfin.cpp.mesh’ has no attribute ‘MeshHierarchy’

My code:
from fenics import *
import dolfin.cpp

mesh = RectangleMesh(Point(0,0),Point(L,L),N_el,N_el)
Mesh_H = dolfin.cpp.mesh.MeshHierarchy(mesh)

This work by Alexander Zimmerman might be of your interest: https://github.com/alexanderzimmerman/phaseflow-fenics

Thank you for the answer. If i have right understood, in this solver they use remeshing for mesh coarsening, which is not the best solution. In opposite MeshHierarchy class posses method coarsen().

If you look in the source code, the “coarsen()” method does exactly the same.

// Set up refinement markers to re-refine the parent mesh
MeshFunction edge_markers(parent_mesh, 1, false);
const std::map<std::size_t, std::size_t>& edge_to_vertex
= *(_relation->edge_to_global_vertex);

// Find edges which were previously refined, but now only mark them
// if not a parent of a “coarsening” vertex
for (EdgeIterator e(*parent_mesh); !e.end(); ++e)
{
auto edge_it = edge_to_vertex.find(e->index());
if (edge_it != edge_to_vertex.end())
{
// Previously refined edge: find child vertex
const std::size_t child_vertex_global_index = edge_it->second;
if (coarsening_vertices.find(child_vertex_global_index)
== coarsening_vertices.end())
{
// Not a “coarsening” vertex, so mark edge for refinement
edge_markers[*e] = true;
}
}
}