Assigning one VectorFunctionSpace to multiple submeshes

I personally create my SubMeshes like this:

def extract_SubMesh(mesh, mf_2d, indices):
    """
    extracts the submesh (meshView-object) with the indices in indices out of the mesh
    Input:
        - mesh: mesh of the system
        - mf_2d: MeshFunction with the indices of the submeshes saved
        - indices: indices of the submesh to be created

    Output:
        - MeshView object of the submesh with the indices in indices
    """
    subdomains = MeshFunction("size_t", mesh, mesh.topology().dim(), 0) # create MeshFunction in order to create the subMesh
    for k in indices:
        subdomains.array()[mf_2d.array()==k] = 1
    extracted_SubMesh_return = MeshView.create(subdomains, 1)

I don’t quite remember where, but somewhere I’ve read, that you should use MeshView.create(…) for SubMeshes. However I forgot the reason why.
The code above however works for me :slight_smile:

Hope this is what you were looking for!