Expression error


283
views
1
5 months ago by
Hi!

I have a new computer on which I installed FEniCS as showed: https://fenicsproject.org/download/

Tried a code which was working on another computer and I am having error with the use of Expressions. When I try:

Theta = Expression('1.0-x[0]*x[1]')

I get the following error:

okubo@okubo-pc:~/Desktop/Other_tests$ python Test.py
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/home/okubo/.cache/instant/python2.7/error/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/compile.log'
Traceback (most recent call last):
  File "Test.py", line 32, in <module>
    Theta = Expression('1.0-x[0]*x[1]')
  File "/usr/lib/python2.7/dist-packages/dolfin/functions/expression.py", line 679, in __new__
    mpi_comm=kwargs.get("mpi_comm"))
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/expressions.py", line 266, in compile_expressions
    mpi_comm=mpi_comm)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/expressions.py", line 183, in compile_expression_code
    mpi_comm=mpi_comm)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 70, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/compilemodule.py", line 603, in compile_extension_module
    **instant_kwargs)
  File "/usr/lib/python2.7/dist-packages/instant/build.py", line 577, in build_module
    build_system)
  File "/usr/lib/python2.7/dist-packages/instant/build.py", line 170, in recompile
    instant_error(msg % (cmd, compile_log_filename_dest))
  File "/usr/lib/python2.7/dist-packages/instant/output.py", line 96, in instant_error
    raise RuntimeError(text)
RuntimeError: In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/home/okubo/.cache/instant/python2.7/error/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/compile.log'
Aborted (core dumped)​

Log file says:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for one of the modules 'craypetsc_real;PETSc'
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of PetscInt
-- Check size of PetscInt - done
-- Checking for one of the modules 'crayslepc_real;SLEPc'
-- Found SWIG: /usr/bin/swig3.0 (found version "3.0.8") 
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    DEBUG


-- Build files have been written to: /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5
/usr/bin/cmake -H/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5 -B/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5 --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/CMakeFiles /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5'
make -f CMakeFiles/_dolfin_34240dec6387b042503a41368ef2ebd044504ee5.dir/build.make CMakeFiles/_dolfin_34240dec6387b042503a41368ef2ebd044504ee5.dir/depend
make[2]: Entering directory '/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5'
[ 33%] Swig source
/usr/bin/cmake -E make_directory /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5
/usr/bin/swig3.0 -python -module dolfin_34240dec6387b042503a41368ef2ebd044504ee5 -shadow -modern -modernargs -fastdispatch -fvirtual -nosafecstrings -noproxydel -fastproxy -fastinit -fastunpack -fastquery -nobuildnone -DDOLFIN_VERSION="2018.1.0.dev0" -c++ -fcompact -O -I. -small -outdir /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5 -c++ -I/usr/local/include -I/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/. -I/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5 -o /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5PYTHON_wrap.cxx /tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i
/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i:101: Error: Unable to find 'dolfin/swig/typemaps/includes.i'
/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i:102: Error: Unable to find 'dolfin/swig/forwarddeclarations.i'
/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i:106: Error: Unable to find 'dolfin/swig/exceptions.i'
/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i:134: Error: Unable to find 'ufc.h'
/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i:147: Error: Unable to find 'dolfin/swig/common/pre.i'
/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5/dolfin_34240dec6387b042503a41368ef2ebd044504ee5.i:154: Error: Unable to find 'dolfin/swig/function/pre.i'
CMakeFiles/_dolfin_34240dec6387b042503a41368ef2ebd044504ee5.dir/build.make:61: recipe for target 'dolfin_34240dec6387b042503a41368ef2ebd044504ee5PYTHON_wrap.cxx' failed
make[2]: *** [dolfin_34240dec6387b042503a41368ef2ebd044504ee5PYTHON_wrap.cxx] Error 1
make[2]: Leaving directory '/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/_dolfin_34240dec6387b042503a41368ef2ebd044504ee5.dir/all' failed
make[1]: *** [CMakeFiles/_dolfin_34240dec6387b042503a41368ef2ebd044504ee5.dir/all] Error 2
make[1]: Leaving directory '/tmp/tmpiL_Yhz2018-3-18-16-17_instant_884c982324107edc0099c7b4a1a06c2a5a2d995d/dolfin_34240dec6387b042503a41368ef2ebd044504ee5'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2​

Can anyone help?

Thanks!
Community: FEniCS Project
In more recent versions, you need to specify the degree of the element on which an Expression is interpolated, e.g.,

from dolfin import *
mesh = UnitSquareMesh(10,10)

# Causes error:
#
# TypeError: Expression needs an integer argument 'degree' if no 'element' is provided.
#
#Theta = Expression('1.0-x[0]*x[1]')

# Okay:
Theta = Expression('1.0-x[0]*x[1]', degree=2)
​

However, you're getting a different error message, so I suspect this is not the full solution to the problem.
written 5 months ago by David Kamensky  
Hi David!

Thanks! Already tried it, but didn't work. Forgot to put the code with the degree.

In other computers, I got an error pointing to the lack of the degree, so, as you said, it doesn't solve all in this case.
written 5 months ago by Carlos Okubo  

2 Answers


0
5 months ago by
Hi Carlos,

Try with the following expression and let us know
Theta = Expression('1.0-x[0]*x[1]',degree=2)
Hi Ruben!

Thanks! Already tried it. Didn't work.
written 5 months ago by Carlos Okubo  
Carlos, please send some more code so we can try to run it and dig a little bit deeper.
written 5 months ago by Ruben Gonzalez  
0
5 months ago by

Try writing it as a class - I think there was a bug at some point in the past - I had similar issue with expressions but writing it as a class worked fine.
Something like below:

class someExpression(Expression):
    def __init__(self, var=1, **kwargs):
        self.var= var

    def eval(self, values, x):
        values[0] = self.var-x[0]*x[1]

    def value_shape(self):
        return (2,)
Hi Soroushr!

Thanks! But, by doing it this way, I am not being able to interpolate the class into a FunctionSpace....or am I doing something wrong?

class Theta(Expression):
    def __init__(self, var=1, **kwargs):
        self.var= var

    def eval(self, values, x):
        values[0] = self.var-x[0]*x[1]

    def value_shape(self):
        return (2,)

A = FunctionSpace(mesh, "CG", 1)
A_int = interpolate(Theta,A)
​
written 5 months ago by Carlos Okubo  
Hi Carlos, try writing it as
A_int = interpolate(Theta(var=1),A)​
written 5 months ago by Soroushr  
Hi Soroushr!

Worked like this:

class Theta(Expression):    
    def eval(self, values, x):
        values[0] = 1.0-x[0]*x[1]

Thet = Theta(degree=2)
A_int = interpolate(Thet,A)​


Thanks for your help...really appreciate it!

written 5 months ago by Carlos Okubo  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »