Hello! When attempting to assemble a vector-valued dirichlet condition, I get the following error:
AttributeError: Boundary condition value must have a dtype attribute.
My version of dolfinx is 0.7.0, and python is 3.11.
My MRE is as follows:
import numpy as np
from mpi4py import MPI
from petsc4py import PETSc
from dolfinx.fem import Function, FunctionSpace, dirichletbc, locate_dofs_geometrical
from dolfinx.mesh import create_unit_square
from ufl import VectorElement
"""
Mesh and Function Spaces
"""
mesh = create_unit_square(MPI.COMM_WORLD, 15, 15)
v_cg2 = VectorElement("Lagrange", mesh.ufl_cell(), 2)
V = FunctionSpace(mesh, v_cg2)
"""
Boundary Conditions
"""
class zero_vector():
def __init__(self, t):
self.t = t
def __call__(self, x):
values = np.zeros((2, x.shape[1]), dtype=PETSc.ScalarType)
return values
def top(x):
return np.isclose(x[1],1)
u_bdy = Function(V)
u_bdy_value = zero_vector(0)
u_bdy.interpolate(u_bdy_value)
top_bdy_dofs = locate_dofs_geometrical(V, top)
u_top = dirichletbc(V, u_bdy, top_bdy_dofs )
I think I’m missing something rather simple, here.