# The application of subdomain solution to the global domain when multiple fields are coupled

A multi-field coupling problem is being calculated, as shown in the figure, with the upper part calculated for the phase field and the overall grid calculated for the magnetic field.

• My mesh function is as follows：
``````def mesh(Lx=1, Ly=5, grid_spacing=0.1/64, **namespace):
mesh_init = df.RectangleMesh(df.Point(0.,-Ly/2), df.Point(Lx, Ly),
int(Lx/grid_spacing), int(1.5*Ly/grid_spacing))
cell_makers = df.MeshFunction('bool',mesh_init,mesh_init.topology().dim())
cell_makers.set_all(False)
for cell in df.cells(mesh_init):
if cell.midpoint().y() > 0:
cell_makers[cell] =True
return df.refine(mesh_init,cell_makers)

mesh = mesh(Lx=1, Ly=5, grid_spacing=0.1/64)
``````

My submesh function is as follow:

``````def mesh_top(mesh_full, Ly, **namespace):
domains = df.MeshFunction('size_t', mesh_full,mesh_full.topology().dim())
domains.set_all(0)
top_domain =TopDomain(Ly)
top_domain.mark(domains,1)
return df.MeshView.create(domains,1)

submesh = submesh(mesh,Ly)
``````
• The solution I get from the phase field which is from sub mesh iterates to the magnetic field, and the formula is as follows:
``````def ramp_veps(domain, phi, A ):
x = ufl.SpatialCoordinate(domain)
return ufl.conditional(ufl.lt(x[1],0.0),1.23*4.0e-7*math.pi, A[0]*0.5*(1.+phi) + A[1]*0.5*(1.-phi))

veps_= ramp_veps(mesh,phi_flt_, permittivity)
``````

The program reports an error:Unable to evaluate function at point.