Adapt error in 2018.1.0

Hi everyone.

By executing the following code:

mesh= RectangleMesh(Point(-0.5lx,0),Point(0.5lx,ly),nr,nt)#,“crossed”)
r_markers = MeshFunction(“bool”, mesh, mesh.topology().dim(),False)
filmx = CompiledSubDomain('x[1] > ‘+str(Hx-Hn) + ’ - tol’, tol=tol)
filmx.mark(r_markers, True)
adapt(mesh, r_markers)

I am getting this error related to adapt (Which does not occur using the previous release 2017.2.0):

TypeError: adapt(): incompatible function arguments. The following argument types are supported: 1. (arg0: dolfin.cpp.mesh.Mesh) -> dolfin.cpp.mesh.Mesh 2. (arg0: dolfin.cpp.mesh.MeshFunctionSizet, arg1: dolfin.cpp.mesh.Mesh) -> dolfin.cpp.mesh.MeshFunctionSizet Invoked with: <dolfin.cpp.generation.RectangleMesh object at 0x7fb0e549a200>, <dolfin.cpp.mesh.MeshFunctionBool object at 0x7fb0e545a030>

Has anyone enountered this issue when using 2018.1.0?

Is there a workaround?

Thanks is avance.

Carlos.

Are you maybe looking for the refine() function? Take a look at the following script:

from dolfin import *

# Define mesh and subdomain:
mesh = UnitSquareMesh(10,10)
d = mesh.topology().dim()
filmx = CompiledSubDomain("x[1] > 1.0-x[0]-DOLFIN_EPS")

# Refinement using the `refine()` function and a Boolean `MeshFunction`:
r_markers = MeshFunction("bool", mesh, d, False)
filmx.mark(r_markers, True)
refinedMesh = refine(mesh,r_markers)

# Transfering a non-negative integer-valued (`size_t`) `MeshFunction` to the
# refined mesh using the `adapt()` function:
meshFunctionToAdapt = MeshFunction("size_t", mesh, d, 0)
filmx.mark(meshFunctionToAdapt,1)
adaptedMeshFunction = adapt(meshFunctionToAdapt,refinedMesh)

# Plot results:
from matplotlib import pyplot as plt
plot(adaptedMeshFunction)
plot(adaptedMeshFunction.mesh()) # (Adapted function is on refined mesh)
plt.show()
1 Like

Ok, this works and it is very clear! Thanks a lot!