Hi
I am trying to expand on the 3D hyperelastic demo problem but considering 2 coupled unknown vector fields, displacement vector u and orientation vector wf. I am currently stuck assigning the Dirichlet boundary conditions for both:
# ----------------------------------------------------------------------------------------------------------------------
# Create a box mesh of a beam
L = 20.0
H = 1.0
msh = mesh.create_box(MPI.COMM_WORLD, [np.array([0.0, 0.0, 0.0]), np.array([L, H, H])], [10, 1, 1],
mesh.CellType.hexahedron)
P1 = ufl.VectorElement("CG", msh.ufl_cell(), 1, dim=3) # Lagrange family, 1st order
P2 = ufl.VectorElement("CG", msh.ufl_cell(), 1, dim=3) # Lagrange family, 1st order
VY = fem.FunctionSpace(msh, ufl.MixedElement([P1, P2]))
# ----------------------------------------------------------------------------------------------------------------------
# Boundary conditions
def left(x):
return np.isclose(x[0], 0)
def right(x):
return np.isclose(x[0], L)
# Dirichlet boundary application to affected dofs
u_left = np.array([0.0, 0.0, 0.0], dtype=PETSc.ScalarType)
u_right = np.array([0.0, 0.0, 1.0e-2], dtype=PETSc.ScalarType)
wf_left = np.array([0.0, 0.0, 0.0], dtype=PETSc.ScalarType)
wf_right = np.array([0.0, 0.0, 0.0], dtype=PETSc.ScalarType)
V0, submap = VY.sub(0).collapse()
left_u_dofs = fem.locate_dofs_geometrical((VY.sub(0),V0), left)
right_u_dofs = fem.locate_dofs_geometrical((VY.sub(0),V0), right)
bc1 = fem.dirichletbc(u_left, left_u_dofs[0], VY.sub(0))
bc2 = fem.dirichletbc(u_right, right_u_dofs[0], VY.sub(0))
V1, submap = VY.sub(1).collapse()
left_wf_dofs = fem.locate_dofs_geometrical((VY.sub(1),V1), left)
right_wf_dofs = fem.locate_dofs_geometrical((VY.sub(1),V1), right)
bc3 = fem.dirichletbc(wf_left, left_wf_dofs[0], VY.sub(1))
bc4 = fem.dirichletbc(wf_right, right_wf_dofs[0], VY.sub(1))
bcs = [bc1, bc2, bc3, bc4]
I am getting the following error:
Blockquote
RuntimeError: Creating a DirichletBC using a Constant is not supported when the Constant size is not equal to the block size of the constrained (sub-)space. Use a Function to create the DirichletBC.
Please advise.