Hi everyone!
I attempt to give a Dirichlet boundary condition on a component of a vector field in a subspace of mixed finite elements.
I have reading (https://github.com/FEniCS/dolfinx/blob/main/python/test/unit/fem/test_bcs.py#L172-L202)
But When I use A_boundary.sub(0).collapse()
to obtain the first component of A.Will report an error.
import numpy as np
import ufl
from dolfinx import cpp as _cpp
from dolfinx import fem
from dolfinx.fem import (Constant, Function, FunctionSpace, dirichletbc,
extract_function_spaces, form,
locate_dofs_geometrical, locate_dofs_topological)
from dolfinx.io import XDMFFile
from dolfinx.mesh import (CellType, GhostMode, create_rectangle,
locate_entities_boundary,create_unit_cube)
from ufl import div, dx, grad, inner,dot,outer,ds,dS,avg,jump,rot,cross
from mpi4py import MPI
from petsc4py import PETSc
from petsc4py import PETSc as _PETSc
# Create mesh
msh = create_unit_cube(MPI.COMM_WORLD,
1,1,1,
CellType.tetrahedron, GhostMode.none)
u_element=ufl.VectorElement("DG", ufl.tetrahedron, 1) # H(div) Vh
A_element=ufl.FiniteElement("N1curl",ufl.tetrahedron,1) # H(curl) Ch
P_element=ufl.FiniteElement("DG",ufl.tetrahedron,0) # Qh
TH= ufl.MixedElement([u_element, A_element,P_element])
W =fem.FunctionSpace(msh,TH)
W0,_=W.sub(0).collapse()
W1,_=W.sub(1).collapse()
W2,_=W.sub(2).collapse()
Dh=fem.FunctionSpace(msh,A_element)
A_boundary = Function(W1)
A_boundary.sub(0).collapse()
Where A is a vector.
If I use A_element=ufl.VectorElement("N1curl",ufl.tetrahedron,1)
I will obtain a tensor function space.
How can I attach a Dirichlet boundary condition of 0 to the first component of A.
Many thanks .