Hello everyone,
When I run the following code of Stokes equations on a new machine:
from fenics import *
mesh = UnitSquareMesh(10, 10)
V = VectorFunctionSpace(mesh, "P", 2)
Q = FunctionSpace(mesh, "P", 1)
VQ = MixedFunctionSpace(V, Q)
(u, p) = TrialFunctions(VQ)
(v, q) = TestFunctions(VQ)
sol = Function(VQ)
mesh0 = Mesh(mesh)
V0 = VectorFunctionSpace(mesh0, "P", 2)
u0 = Function(V0)
u0.set_allow_extrapolation(True)
dx = Measure("dx", domain=mesh)
a = inner(grad(u), grad(v))*dx - p*div(v)*dx + q*div(u)*dx + Constant(0)*p*q*dx
L = dot(Constant((0, 1)), v)*dx + dot(u0, v)*dx
bc = DirichletBC(V, Constant((0, 0)), "on_boundary")
system = assemble_mixed_system(a == L, sol, bc)
I get the following error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[7], line 21
18 L = dot(Constant((0, 1)), v)*dx + dot(u0, v)*dx
19 bc = DirichletBC(V, Constant((0, 0)), "on_boundary")
---> 21 system = assemble_mixed_system(a == L, sol, bc)
File /usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/solving.py:478, in assemble_mixed_system(*args, **kwargs)
476 # Create solver and call solve
477 solver = MixedLinearVariationalSolver(problem)
--> 478 system = solver.assemble_system()
479 return system
480 else:
RuntimeError: Cannot find common parent mesh
After testing, I believe the error comes from the term dot(u0, v)*dx
, as the functions u0
and u
, v
are considered unable to find a common parent mesh, even though their meshes are actually the same, and u0
has already been allowed to extrapolate. However, this error does not occur on my old machine.
Therefore, I suspect this might be related to the version of legacy FEniCS. The legacy FEniCS version for Ubuntu 24.04.1 LTS
on my new machine is
fenics-dijitso: 2019.2.0.dev0
fenics-dolfin: 2019.2.0.64.dev0
fenics-ffc: 2019.2.0.dev0
fenics-fiat: 2019.2.0.dev0
fenics-ufl-legacy: 2022.3.0
while the legacy FEniCS version for Ubuntu 24.04.1 LTS
on my old machine is
fenics-dijitso: 2019.2.0.dev0
fenics-dolfin: 2019.2.0.dev0
fenics-ffc: 2019.2.0.dev0
fenics-fiat: 2019.2.0.dev0
fenics-ufl-legacy: 2022.2.0
Is there any way to fix the error in the code above, or install a specific version of legacy FEniCS? I would appreciate any help.