This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Periodic Boundary Condition in FeniCS 2017.1.0

0 votes

Hello,

I have recently moved to FeniCS 2017.1.0. I want to solve an eigenvalue problem with periodic boundary condition in 3D. However, when I use the following code:

        a=5.e-2; #cube size
# Sub domain for Periodic boundary condition
class PeriodicBoundary(SubDomain):

    # Left boundary is "target domain" G
    def inside(self, x, on_boundary):
        # return True if on left or bottom boundary AND NOT on one of the two slave edges
        return bool(( near(x[0], -a/2.) or near(x[1], -a/2.) or near(x[2], -a/2.)) and 
            (not ((near(x[0], a/2.) and near(x[2], -a/2.)) or 
                  (near(x[0], -a/2.) and near(x[2], a/2.)) or
                  (near(x[1], a/2.) and near(x[2], -a/2.))or
                  (near(x[1], -a/2.) and near(x[2], a/2.)))) and on_boundary)

    # Map right boundary (H) to left boundary (G)
    def map(self, x, y):

        if near(x[0], a/2.) and near(x[2], a/2.):
            y[0] = x[0] - a/2
            y[1] = x[1] 
            y[2] = x[2] - a/2
        elif near(x[1], a/2.) and near(x[2], a/2.):
            y[0] = x[0] 
            y[1] = x[1] - a/2
            y[2] = x[2] - a/2
        elif near(x[0], a/2):
            y[0] = x[0] - a/2
            y[1] = x[1]
            y[2] = x[2]
        elif near(x[1], a/2):
            y[0] = x[0]
            y[1] = x[1] - a/2
            y[2] = x[2] 
        elif near(x[2], a/2):
            y[0] = x[0]
            y[1] = x[1]
            y[2] = x[2] - a/2



mesh = BoxMesh(Point(-a/2, -a/2, -a/2), Point(a/2, a/2, a/2),36,36,36)

V = VectorFunctionSpace(mesh, "CG", 1, constrained_domain=PeriodicBoundary())
Vcomplex = V*V

I got this error:

 V = VectorFunctionSpace(mesh, "CG", 1, constrained_domain=PeriodicBoundary())
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 427, in VectorFunctionSpace
    constrained_domain=constrained_domain)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 197, in __init__
    self._init_from_ufl(*args, **kwargs)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 218, in _init_from_ufl
    dolfin_element, dolfin_dofmap = _compile_dolfin_element(element, mesh, constrained_domain=constrained_domain)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 82, in _compile_dolfin_element
    ufc_element, ufc_dofmap = jit(element, mpi_comm=mesh.mpi_comm())
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 70, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 147, in jit
    "ffc.jit failed with message:\n%s" % (tb_text,))
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/cpp/common.py", line 2342, in dolfin_error
    return _common.dolfin_error(location, task, reason)
RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to perform just-in-time compilation of form.
*** Reason:  ffc.jit failed with message:
Traceback (most recent call last):
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 142, in jit
    result = ffc.jit(ufl_object, parameters=p)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/ffc/jitcompiler.py", line 204, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/ffc/jitcompiler.py", line 120, in jit_build
    generate=jit_generate)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dijitso/jit.py", line 160, in jit
    header, source, dependencies = generate(jitable, name, signature, params["generator"])
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/ffc/jitcompiler.py", line 76, in jit_generate
    dep_module_name = jit(dep, parameters, indirect=True)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/ffc/jitcompiler.py", line 204, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/ffc/jitcompiler.py", line 120, in jit_build
    generate=jit_generate)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dijitso/jit.py", line 173, in jit
    params)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dijitso/build.py", line 157, in build_shared_library
    lockfree_move_file(temp_lib_filename, lib_filename)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dijitso/system.py", line 272, in lockfree_move_file
    return _lockfree_move_file(src, dst, False)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dijitso/system.py", line 311, in _lockfree_move_file
    move_file(src, priv(ui))
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/site-packages/dijitso/system.py", line 258, in move_file
    shutil.move(srcfilename, dstfilename)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/share/apps/miniconda2/envs/fenics/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: u'/share/apps/miniconda2/envs/fenics/.cache/dijitso/lib/libdijitso-ffc_element_45b1d44b0e4691b9df75611b170d6386dcfa3bdf.so.priv.175565285178804204168798631990071275483'
.
*** Where:   This error was encountered inside jit.py.
*** Process: 0
***
*** DOLFIN version: 2017.1.0
*** Git changeset:  d90efb69cac2db97c88c66a2189d43b3f91d3c80
*** -------------------------------------------------------------------------

Aborted

Also when I change the last lines of me code as following I get a similar error:

V = VectorElement("Lagrange", mesh.ufl_cell(), 1)
W = MixedElement([V, V])
Vcomplex = FunctionSpace(mesh, W, constrained_domain=PeriodicBoundary())

Can anybody help me with this issue?

Thanks

asked May 24, 2017 by Ashkan FEniCS Novice (300 points)

1 Answer

+2 votes

It looks like you do not have write permissions to the directory where dijitso wants to store the jit cache. Try to set DIJITSO_CACHE_DIR, INSTANT_CACHE_DIR and INSTANT_ERROR_DIR to a directory where you know you have write permissions, for example:

export DIJITSO_CACHE_DIR=/tmp/cache/dijitso
export INSTANT_CACHE_DIR=/tmp/cache/instant/cache
export INSTANT_ERROR_DIR=/tmp/cache/instant/error
answered May 24, 2017 by johannr FEniCS Expert (17,350 points)

Great! I asked for the permission and it is solved now. Thanks.

...