Continuity into Subspace for variational form

6 months ago by
Hello everyone,

Is there a way to continue a function defined on one submesh into another submesh?
Consider for example two submeshes with   $u_1$u1   being defined in one of them and  $u_2$u2  in the other. They are coupled by  $u_1=u_2$u1=u2  on the boundary and some Neumann boundary condition. How do I include this first equality into the variational form?

Any help is very welcome

Edit: add some code as basis
edit2: added "for variational form" to post title

import fenics as fnx
import mshr as ms
#creating mesh:
index_circle = 1
index_other = 2

domain = ms.Rectangle(fnx.Point(-2.5,-2.5), fnx.Point(2.5,2.5))
domain.set_subdomain(index_circle, ms.Circle(fnx.Point(0, 0), 1))
domain.set_subdomain(index_other, ms.Rectangle(fnx.Point(-2.5,-2.5), fnx.Point(2.5,2.5))-ms.Circle(fnx.Point(0, 0), 1))

mesh = ms.generate_mesh(domain, 15)

# Convert subdomains to mesh function for plotting
mesh_regions = fnx.MeshFunction("size_t", mesh, 2,
#uncomment if you want to see the mesh regions:

submesh_c = fnx.SubMesh(mesh, mesh_regions, index_circle)
submesh_o = fnx.SubMesh(mesh, mesh_regions, index_other)

V_cd = fnx.FunctionSpace(submesh_c, "P", 1) #cd = circle domain
V_od = fnx.FunctionSpace(submesh_o, "P", 1) #od = other domain
dx = fnx.Measure("dx", mesh, subdomain_data=mesh_regions)

# consider two laplace equations to be solve on the mesh
grad = fnx.grad
dot =

#Define variational problem
v_cd = fnx.TestFunction(V_cd)
u_cd = fnx.TrialFunction(V_cd)
eq_cd = dot(grad(v_cd), grad(u_cd)) * dx(index_circle)

v_od = fnx.TestFunction(V_od)
u_od = fnx.TrialFunction(V_od)
eq_od = dot(grad(v_od), grad(u_od)) * dx(index_other)
eq_total = eq_cd + eq_od

# and now?
Community: FEniCS Project

1 Answer

6 months ago by
from fenicstools.

See this:
I think i did no explain very well my question. Did some editing now.
I want to use this for the variatonal form. This is not where to use interpolate_nonmatching_mesh​(,), is it?
written 6 months ago by Baltasar  
Ok. If you want to prescribe explicitly a Dirichlet boundary condition u1 = u2 on the interface use fenicstools the way I mentioned. Not implicitly in the weak formulation.
written 6 months ago by Minas Mattheakis  
Thank you. I'll try to implement it.
written 6 months ago by Baltasar  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »