Hi there,
I am switching from Fenics to FenicsX, which provides some issues regarding the boundary conditions (bcs) for MixedElement
. I am a little confused about how to apply, for example, a constraint to u_x at x=0. And how would it look like if I have a constraint for both components, i.e., u_x and u_y?
from mpi4py import MPI
from petsc4py import PETSc
import numpy as np
from basix.ufl import element, mixed_element
from dolfinx import fem, io, mesh
from dolfinx.fem.petsc import LinearProblem
from ufl import (Measure, SpatialCoordinate, TestFunctions, TrialFunctions,
div, exp, inner)
# Mesh parameters
Lx = 20.0
Ly = 2.0
Nx = 40
Ny = 4
# Define a structured quadrilateral mesh
domain = mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0, 0]), np.array([Lx, Ly])], [Nx, Ny], mesh.CellType.quadrilateral)
Q_el = element("Lagrange", domain.basix_cell(), 2)
P_el = element("Lagrange", domain.basix_cell(), 1)
V_el = mixed_element([Q_el, P_el])
V = fem.functionspace(domain, V_el)
(u, Theta) = TrialFunctions(V)
(u_, Theta_) = TestFunctions(V)
fdim = domain.topology.dim - 1
facets_left = mesh.locate_entities_boundary(domain, fdim, lambda x: np.isclose(x[0], 0))
Q, _ = V.sub(0).collapse()
dofs_left = fem.locate_dofs_topological((V.sub(0), Q), fdim, facets_left)