I have to echo some frustration that is shown in this post → FEniCS version and compatibility problems (chaos?)
What is the correct way of dealing with mixed elements?
Is is like in @dokken 's Demo for Mixed formulation for the Poisson equation?
Q_el = element("BDMCF", msh.basix_cell(), k, dtype=default_real_type)
P_el = element("DG", msh.basix_cell(), k - 1, dtype=default_real_type)
V_el = mixed_element([Q_el, P_el])
V = fem.functionspace(msh, V_el)
This method is also shown in Mixed finite element problems — FEniCS Workshop …
el_u = basix.ufl.element("Lagrange", mesh.basix_cell(), 3, shape=(mesh.geometry.dim,))
el_p = basix.ufl.element("Lagrange", mesh.basix_cell(), 2)
el_mixed = basix.ufl.mixed_element([el_u, el_p])
Or is it as @jpdean states in his GitHub - jpdean/mixed_domain_demos at 65975c7e073fff490bcd9a3809f9234c6c66b771 " Mixed-domain functionality in FEniCSx is under active development and is not ready for production use."
Or should it be done as shown here (FEniCS release notes | FEniCS Project)
V = dolfinx.fem.functionspace(domain, ("Lagrange", 2))
Q = dolfinx.fem.functionspace(submesh, ("Lagrange", 1))
# Create mixed problem residual F
W = ufl.MixedFunctionSpace(V, Q)
I am constantly running into errors when I try to use mixed elements. For example (MWE):
from dolfinx import fem, mesh
from mpi4py import MPI
from basix.ufl import element, mixed_element
nx, ny = 5, 5
domain = mesh.create_unit_square(MPI.COMM_WORLD, nx, ny, mesh.CellType.triangle)
U = element("DG", domain.basix_cell(), 2, shape=(2, )) # velocity
V = element("DG", domain.basix_cell(), 2, shape=(3, )) # deformation
X = fem.functionspace(domain, mixed_element([U,V]))
def interpolation_function(x):
return 1 + x[0]**2 + x[1]**2
source = fem.Function(X)
# LINE BLOW THROWS ERROR:
# RuntimeError: Cannot get interpolation points - no Basix element available. Maybe this is a mixed element?
source.interpolate(interpolation_function)
I am just trying to port @garth and Steven Vandekerckhove’s Automatic calibration of damping layers in finite element time domain simulations from FEniCS to FEniCSx, but it feels like trying to hit a moving target.
If the answer is that FEniCSx isn’t ready for mixed element problems, that would be very helpful to know.
Thank you for your help:
VERSION INFORMATION
either tutorial compatable docker images
- docker run --init -p 8888:8888 -v “$(pwd)”:/root/shared Package dolfinx-tutorial · GitHub
- docker run --ti -v “$(pwd)”:/root/shared --entrypoint=“/bin/bash” Package dolfinx-tutorial · GitHub