Interpolation the function after the mesh refinement within MPI computing

Hi Fenicsers,

I pose kindly my question here, which is occurring during the mesh refinement within MPI parallel computation.

I have a pointwise level set function (lsf_project()) which is defined on the previous mesh, after mesh refinement, this function can no longer be evaluated correctly.

The minimum code is showed as follows:

   else: #refinement=True
        print('********************************************Refinement******************************************************')

        It_refine=It_refine+1  #new mesh is defined here, avoid the bug of MPI during refinement process

        Nx=Nx+4
        Ny=Ny+4
        Nz=Nz+4

        meshname="mesh_{}".format(It_refine) 
        meshname=BoxMesh(comm, Point(0.0,0.0,0.0),Point(1.0,1.0,1.0),Nx,Ny,Nz)


        materials= MeshFunction('size_t', meshname, 3)  #3 represents the dim of topology which leads to tetrahedral mesh
        dx=Measure("dx")(subdomain_data=materials,domain=meshname)



        #Function space
        V=FunctionSpace(meshname,'CG',deg)


        #lsf function is defined pointwisely and based on the previous function space V
        lsf_project=Function(V)
        lsf_project.assign(project(lsf,V))  
        ......

An error occurs when computing the code "lsf_project.assign(project(lsf,V)) " with info:

*** -------------------------------------------------------------------------
*** Error:   Unable to evaluate function at point.
*** Reason:  The point is not inside the domain. Consider calling "Function::set_allow_extrapolation(true)" on this Function to allow extrapolation.
*** Where:   This error was encountered inside Function.cpp.
*** Process: 1
*** 
*** DOLFIN version: 2019.1.0
*** Git changeset:  74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------

Great thanks for your further help.

Can you reduce your problem to a minimal working example? It’s difficult to help given many aspects of your code are missing, most crucially the definition of lsf.