Now I have a better view of what you are aiming for. Since you were converting to xml
I thought that you were using the Legacy FEniCS. Since your are working in FEniCSx, you can use the GMSHIO to import your mesh tags as follows:
from dolfinx.io import gmshio
from dolfinx import fem, default_scalar_type
import ufl
msh, cell_tags, facet_tags = gmshio.read_from_msh( MSL_XY.msh, MPI.COMM_WORLD, gdim=2)
Please read the post from @dokken on how to save .msh
files.
Then, you define your parameters as follows (I will assume same tags as you)
cells_on1 = cell_tags.find(1)
cells_on2 = cell_tags.find(2)
cells_on3 = cell_tags.find(3)
cells_on4 = cell_tags.find(4)
cells_on5 = cell_tags.find(5)
cells_on125= np.concatenate((cells_on1, cells_on2, cells_on5))
DG0 = fem.FunctionSpace(msh, ("DG", 0))
e_r = fem.Function(DG0)
e_r.x.array[cells_on3] = np.full_like(cells_on3, 1.0, dtype=default_scalar_type)
e_r.x.array[cells_on4] = np.full_like(cells_on4, 4.5, dtype=default_scalar_type)
In this way your parameters are defined per cell on the mesh. Since m_r
is defined everywhere with single value, then it is enough to take m_r=1.0
. If not, follow the above.
Since you want Et=0
and Ez=0
on tags 1,2,5, and they are trial or test functions, you can restrict the integrals by redefining the measures:
dx = ufl.Measure("dx", domain=msh, subdomain_data=cell_tags)
a_tt = ((1/mr)*ufl.inner(ufl.curl(Et), ufl.curl(Et_tf)) - (k0**2) * e_r * ufl.inner(Et, Et_tf)) * ufl.dx((3,4))
b_tt = (1/mr)*ufl.inner(Et, Et_tf) * ufl.dx((3,4))
b_tz = (1/mr)*ufl.inner(Et, ufl.grad(Ez_tf)) * ufl.dx((3,4))
b_zt = ufl.inner(ufl.grad(Ez), Et_tf) * ufl.dx((3,4))
b_zz = ((1/mr)*ufl.inner(ufl.grad(Ez), ufl.grad(Ez_tf)) - (k0**2) * e_r * ufl.inner(Ez, Ez_tf)) * ufl.dx((3,4))
A fantastic tutorial of what I did can be found in https://jsdokken.com/dolfinx-tutorial/chapter3/subdomains.html
I hope this is what you’re looking for.
Cheers.