Why there is no need to use degree on C++ version of Expression?

Hello!

I am confused when I use Expression because I need to use parameter degree in python version of Expression like this

Expression(("x[0]","x[1]"),degree=2)

However, parameter degree is not used in C++ version of Expression like this

class Source : public Expression
{
public:

    Source() : Expression(2)
    {}

    void eval(Array<double>& values, const Array<double>& x) const
    {
        values[0]= x[0];
        values[1]= x[1];
    }

};

And use like this

Source source;

So, what’s the meaning of degree? We need to project Expression into finite element space before we use it?

Hey,

you will need to use the degree parmeter in both cases. In the end in your second example you will have something like this:

cpp_code = "class Source : public Expression
{
public:

    Source() : Expression(2)
    {}

    void eval(Array<double>& values, const Array<double>& x) const
    {
        values[0]= x[0];
        values[1]= x[1];
    }

};"
exp = CompiledExpression(compile_cpp_code(cpp_code).Source(), degree=2)

I interpret it the same as you, as a projection into the finite element space.

Hope this helps :slight_smile:
Emanuel

Thank you very much!

So, “exp” has its own function space.