Hi, I would like to apply a Dirichlet boundary condition on a function space of RT element. I followed the suggestions in this topic and visited the Mixed Poisson demo. Using these, I made the following code which does not work.
import numpy as np
from dolfinx import fem, mesh
from ufl import FiniteElement
from mpi4py import MPI
from petsc4py import PETSc
def boundary_top(x):
return np.isclose(x[1], 1.0)
domain = mesh.create_unit_square(
MPI.COMM_WORLD,
32, 32,
mesh.CellType.triangle
)
RT = FiniteElement("RT", domain.ufl_cell(), 1)
V = fem.FunctionSpace(domain, RT)
fdim = domain.topology.dim - 1
facets_top = mesh.locate_entities_boundary(domain, fdim, boundary_top)
dofs_top = fem.locate_dofs_topological(V, fdim, facets_top)
def f1(x):
values = np.zeros((2, x.shape[1]))
return values
f_h1 = fem.Function(V)
f_h1.interpolate(f1)
bc_top = fem.dirichletbc(f_h1, dofs_top, V)
The original code in the mixed Poisson demo does work for me, this modification does crashes with TypeError
. I’d be grateful for any explanation how this should work or what is the logic behind. I checked other forum posts but they mostly deal with the situation where the function space is a subspace of mixed element and the solution there does not work for me.