Dear Community,
Since yesterday I have an import error of FFCX each time I try to use form(). Here is the MWE and the bug associated. But before, for the record : I’m using apple silicon M3 and my architecture was based on conda, and I deeply need the complex value architecture of FEniCSx
MWE :
import gmsh
from mpi4py import MPI
from dolfinx.io import gmshio
from ufl import (TestFunction, TrialFunction,
Measure,
FacetNormal,
inner, grad, div,
Dn)
from basix.ufl import element
from dolfinx.fem import functionspace, form, petsc
def generate_cube_gmshio(side_length=1.0, filename="cube.msh"):
"""
Generate a cube with side length `side_length`,
export the mesh to `filename`, and
return (final_mesh, cell_tags, facet_tags).
"""
# Initialize the Gmsh API
gmsh.initialize()
# Retrieve the MPI communicator and rank
comm = MPI.COMM_WORLD
model_rank = 0
# Reference the Gmsh model
model = gmsh.model
model.add("cube")
# Create the cube with the OpenCASCADE kernel
# (x, y, z, dx, dy, dz)
box_tag = model.occ.addBox(0, 0, 0, side_length, side_length, side_length)
# Synchronize the geometry
model.occ.synchronize()
# (Optional) add a physical group for the volume (tag=1)
model.addPhysicalGroup(3, [box_tag], tag=1)
# Generate the 3D mesh with second-order elements
gmsh.option.setNumber("Mesh.ElementOrder", 2)
gmsh.option.setNumber("Mesh.HighOrderOptimize", 2)
model.mesh.generate(3)
# Save the mesh to a .msh file
gmsh.write(filename)
# Convert the Gmsh mesh into a FEniCSx mesh
final_mesh, cell_tags, facet_tags = gmshio.model_to_mesh(
model, comm, model_rank
)
# Finalize Gmsh
gmsh.finalize()
# Return the objects describing the mesh in FEniCSx
return final_mesh, cell_tags, facet_tags
# Example usage:
if __name__ == "__main__":
# Generate a cube mesh and retrieve mesh data
final_mesh, cell_tags, facet_tags = generate_cube_gmshio(1.0, "cube.msh")
# Define volume (dx) and surface (ds) measures
dx = Measure("dx", domain=final_mesh)
# Define a Lagrange element of degree 3
P1 = element("Lagrange", final_mesh.basix_cell(), 2)
P = functionspace(final_mesh, P1)
# Define trial and test functions
p, v = TrialFunction(P), TestFunction(P)
# Define the volumetric bilinear form
k = inner(p, v) * dx
# Assemble the total form
A = form(k)
The error :
Traceback (most recent call last):
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 97, in get_cached_module
with open(c_filename, "x"):
FileExistsError: [Errno 17] File exists: '/Users/pierremariotti/.cache/fenics/libffcx_forms_8ff3a977f949229519a3cca1fb86ddf3d3d6c342.c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/pierremariotti/Documents/PhD/FEniCSx/new_try2/root/ABC_FEniCSx_classical/mwe_FEniCSx.py", line 78, in <module>
A = form(k)
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 337, in form
return _create_form(form)
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 331, in _create_form
return _form(form)
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 254, in _form
ufcx_form, module, code = jit.ffcx_jit(
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/jit.py", line 62, in mpi_jit
return local_jit(*args, **kwargs)
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/jit.py", line 212, in ffcx_jit
r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 188, in compile_forms
obj, mod = get_cached_module(module_name, form_names, cache_dir, timeout)
File "/opt/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 114, in get_cached_module
compiled_module = importlib.util.module_from_spec(spec)
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1176, in create_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ImportError: dlopen(/Users/pierremariotti/.cache/fenics/libffcx_forms_8ff3a977f949229519a3cca1fb86ddf3d3d6c342.cpython-310-darwin.so, 0x0002): tried: '/Users/pierremariotti/.cache/fenics/libffcx_forms_8ff3a977f949229519a3cca1fb86ddf3d3d6c342.cpython-310-darwin.so' (duplicate LC_RPATH '/opt/anaconda3/envs/env3-10-complex/lib'), '/System/Volumes/Preboot/Cryptexes/OS/Users/pierremariotti/.cache/fenics/libffcx_forms_8ff3a977f949229519a3cca1fb86ddf3d3d6c342.cpython-310-darwin.so' (no such file), '/Users/pierremariotti/.cache/fenics/libffcx_forms_8ff3a977f949229519a3cca1fb86ddf3d3d6c342.cpython-310-darwin.so' (duplicate LC_RPATH '/opt/anaconda3/envs/env3-10-complex/lib')
And all I tried was removing the cache with
rm -rf ~/.cache/fenics
Thanks for the support,
I’m supposed to submit my article very soon and I need to recover some results..