Error with using abs() function in Expression


29
views
0
10 days ago by
Amireh  
Dear all,
when I run the code

mesh = UnitSquareMesh(4, 4)
V = FunctionSpace(mesh, "CG", 2)
f = Expression("(1-abs(x[0]))*(1-abs(x[1]))", degree = 2)
f1 = interpolate(f, V)

I get the following error:

In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '/home/amireh/.cache/instant/python2.7/error/dolfin_6d59e53a1226dc50eb179a3f1a3e1370cddc2b63/compile.log'
Traceback (most recent call last):
File "test.py", line 4, in <module>
f = Expression("(1-abs(x[0]))*(1-abs(x[1]))", degree = 2)
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/amireh/.cache/instant/python2.7/error/dolfin_6d59e53a1226dc50eb179a3f1a3e1370cddc2b63/compile.log'
Aborted (core dumped)

When I change the abs() function with power(,) , the code works. Please help me to find the problem with abs().
Community: FEniCS Project

1 Answer


1
10 days ago by
It works for me after switching to the floating-point absolute value function:

f = Expression("(1-fabs(x[0]))*(1-fabs(x[1]))", degree = 2)​


(Keep in mind that the string passed to the Expression constructor here is C++ code, not UFL.)

or std::abs if wanting to stay C++
written 9 days ago by Nate  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »