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.