Hello everyone,
I am facing some trouble passing a matrix to a Dirichlet boundary condition. Here is the description of the problem followed by an MWE:
Consider a disk of radius 1. I want to apply a matrix
gamma2 = as_matrix((10.0*(boundary_coordinates[:][0]),0.0*(boundary_coordinates[:][1]))
where the boundary coordinates are the coordinates of the boundary of the disk. Finally, I pass this matrix as a Dirichlet BC to my problem with the following code:
c_out = DirichletBC(V, gamma2, boundary_markers, 1)
bcs=[c_out]
where the boundary of the disk has been tagged 1. This produces the error:
c_out = DirichletBC(V, gamma2, boundary_markers, 1)
^
SyntaxError: invalid syntax
Here is an MWE:
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+06) 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_nodes = BoundaryMesh(mesh, "exterior", True)
boundary_coordinates = boundary_nodes.coordinates()
n = len(boundary_coordinates)
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)
n = FacetNormal(mesh)
V = VectorFunctionSpace(mesh, "Lagrange", 1)
# Define boundary condition
# Define functions
du = TrialFunction(V)
v = TestFunction(V)
u = Function(V)
gamma2 = as_matrix((10.0*(boundary_coordinates[:][0]),0.0*(boundary_coordinates[:][1]))
c_out = DirichletBC(V, gamma2, boundary_markers, 1)
bcs=[c_out]
d = mesh.geometry().dim()
print(d)
I = Identity(d) # Identity tensor
F = I + grad(u)
J_e = det(F)
C_lumen = F.T*F
Ic_lumen = tr(C_lumen)
alpha, mu_lumen = 0.00001, 0.000001
psi_lumen = (mu_lumen)*(Ic_lumen - 3) + (alpha)*(J_e-1)**2 + mu_lumen*ln(J_e)
Pi_lumen = (psi_lumen*dx(8)) #+ dot(gamma2,u)*ds(1) #- dot(P*(n), u)*ds(1)
F1 = derivative(Pi_lumen, u, v)
# Compute Jacobian of F
Ju = derivative(F1, u, du)
# Solve variational problem
solve(F1 == 0, u, bcs,
form_compiler_parameters=ffc_options)
#mesh_lumen = Mesh(mesh)
ALE.move(mesh,u)
mesh_moved = Mesh(mesh)
plot(mesh_moved)
plt.show()
Any suggestions why this is happening and what should be done?