Hello dokken,
may I asked you something again?
# Randbedingungen-----------------------------------------------------------
class Left(SubDomain):
def inside(self, x, on_boundary):
return (between(x[1], (-1.0, 1.0)) and between(x[0], (4.0, -4.0)))
class Right(SubDomain):
def inside(self, x, on_boundary):
#return near(x[1], 1.0)
return ((between(x[1], (2.0, 2.0)) and between(x[0], (1.0, 3.0))) and (between(x[2], (0.1, 0.0)) and between(x[1], (2.0, 2.0))) and (between(x[3], (2.0, 0.0)) and between(x[2], (0.1, 0.0))) and (between(x[4], (5.0, -3.0)) and between(x[3], (2.0, 0.0))))
class Bottom(SubDomain):
def inside(self, x, on_boundary):
return (between(x[1], (5.0, -3.0)) and between(x[0], (4.0, -4.0)))
class Top(SubDomain):
def inside(self, x, on_boundary):
return (between(x[1], (1.0, 3.0)) and between(x[0], (-1.0, 1.0)))
# Initialize sub-domain instances
left = Left()
top = Top()
right = Right()
bottom = Bottom()
# Initialize mesh function for boundary domains
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
left.mark(boundaries, 1)
top.mark(boundaries, 2)
right.mark(boundaries, 3)
bottom.mark(boundaries, 4)
# Define Dirichlet boundary conditions at top and bottom boundaries
bc2 = DirichletBC(V, 0.0, boundaries, 2)
bc4 = DirichletBC(V, 0.0, boundaries, 4)
# TEST BC-----------------------------------------------------------------
# Pin down one corner to get rid of constant mode:
#bc = DirichletBC(V,Constant(0.0),
# "near(x[0],0) && near(x[1],0)","pointwise")
# Take a look at the solution:
#solve(lhs(res)==rhs(res),uh, bc)
#-------------------------------------------------------------------------
solve(lhs(res)==rhs(res),uh, [bc2, bc4])
from matplotlib import pyplot as plt
plot(uh)
plt.show()
plt.savefig("solution.png")
I believe the right BC is wrong. This is the warning
IndexError: index 2 is out of bounds for axis 0 with size 2
Is it because of the first line from x_0 to x_1?
Do you please know a similar example. I really don’t get it.
Greetings