problem with compiling cpp code of an example problem from FEniCS book
I typed the example in Chapter 33 of the FEniCS book. On page 620, it has a demonstration of applying SUPG scheme in dolfin.
I typed this Python code on this page to a file and run it from terminal, but it said the code didn't compile.
The content of the python code is copied below:
------
from dolfin import *
import numpy as np
cppcode = """
class Stab : public Expression {
public:
double sigma; boost::
boost:
Stab(): Expression(3), sigma(1.0e5){};
void eval(Array<double>& v, const Array<double>& x, const ufc:cell& c) const{
Cell cell(*mesh, c.index);
double field_norm = 0.0; double tau = 0.0
double h = cell.diameter();
field-
for (uint i=0; i<x.size(); ++i)
field_norm += v[i]*v[i];
field_norm = sqrt(field_norm);
double PE = 0.5*field_norm * h/sigma;
if (PE > DOLFIN_EPS)
tau = 1/tanh(PE) - 1/PE;
for (uint i=0; i<x.size(); ++i)
v[i] *= 0.5*h*tau/
"""
s = Expression(cppcode)
------ (end of code)
And the error message reads,
-------
...
Traceback (most recent call last):
File "compile_cpp.py", line 25, in <module>
s = Expression(cppcode)
File "/usr/lib/
cpp_base, members = compile_
File "/usr/lib/
code_snippets), classnames)
File "/usr/lib/
dolfin_
File "/usr/lib/
return local_jit(*args, **kwargs)
File "/usr/lib/
**instant_
File "/usr/lib/
recompile(
File "/usr/lib/
"compile, see '%s'" % compile_
File "/usr/lib/
raise RuntimeError(text)
RuntimeError: In instant.recompile: The module did not compile...
-------
I was trying to learn to write cpp code for complex Expression, but it really confused me that even an example from the book didn't run... Did I make any stupid mistake? Please help me. Thanks a lot!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Blechta
- Solved:
- Last query:
- Last reply: