fenics-tutorial icon indicating copy to clipboard operation
fenics-tutorial copied to clipboard

Log function as Expression

Open jaddoghman opened this issue 4 years ago • 1 comments

The log function is no longer functional in FEniCS. For instance, f = Expression("log(x[0])", degree=2) yields the following error:

Moving new file over differing existing file: src: /Users/jaddoghman/PycharmProjects/pythonProject/jitfailure-dolfin_expression_f60265c862d87700218c841a812dafcb/error.log.6ea03de6066b4b9d83ac2b8ded7b64d0 dst: /Users/jaddoghman/PycharmProjects/pythonProject/jitfailure-dolfin_expression_f60265c862d87700218c841a812dafcb/error.log backup: /Users/jaddoghman/PycharmProjects/pythonProject/jitfailure-dolfin_expression_f60265c862d87700218c841a812dafcb/error.log.old ------------------- Start compiler output ------------------------ /var/folders/ss/zp8nt0fj6sq7cbyhdz9w52q40000gp/T/tmpi7ash_kk/dolfin_expression_f60265c862d87700218c841a812dafcb.cpp:61:23: error: no matching function for call to 'log' values[0] = log(x[0]); ^~~ /Users/jaddoghman/opt/anaconda3/envs/fenics2018/include/dolfin/log/log.h:103:8: note: candidate function not viable: requires at least 2 arguments, but 1 was provided void log(int debug_level, std::string msg, ...); ^ 1 error generated. ------------------- End compiler output ------------------------ Compilation failed! Sources, command, and errors have been written to: /Users/jaddoghman/PycharmProjects/pythonProject/jitfailure-dolfin_expression_f60265c862d87700218c841a812dafcb Traceback (most recent call last): File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dolfin/jit/jit.py", line 167, in compile_class mpi_comm=mpi_comm) File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dolfin/jit/jit.py", line 47, in mpi_jit return local_jit(*args, **kwargs) File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dolfin/jit/jit.py", line 103, in dijitso_jit return dijitso.jit(*args, **kwargs) File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dijitso/jit.py", line 217, in jit % err_info['fail_dir'], err_info) dijitso.jit.DijitsoError: Dijitso JIT compilation failed, see '/Users/jaddoghman/PycharmProjects/pythonProject/jitfailure-dolfin_expression_f60265c862d87700218c841a812dafcb' for details During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/jaddoghman/PycharmProjects/pythonProject/Scratch2.py", line 8, in f = Expression("log(x[0])", degree=2) File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dolfin/function/expression.py", line 376, in init self._cpp_object = jit.compile_expression(cpp_code, params) File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dolfin/function/jit.py", line 158, in compile_expression expression = compile_class(cpp_data, mpi_comm=mpi_comm) File "/Users/jaddoghman/opt/anaconda3/envs/fenics2018/lib/python3.7/site-packages/dolfin/jit/jit.py", line 170, in compile_class raise RuntimeError("Unable to compile C++ code with dijitso") RuntimeError: Unable to compile C++ code with dijitso

Is there any alternative? Thanks!

jaddoghman avatar Sep 03 '21 12:09 jaddoghman

For whom it may concern, the function log1p may be a good alternative for log. For instance, log1p(x) = log(x + 1), so it suffices to consider log1p(x - 1).

jaddoghman avatar Sep 03 '21 13:09 jaddoghman