Error: Unable to extract mesh from form

Hello everyone,
I’m trying to solve a problem and I’m stuck on this error and your help will be very useful.
This is actually a mechanics problem where the two sub-domains are defined by different materials and each will have a displacement u1 and u2. The lower part of the large cube is fixed and the upper part moves. To ensure continuity at the contact surfaces between the two solids, I used the Nitsche formulation. To solve this problem, I created the geometry in Gmsh and imported it into fenics using dolfin convert. only, I get this error and I don’t know how to solve it. has anyone ever solved such a problem?
your help will be very useful. thank you in advance.
here is the gmsh and fenics code.

Here is the Gmsh code

// Define parameters
SetFactory("OpenCASCADE");
Coherence;
lc = 0.09; // Characteristic mesh size

// Define points
Point(1) = {-0.5, -0.5, 0, lc};
Point(2) = {0.5, -0.5, 0, lc};
Point(3) = {0.5, 0.5, 0, lc};
Point(4) = {-0.5, 0.5, 0, lc};
Point(5) = {-0.25, -0.25, 0, lc};
Point(6) = {0.25, -0.25, 0, lc};
Point(7) = {0.25, 0.25, 0, lc};
Point(8) = {-0.25, 0.25, 0, lc};

// Define lines
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line(5) = {5, 6};
Line(6) = {6, 7};
Line(7) = {7, 8};
Line(8) = {8, 5};

// Define plane surfaces
Line Loop(1) = {1, 2, 3, 4};
Plane Surface(1) = {1};

Line Loop(2) = {5, 6, 7, 8};
Plane Surface(2) = {2};

// Extrude surfaces to create 3D solids
Extrude {0, 0, 0.15} {
  Surface{1};
}

Extrude {0, 0, 0.15} {
  Surface{2};
}



// Subtract smaller cube from larger cube
t[] = Extrude {0, 0, 0.15} { Surface{2}; };

solid[] = BooleanDifference{ Volume{1}; Delete; }{ Volume{2}; Delete; }; 

//+
Physical Surface(1) = {23}; // moving boundary
//+
Physical Surface(2) = {18};// fixed boundary
//+
Physical Surface(3) = {8}; // contact surface 1
//+
Physical Surface(4) = {11}; // contact surface 2
//+
Physical Surface(5) = {10}; // contact surface 3
//+
Physical Surface(6) = {9}; // contact surface 4

//+
Physical Volume(1) = {1};
//+
Physical Volume(2) = {3};

Here is the FEniCS code

from dolfin import *

import os

os.system('dolfin-convert domain.msh domain.xml')


mesh = Mesh("domain.xml")
bdry = MeshFunction("size_t", mesh, "domain_facet_region.xml")
subdomains = MeshFunction("size_t", mesh, "domain_physical_region.xml")
mesh1 = SubMesh(mesh, subdomains, 1)
mesh2 = SubMesh(mesh, subdomains, 2)
ds = Measure("ds", subdomain_data=bdry)
dx = Measure("dx", subdomain_data=subdomains)
n = FacetNormal(mesh)
n1 = FacetNormal(mesh1)
n2 = FacetNormal(mesh2)

# Define function spaces for each solid
V1 = VectorFunctionSpace(mesh1, 'P', 1)
V2 = VectorFunctionSpace(mesh2, 'P', 1)

# Define material parameters
mu1 = Constant(1.0)  # Shear modulus for solid 1
mu2 = Constant(0.8)  # Shear modulus for solid 2
beta = Constant(10.0)  # Penalty parameter

# Define test and trial functions for each solid
u1 = TrialFunction(V1)
v1 = TestFunction(V1)
u2 = TrialFunction(V2)
v2 = TestFunction(V2)

# Define boundary conditions for solid 1
bc1_fixe = DirichletBC(V1, Constant((0.0, 0.0, 0.0)), 'near(x[1], -0.5) && on_boundary')  # Surface fixe
g = Constant((0.0, 0.0, -0.1))  # Prescribed displacement vector
bc1_prescrit = DirichletBC(V1, g, 'near(x[1], 0.5) && on_boundary')  # Surface avec déplacement prescrit

# Define strain and stress for each solid
def epsilon(u):
    return sym(grad(u))

def sigma(u, mu):
    return 2.0 * mu * epsilon(u)

# Define variational problem for solid 1
u1 = Function(V1)
du1 = TrialFunction(V1)
a1 = inner(sigma(du1, mu1), grad(v1)) * dx(1) + sum(beta * dot(jump(du1), jump(v1)) * dS(i) for i in range(3, 6))
L1 = Constant(0.0) * dot(v1, n1) * (ds(1) + ds(2))  # No Neumann boundary conditions on other surfaces

# Define variational problem for solid 2
u2 = Function(V2)
du2 = TrialFunction(V2)
a2 = inner(sigma(du2, mu2), grad(v2)) * dx(2) + sum(beta * dot(jump(du2), jump(v2)) * dS(i) for i in range(3, 6))
L2 = Constant(0.0) * dot(v2, n2) * (ds(3) + ds(4) + ds(5) + ds(6))  # No Neumann boundary conditions on other surfaces

# Define nonlinear variational problem
F1 = derivative(a1, u1, du1)
F2 = derivative(a2, u2, du2)
problem1 = NonlinearVariationalProblem(F1, u1, [bc1_fixe, bc1_prescrit], J=assemble(derivative(F1, u1)))
problem2 = NonlinearVariationalProblem(F2, u2, [], J=assemble(derivative(F2, u2)))

# Solve nonlinear variational problems using Newton's method
solver1 = NonlinearVariationalSolver(problem1)
solver2 = NonlinearVariationalSolver(problem2)
solver1.solve()
solver2.solve()

# Save solutions
u1.rename("Displacement_Solid1", "label")
u2.rename("Displacement_Solid2", "label")

vtkfile1 = File('solid1_displacement.pvd')
vtkfile1 << u1

vtkfile2 = File('solid2_displacement.pvd')
vtkfile2 << u2

here is the error

** -------------------------------------------------------------------------
*** Error:   Unable to extract mesh from form.
*** Reason:  Non-matching meshes for function spaces and/or measures.
*** Where:   This error was encountered inside Form.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset:  unknown
*** -------------------------------------------------------------------------

Thank you in advance for your helps.

Please note that dolfin-convert has been deprecated for a long time, and thus I am not able to reproduce your error messages, as dolfin-convert doesn’t like the generated msh file.

I guess your problem is that you are mixing the measure defined on the mesh dx, ds with functions defined on the SubMesh mesh1. These should not be mixed, and thus the error message