Adapt error in 2018.1.0

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