Hi, thank you for the answer but I’m not sure if I understood how to use the return of compute_incident_entities
.
This would be the main non-working example:
from dolfinx.mesh import create_box
from dolfinx.mesh import locate_entities, meshtags
from mpi4py import MPI
import numpy as np
L = 1
N = 5
mesh_1 = create_box(comm=MPI.COMM_WORLD,points=[(0,0,0),(L,L,L)], n=[N,N,N])
Gamma= 1
Gamma_back = 2
Gamma_sides = 3
boundaries = [( Gammma, lambda x: np.isclose(x[0], 0)),
( Gamma_back, lambda x: np.isclose(x[0], L) ),
( Gamma_sides, lambda x: np.isclose( np.maximum(np.abs(x[1]), np.abs(x[2])), L) ) ]
facet_indices, facet_markers = [], []
fdim = mesh_1.topology.dim - 1
for (marker, locator) in boundaries:
facets = locate_entities(mesh_1, fdim, locator)
facet_indices.append(facets)
facet_markers.append(np.full_like(facets, marker))
facet_indices = np.hstack(facet_indices).astype(np.int32)
facet_markers = np.hstack(facet_markers).astype(np.int32)
sorted_facets = np.argsort(facet_indices)
facet_tags_1 = meshtags( mesh_1 , fdim, facet_indices[sorted_facets], facet_markers[sorted_facets])
mesh_2 = create_box(comm=MPI.COMM_WORLD,points=[(-Lx,0,0),(0,Ly,Lz)], n=[Nx,Ny,Nz])
boundaries = [( Gammma, lambda x: np.isclose(x[0], 0)),
( Gamma_back, lambda x: np.isclose(x[0], -L) ),
( Gamma_sides, lambda x: np.isclose( np.maximum(np.abs(x[1]), np.abs(x[2])), L) ) ]
facet_indices, facet_markers = [], []
fdim = mesh_2.topology.dim - 1
for (marker, locator) in boundaries:
facets = locate_entities(mesh_2, fdim, locator)
facet_indices.append(facets)
facet_markers.append(np.full_like(facets, marker))
facet_indices = np.hstack(facet_indices).astype(np.int32)
facet_markers = np.hstack(facet_markers).astype(np.int32)
sorted_facets = np.argsort(facet_indices)
facet_tags_2 = meshtags( mesh_2 , fdim, facet_indices[sorted_facets], facet_markers[sorted_facets])
# for creating ds1 and ds1 measures later
from dolfinx.fem import Function, FunctionSpace
H1 = FunctionSpace( mesh_1, ("Lagrange",1))
H2 = FunctionSpace( mesh_2, ("Lagrange",1))
u1 = Function(H1)
# ... solution of a variational formulation for u1
u2 = Function(H2)
u2.interpolate(u1,...) # here I would like to interpolate u1 restricted to Gamma, on u2 restricted to Gamma.
# I don't need to interpolate on the rest of the boundary.