RuntimeError: Unable to compile C++ code with dijitso (initial guess)

Hi everyone,

I’m writing a program to solve iteratively some non-linear equations. Until now, I’ve worked with a constant initial guess, but I’m having problems with convergence, so now I decided to try with an initial condition related to an approximate solution. However, when the time comes to execute the program, I get the error RuntimeError: Unable to compile C++ code with dijitso. The deffinition of the initial guess is the next one:

u = interpolate(Expression("(sqrt(pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/sqrt( 1 + (pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/ pow[12.2, 2])", degree = 2), V)

I have been looking for a solution for this problem, but have not been able to find it. I would be very grateful to get some help and suggestions on how to fix it.

Thank you so much!

Did you mean to use square brackets here?

I changed the square brakets to usual brakets:

u = interpolate(Expression("(sqrt(pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/sqrt( 1 + (pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/ pow(12.2, 2))", degree = 2), V)

The problem still persists.

You have non-matching brackets, which is indicated by the stack trace. You should include that for the next example.

I.e.

from dolfin import *
Expression("(sqrt(pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/sqrt( 1 + (pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/ pow(12.2, 2))", degree = 2)

returns

------------------ Start compiler output ------------------------
/tmp/tmputhn1tq1/dolfin_expression_c9f29955407837c29ad0faeaff629795.cpp: In member function ‘virtual void dolfin::dolfin_expression_c9f29955407837c29ad0faeaff629795::eval(Eigen::Ref<Eigen::Matrix<double, -1, 1> >, Eigen::Ref<const Eigen::Matrix<double, -1, 1> >) const’:
/tmp/tmputhn1tq1/dolfin_expression_c9f29955407837c29ad0faeaff629795.cpp:61:142: error: expected ‘)’ before ‘;’ token
   61 |           values[0] = (sqrt(pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/sqrt( 1 + (pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/ pow(12.2, 2));
      |                                                                                                                                              ^
/tmp/tmputhn1tq1/dolfin_expression_c9f29955407837c29ad0faeaff629795.cpp:61:23: note: to match this ‘(’
   61 |           values[0] = (sqrt(pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/sqrt( 1 + (pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/ pow(12.2, 2));
      |                       ^

-------------------  End compiler output  ------------------------
Compilation failed! Sources, command, and errors have been written to: /root/shared/jitfailure-dolfin_expression_c9f29955407837c29ad0faeaff629795
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/dolfin/jit/jit.py", line 165, in compile_class
    module, signature = dijitso_jit(cpp_data, module_name, params,
  File "/usr/lib/python3/dist-packages/dolfin/jit/jit.py", line 47, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/dolfin/jit/jit.py", line 103, in dijitso_jit
    return dijitso.jit(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 216, in jit
    raise DijitsoError("Dijitso JIT compilation failed, see '%s' for details"
dijitso.jit.DijitsoError: Dijitso JIT compilation failed, see '/root/shared/jitfailure-dolfin_expression_c9f29955407837c29ad0faeaff629795' for details

while

from dolfin import *
 
Expression("sqrt(pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/sqrt( 1 + (pow(x[0], 2) + pow(x[1], 2) + pow(x[2], 2))/ pow(12.2, 2))", degree = 2)

works (removing the first left bracket).