Interior Non-Zero Neumann BC

Hello,

I am having difficulties with properly implementing non-zero Neumann boundary conditions on interior boundaries. I’ve gotten them to work on external boundaries. There is no error message, I am using the interior measure of integration ‘dS’ and I’ve ensured that the proper facets are being referred to in the MeshFunction.

MWE:

D = 1e-3    # Diffusivity

Outer_radius = 30 # Outer radius
Inner_radius = 20 # Inner radius
origin = Point(0,0)

domain = Circle(origin, Outer_radius, 70) - Circle(origin, Inner_radius, 50)
mesh = generate_mesh(domain, 75)
mesh = Mesh(mesh)

class OuterRing(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary

class InnerRing(SubDomain):
    def inside(self, x, on_boundary):
        return sqrt((x[0] * x[0]) + (x[1] * x[1])) < (Inner_radius + 1e-10) and on_boundary

# Initialize sub-domain instances
OuterRing = OuterRing()
InnerRing = InnerRing()

boundaries = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0 )
boundaries.set_all(0)
OuterRing.mark(boundaries, 1)
InnerRing.mark(boundaries, 2)

File("facets.xml") << boundaries
bound = MeshFunction("size_t", mesh, "facets.xml")

# Define function space
P1 = FiniteElement('P', triangle, 1)
V = FunctionSpace(mesh, P1)

# Define trial and test functions
u = TrialFunction(V)
u_t = TrialFunction(V)
v = TestFunction(V)

# Improve efficiency of solver
D = Constant(D)

# Redefine measures of integration
dx = Measure("dx", domain=mesh, subdomain_data=bound)
dS = Measure("dS", domain=mesh, subdomain_data=bound)

bcu_outer = DirichletBC(V, Constant(1), bound, 1)
bcs = bcu_outer

# Define weak form
a = D*dot(grad(u), grad(v))*dx
L = 0.001*v('+')*dS(2)

# Compute solution
u = Function(V)
# Solve variational problem for time step
solve(a == L, u, bcs=bcs)

The boundary condition doesn’t seem to be taking any effect.

What do you imply when you want a Neumann condition on an interior boundary? Are you trying to enforce n\cdot \nabla u=g on an inner boundary?

You should consider the variational consquences of such a boundary condition. If you integrate by parts per cell, you will get a “jump” term between the integrals on each interior facet.

1 Like

Thank you for the quick reply!
Your response led me to study how to deal with discontinuous problems, which resulted in me realizing my problem has none of those complexities.

I was caught up on the need to use the dS integration measure when my ‘interior facets’ are also on the exterior of the domain (inner boundary). I don’t currently need to consider any discontinuity of that sort. This also means that I was erroneously defining the positive side of the ‘discontinuity’ in that code.

It’s working now, thanks again!