In the MWE below, I am trying to solve a Poisson equation on a unit disc with a 0 Dirichlet BC. I have defined a Lagrange FunctionSpace on the domain. The solution is a scalar function defined at every point on the domain. Next, I am forming two other scalar functions, u1
and u2
from the solution u
. Next, I want to form a matrix G that takes as input the two scalar functions u1
and u2
.
Now, when I am trying to execute the code, it’s producing the error for each iteration.
*** Warning: Found no facets matching domain for boundary condition.
*** Warning: Found no facets matching domain for boundary condition.
Python script:
C1 = Circle(Point(0, 0),1)
class b1(SubDomain):
def inside(self, x, on_boundary):
return near(x[0]**2 + x[1]**2, 1, eps=1e-3) and on_boundary
class s1(SubDomain):
def inside(self, x, on_boundary):
return x[0]**2 + x[1]**2 < 1
mesh = generate_mesh(C1, 5)
boundary_markers = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
surface_markers = MeshFunction("size_t", mesh, mesh.topology().dim(), 0)
b1().mark(boundary_markers, 1)
s1().mark(surface_markers, 8)
ds = Measure('dS', domain=mesh, subdomain_data=boundary_markers)
dx = Measure('dx', domain=mesh, subdomain_data=surface_markers)
W1 = FunctionSpace(mesh, "Lagrange", 1)
du = TrialFunction(W1)
v = TestFunction(W1)
u = Function(W1)
# Define boundary condition
G , mu_flow = 1, 0.1
u_D = Constant(0.0)
bc = DirichletBC(W1, u_D, boundary_markers, 1)
# Define variational problem
f = Constant(-G/mu_flow)
a = inner(grad(u), grad(v))*dx(domain=mesh) + f*v*dx(domain=mesh)
# Compute solution
solve(a == 0, u, bc)
u1 = Expression('(u**4)/((u**4)+(1.12*(10**-5))**4)')
u2 = Expression('(0.25)*(u**4)/((u**4)+(1.12*(10**-5))**4)')
G1 = Expression((('1.0+u1','0.0','0.0'),
('0.0','1.0+u2','0.0'),
('0.0','0.0','1.0')))
My final aim is to define the matrix G at every vertex of the mesh. What am I doing wrong here? I know there is a problem with my defining the boundaries, but can’t quite figure out the problem here. Any help or suggestion would be highly appreciated.