cpp_compile_expression can not be used twice on expression with same type-declaration

Issue #988 resolved
Jørgen Dokken created an issue

As shown in the example, if one tries to compile the same expression with identical class name twice, ditjitso throws a cryptic error, this can be fixed by renaming the class

cpp_code = base_code.replace("MyCppExpression", "MyExp2")
cpp_code = cpp_code.replace("EXPRESSION", "(x[0] - a_)")

The error message should be clearer, so that non-developers are able to fix this.

Comments (10)

  1. Jørgen Dokken reporter

    @chris_richardson I get the same message. The first compile_cpp_expression yields

    <module 'dolfin_cpp_module_f39a9ad369d77806206009e6203e7329' from '/home/dokken/V_envs/dolfin_lfs/env/.cache/dijitso/lib/dolfin_cpp_module_f39a9ad369d77806206009e6203e7329.so'>
    

    The second one returns None

  2. Chris Richardson

    The problem is that you are trying to register two types with the same name "MyCppExpression". If you rename the second expression, it should work OK. Maybe dijitso should raise, instead of printing that cryptic error.

  3. Jørgen Dokken reporter

    Got the same message when i did the following:

    cpp_code = base_code.replace("MyCppExpression", "MyExp2")
    cpp_code = base_code.replace("EXPRESSION", "(x[0] - a_)")
    d=compile_cpp_code(da_cpp_code)
    f=compile_cpp_code(cpp_code)
    
  4. Jørgen Dokken reporter

    You are correct. By renaming the expression, the code works. However, I agree that a less cryptic error should be printed.

  5. Log in to comment