The value of "degree" in Expression

Dear all,

I do not know how to take the value of “degree” in Expression. For example:

V = VectorFunctionSpace(mesh, 'CG', 1)
test1 = Expression("a", a=10, degree = 1)
#or test1 = Expression("a", a=10, degree = 0)?
#test1.a will be changed during the computation, for example:
........
test1.a = 100
........
test1.a = 120
.......
.......

In this case, should we use degree = 1 or degree = 0 ?
Any help is appreciated.

If your expression is just a constant value that changes over time (and is constant in the whole space), i would recommend that you use Constant instead, and re-assign the value, ie something along the lines of

a = Constant(10)
a.assign(100)
#….
a.assign(200)

as using a cellwise constant to represent a domain constant is overkill

Thank you for your reply. Specifically, I use it to denote the value of the Dirichlet boundary condition, and yes, it is a constant that changes over time. I will try to use Constant now. Besides, if we choose to use Expression in this case, should we use degree = 1 or degree = 0? I know it is overkill, but I am really curious about this question. :slightly_smiling_face:

If it is a constant in space, degree 0 is more sensible.

1 Like