Sure (sorry) here I have one:
import numpy as np
from dolfinx.fem import (
Function,
FunctionSpace,
locate_dofs_geometrical,
dirichletbc,
Constant,
assemble_scalar,
set_bc,
form,
)
import ufl
#Librairy for p-FE
import basix
import basix.ufl_wrapper
from mpi4py import MPI
comm = MPI.COMM_WORLD
Lx = 2
Nb_elem= 200
from dolfinx.mesh import create_interval
mesh = create_interval(comm, Nb_elem, [0,Lx])
element = basix.create_element(basix.ElementFamily.P, basix.cell.string_to_type(mesh.ufl_cell().cellname()), 4, basix.LagrangeVariant.legendre, True)
element_u = basix.ufl_wrapper.BasixElement(element)
V_u = FunctionSpace(mesh, element_u)
u = Function(V_u, name=“Displacement”)
Uimp_ux = Function(V_u, name=“Boundary Displacement”)
zero_ux = Function(V_u, name=“Null Boundary Displacement”)
Boundary definitions dofs
dofs_u_left = locate_dofs_geometrical(V_u, lambda x: np.isclose(x[0], 0.0))
dofs_u_right = locate_dofs_geometrical(V_u, lambda x: np.isclose(x[0], Lx))
Set Bcs Function
zero_ux.interpolate(lambda x: (np.zeros_like(x[0])))
Uimp_ux.interpolate(lambda x: (np.ones_like(x[0])))
bcs_u = [
dirichletbc(zero_ux, dofs_u_left),
dirichletbc(Uimp_ux, dofs_u_right),
]
Thanks