What does the error " Unable to compile C++ code with dijitso" mean?

Hi!

While executing a code, I came across an error message
RuntimeError: Unable to compile C++ code with dijitso

I went through some of the responses to same/similar error messages from the community responses but unfortunately none of them worked.

Here is an MWE

from __future__ import print_function
from fenics import *
import matplotlib.pyplot as plt


from dolfin import *
import meshio
from dolfin import Mesh, XDMFFile, File, MeshValueCollection, cpp



# Optimization options for the form compiler
parameters["form_compiler"]["cpp_optimize"] = True
ffc_options = {"optimize": True, \
               "eliminate_zeros": True, \
               "precompute_basis_const": True, \
               "precompute_ip_const": True}



from mshr import Circle, generate_mesh
from dolfin import Mesh, File, MeshFunction, Point, BoundaryMesh, SubDomain, plot, File
import matplotlib.pyplot as plt
from dolfin import *
from mshr import *


class boundary(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary


class disk(SubDomain):
    def inside(self, x, on_boundary):
        return x[0] < 0 and x[0] > 0


mesh = generate_mesh(Circle(Point(0, 0), 3), 50)
boundary_markers = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
surface_markers = MeshFunction("size_t", mesh, mesh.topology().dim(), 0)
boundary().mark(boundary_markers, 2)
disk().mark(surface_markers, 1)


ds = Measure('ds', subdomain_data=boundary_markers)
dx = Measure('dx', subdomain_data=surface_markers)
n = FacetNormal(mesh)

W1 = FunctionSpace(mesh, "Lagrange", 1)
n = FacetNormal(mesh)
G , mu = 1, 0.1
u_D=Constant(0.0)

bc = DirichletBC(W1, u_D, boundary_markers, 2)

# Define variational problem
u = TrialFunction(W1)
v = TestFunction(W1)
f = Constant(-G/mu) # f=-G/mu
a = dot(grad(u), grad(v))*dx
L = -f*v*dx

# Compute solution
u = Function(W1)
solve(a == L, u, bc)

file = File("fsp1.pvd");
file << u;

gamma1 = Expression(("(-1/D)*(f0 + f1*(1-exp(-beta*(t**2))))"), degree = 1, D = 0.7, t = u, f0 = 5, f1 = 2, beta = 0.3)

This produces a gigantic error message, a part of which reads

Traceback (most recent call last):
  File "fspex.py", line 70, in <module>
    gamma1 = Expression(("(-1/D)*(f0 + f1*(1-exp(-beta*(t**2))))"), degree = 1, D = 0.7, t = u, f0 = 5, f1 = 2, beta = 0.3)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/expression.py", line 400, in __init__
    self._cpp_object = jit.compile_expression(cpp_code, params)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/jit.py", line 158, in compile_expression
    expression = compile_class(cpp_data, mpi_comm=mpi_comm)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py", line 173, in compile_class
    raise RuntimeError("Unable to compile C++ code with dijitso")
RuntimeError: Unable to compile C++ code with dijitso

It means that the string here, cannot be interpreted as a C++ string. You need to use the pow( , ) operator to do powers in C++.

1 Like

Hi dokken! Thanks for the response.

Your suggestion works perfectly fine for the MWE I created. But with the actual code I am dealing with, the problem still persists after your suggested modification. I am a bit hesitant to post the actual problem since it imports geometries from GMSH which is a quite complicated geometry and cannot be reproduced within FEniCS and also in a previous post, you advised me to create some built-in geometries so that the code can be easily reproduced and I absolutely agree with that. So right now, I have no clue why your suggestion works for the MWE and not in my actual code. If you want I can post the gmsh and the python script.

As this relates to an Expression, there should be no reason for it being dependent on the mesh. Please try to simplify the problem by using a built-in mesh, and see if the error persists.

1 Like

Ok, I will create an MWE and if there is a problem, I will get back to you.

1 Like

Hi dokken,

Here is an MWE with a built-in mesh:

from __future__ import print_function
from fenics import *
import matplotlib.pyplot as plt

from dolfin import *
import meshio
from dolfin import Mesh, XDMFFile, File, MeshValueCollection, cpp

# Optimization options for the form compiler
parameters["form_compiler"]["cpp_optimize"] = True
ffc_options = {"optimize": True, \
               "eliminate_zeros": True, \
               "precompute_basis_const": True, \
               "precompute_ip_const": True}

import numpy as np
import meshio
from mshr import Circle, generate_mesh
from dolfin import Mesh, File, MeshFunction, Point, BoundaryMesh, SubDomain, plot, File
import matplotlib.pyplot as plt
from dolfin import *
from mshr import *

class boundary(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary

class disk(SubDomain):
    def inside(self, x, on_boundary):
        return True


mesh = generate_mesh(Circle(Point(0, 0), 3), 50)
boundary_markers = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
surface_markers = MeshFunction("size_t", mesh, mesh.topology().dim(), 0)
boundary().mark(boundary_markers, 2)
disk().mark(surface_markers, 1)

ds = Measure('ds', subdomain_data=boundary_markers)
dx = Measure('dx', subdomain_data=surface_markers)
n = FacetNormal(mesh)

W1 = FunctionSpace(mesh, "Lagrange", 1)
n = FacetNormal(mesh)
G , mu = 1, 0.1
u_D=Constant(0.0)

bc = DirichletBC(W1, u_D, boundary_markers, 2)

# Define variational problem
u = TrialFunction(W1)
v = TestFunction(W1)
f = Constant(-G/mu) # f=-G/mu
a = dot(grad(u), grad(v))*dx
L = -f*v*dx

# Compute solution
u = Function(W1)
solve(a == L, u, bc)

# Calculating shear stress S
Ux=0.0
Uy=0.0
Uz=u
U = as_vector((Uy, u))
N = as_matrix([[0.0,0.5],
                 [0.0,0.0]])
Sn = mu/2 * dot(grad(U) + grad(U).T, (N.T)*n)
print(assemble(Sn[1]*ds))
gamma1 = Expression(("(-1/D)*(f0 + f1*(1-exp(-beta*(pow(t,2))))"), degree = 1, D = 0.7, t = Sn[1] , f0 = 5, f1 = 2, beta = 0.3) 

And the error reads (I am copying the whole error message):

Traceback (most recent call last):
  File "cae.py", line 70, in <module>
    gamma1 = Expression(("(-1/D)*(f0 + f1*(1-exp(-beta*(pow(t,2))))"), degree = 1, D = 0.7, t = Sn[1] , f0 = 5, f1 = 2, beta = 0.3)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/expression.py", line 400, in __init__
    self._cpp_object = jit.compile_expression(cpp_code, params)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/jit.py", line 158, in compile_expression
    expression = compile_class(cpp_data, mpi_comm=mpi_comm)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py", line 173, in compile_class
    raise RuntimeError("Unable to compile C++ code with dijitso")
RuntimeError: Unable to compile C++ code with dijitso

Any suggestion would be greatly appreciated.

The parentheses in gamma1 are not balanced. Also, you’re trying to include a ufl form for t=Sn[1] in your Expression where a primitive number, Expression, or Function is expected.

1 Like

Thanks Nate! Projection of Sn[1] onto a function space fixed the problem.

1 Like