Hello,
What would be the way to getting a value of the Expression as a float for a given values of parameters? For example,
y = Expression(‘exp( a * x )’, degree = 1, a = 1, x = 0)
y.a = 2
y.x = 3
How can I get the value of y now? Thank you!
Hello,
What would be the way to getting a value of the Expression as a float for a given values of parameters? For example,
y = Expression(‘exp( a * x )’, degree = 1, a = 1, x = 0)
y.a = 2
y.x = 3
How can I get the value of y now? Thank you!
An expression has to be interpolated into a suitable function space for you to extract values at certain points. Please note that as your expression is not spatially varying, you should consider using a Constant
instead.
His expression contains values a and x that can be changed using syntax y.x = something. How can i do the same with Constant?
This depends on if you are in DOLFINx or legacy DOLFIN.
In legacy dolfin you can do
a = Constant(5)
a.assign(1))
while in dolfinx you would do
a = dolfinx.fem.Constant(mesh, 5.)
a.value = 1
Suppose that I have an expression like his: exp(a*t), and I want to update it for different values of t, can I do it with Constant in Dolfin legacy? Because, it holds two variables essentially, a and t. You’d said that Constant is more appropriate for expressions that do not vary spatially, as is my case, since t is time.
I would simply use ufl.exp(a*t) where a and t are dolfin.Constant, rather than using expression.