Hello all,
I am trying to solve an equation with two fields, one defined on a domain in 2D (mesh) and the second one defined on a subdomain in 2D also (submesh). The two fields are coupled in the subdomain. I am having trouble to define the variational form and to assemble the corresponding matrix for the coupling terms, when the two fields appear in the form. Essentially, I am trying to do the following:
import numpy as np
import ufl
from dolfinx import fem
import dolfinx.mesh
import dolfinx
from mpi4py import MPI
# Create a unit square mesh
domain = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
domain.topology.create_connectivity(domain.topology.dim - 1, domain.topology.dim)
submesh_entities = dolfinx.mesh.locate_entities(domain, dim=2, marker=lambda x: (x[0] < 0.5) )
submesh, sub_to_parent, vertex_map, geom_map = dolfinx.mesh.create_submesh(domain, domain.topology.dim, submesh_entities)
fn_space_field1 = fem.functionspace(domain, ("Lagrange", 1))
fn_space_field2 = fem.functionspace(submesh, ("Lagrange", 1))
fn_space = ufl.MixedFunctionSpace(fn_space_field1, fn_space_field2)
field1_trial, field2_trial = ufl.TrialFunctions(fn_space)
field1_test, field2_test = ufl.TestFunctions(fn_space)
dx_all = ufl.Measure("dx", domain=domain)
dx_sub = ufl.Measure("dx", domain=submesh)
F0 = ufl.inner(field1_trial, field2_test) * dx_sub
F0_compiled = dolfinx.fem.form(F0)
M0 = dolfinx.fem.petsc.assemble_matrix(F0_compiled, bcs=[])
M0.assemble()
This code throws an error:
RuntimeError: Incompatible mesh. entity_maps must be provided.
I have tried to provide the entity_maps, following many posts on submeshes, and went through some examples referenced there, but somehow, I am unable to make it work.
I am using fenicsx, version 0.9.
Any help would be appreciated.