Hi,
I’m conducting a benchmark to compare my code with commercial FEM software, which typically only offer Serendipity elements for plane stress cases, rather than Lagrange Elements.
I followed the suggestion from @dokken on dealing with Serendipity Elements as discussed in this FEniCS Project forum thread. However, I encountered an issue when trying to create a Dirichlet boundary condition in just one direction, resulting in the following error:
RuntimeError: Constant can be used only with point-evaluation elements
I’m trying to fix a displacement of 0 in the x-direction at the bottom of the domain. Here’s a code snippet illustrating my problem:
import dolfinx
from mpi4py import MPI
import numpy as np
from petsc4py.PETSc import ScalarType
def boundary_bottom(x: List[float]) -> bool:
return np.isclose(x[1], min(x[1]))
domain = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 1, 1, dolfinx.mesh.CellType.quadrilateral)
v_func_space = dolfinx.fem.VectorFunctionSpace(domain, ("S", 2))
sub_0, _ = v_func_space.sub(0).collapse()
edges = dolfinx.mesh.locate_entities_boundary(domain, domain.topology.dim - 1, boundary_bottom)
boundary_dofs = dolfinx.fem.locate_dofs_topological((v_func_space.sub(0), sub_0), domain.topology.dim - 1, edges)
bc = dolfinx.fem.dirichletbc(ScalarType(0), boundary_dofs[0], v_func_space.sub(0))
What doesn’t make sense is that this approach works for second-order Lagrange elements, as well as for first-order Serendipity and Lagrange Elements.
Thanks in advance for any help!