Passing python object to cppcode of expression


196
views
0
10 months ago by
Hi:

I am thinking of passing a python class instance to c++ code of expression, something like
cppcode='''
class source: public Expression
{
public:
     pyclass cc;

    void set_object(const pyclass c)
    {
        // something like cc=c
    }
    void eval(Array<double>& values, const Array<double>& x, const ufc::cell& c) const
    {
         values[0]=cc.method();
    }
};'''

f=Expression(cppcode=cppcode, degree=2)
f.set_object(C)#C is some python class instance
​

Does anybody do this before?Any advise would be appreciated!

Community: FEniCS Project
Please login to add an answer/comment or follow this question.

Similar posts:
Search »