Hi,
Was this feature eventually included in dolfinx? I just tried to do it in the way described in old docs and it didn’t work. Here is an MWE
import gmsh, dolfinx, ufl, mpi4py, petsc4py
import numpy as np
from dolfinx.io import gmshio
a = 1
L = 8*a
c1 = (L/2, L/2) # center of circle in first geometry
c2 = (L/2+0.1, L/2) # center of circle in second geometry
Um = 1
gmsh.initialize()
gdim = 2
model_rank = 0
occ = gmsh.model.occ
rectangle = occ.addRectangle(0,0,0, L, L)
obstacle = occ.addDisk(c1[0], c1[1], 0, a, a)
occ.synchronize()
geom, _ = occ.cut([(gdim, rectangle)], [(gdim, obstacle)])
occ.synchronize()
domains = gmsh.model.getEntities(dim=gdim)
assert(len(domains) == 1)
gmsh.model.addPhysicalGroup(domains[0][0], [domains[0][1]], 1)
gmsh.model.setPhysicalName(domains[0][0], 1, "Fluid")
gmsh.model.mesh.generate(gdim)
gmsh.model.mesh.refine()
mesh1, ct1, ft1 = gmshio.model_to_mesh(gmsh.model, mpi4py.MPI.COMM_WORLD, model_rank, gdim=gdim)
gmsh.clear()
rectangle = occ.addRectangle(0,0,0, L, L)
obstacle = occ.addDisk(c2[0], c2[1], 0, a, a)
occ.synchronize()
geom, _ = occ.cut([(gdim, rectangle)], [(gdim, obstacle)])
occ.synchronize()
domains = gmsh.model.getEntities(dim=gdim)
assert(len(domains) == 1)
gmsh.model.addPhysicalGroup(domains[0][0], [domains[0][1]], 1)
gmsh.model.setPhysicalName(domains[0][0], 1, "Fluid")
gmsh.model.mesh.generate(gdim)
gmsh.model.mesh.refine()
mesh2, ct2, ft2 = gmshio.model_to_mesh(gmsh.model, mpi4py.MPI.COMM_WORLD, model_rank, gdim=gdim)
gmsh.finalize()
velocity = lambda x: 4*Um*x[1]*(L-x[1])
V1 = dolfinx.fem.FunctionSpace(mesh1, ("CG", 2))
u1 = dolfinx.fem.Function(V1)
u1.interpolate(velocity)
# now that we have u1 defined on mesh1, let us use it to define u2 on mesh2
V2 = dolfinx.fem.FunctionSpace(mesh2, ("CG",2))
u2 = dolfinx.fem.Function(V2)
u2.interpolate(u1)
Of course the last step u2.interpolate(u1) runs into error:
RuntimeError: Interpolation on different meshes not supported (yet).