Error in FunctionSpace

Hi everyone!
Normally I work with FeniCS on my pc, but I have installed it at the university and I get this error with this simple code.

from fenics import *
from mshr import *
import numpy as np
from dolfin import *
import matplotlib.pyplot as plt
import math

#Unsteady Navier-Stokes
T = 140
n_sps=600
num_steps = int(T)*n_sps
dt = T / num_steps
mu=rho*U0*D/Re



# Create mesh

channel = Rectangle(Point(-40.0, -y_h), Point(50.0, y_h))


cylinder = Circle(Point(0.0, 0.0), 0.5,320)

domain = channel - cylinder
mesh = generate_mesh(domain, 30)

#Refine mesh code
cell_markers = MeshFunction("bool", mesh, mesh.topology().dim())

for c in cells(mesh):
    if c.midpoint().y() < 9 and c.midpoint().y() > -9 and c.midpoint().x() < 24 and c.midpoint().x() > -9:
                cell_markers[c] = True
    else:
                cell_markers[c] = False

mesh = refine(mesh, cell_markers)

cell_markers = MeshFunction("bool", mesh, mesh.topology().dim())

for c in cells(mesh):

    if c.midpoint().y() < 3 and c.midpoint().y() > -3 and c.midpoint().x() < 12 and c.midpoint().x() > -3:

                cell_markers[c] = True
    else:
                cell_markers[c] = False


mesh = refine(mesh, cell_markers)


# Define function spaces

#Product of Function Spaces
P2 = VectorElement("CG", mesh.ufl_cell(), 2)
P1 = FiniteElement("CG", mesh.ufl_cell(), 1)
TH = MixedElement([P2, P1])
Q = FunctionSpace(mesh, 'CG', 1)
V = VectorFunctionSpace(mesh, 'CG', 1)



The error text is:

 File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dolfin/function/functionspace.py", line 33, in __init__
    self._init_convenience(*args, **kwargs)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dolfin/function/functionspace.py", line 100, in _init_convenience
    self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dolfin/function/functionspace.py", line 42, in _init_from_ufl
    ufc_element, ufc_dofmap = ffc_jit(element, form_compiler_parameters=None,
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dolfin/jit/jit.py", line 47, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dolfin/jit/jit.py", line 97, in ffc_jit
    return ffc.jit(ufl_form, parameters=p)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/ffc/jitcompiler.py", line 217, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/ffc/jitcompiler.py", line 130, in jit_build
    module, signature = dijitso.jit(jitable=ufl_object,
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dijitso/jit.py", line 177, in jit
    build_shared_library(signature, header, source, dependencies,
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dijitso/build.py", line 148, in build_shared_library
    cmd = make_compile_command(temp_src_filename, temp_lib_filename,
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dijitso/build.py", line 60, in make_compile_command
    inc_dir = make_inc_dir(cache_params)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dijitso/cache.py", line 247, in make_inc_dir
    make_dirs(d)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/site-packages/dijitso/system.py", line 90, in make_dirs
    os.makedirs(path)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/opt/ohpc/pub/apps/miniconda/miniconda3/envs/fenicsproject_mshr_matplotlib/.cache'

and I don´t know where is the problem…
Anyone can help us?

Thank you!

Seems like you do not have permission to write (the automatically generated code) to the default cache location on your university server.
You could try setting the environment variable DIJITSO_CACHE_DIR to a location where you have write access.

2 Likes