Update a CoefficientFunction defined in terms of GridFunctions

Is it possible to update the values of a CoefficientFunction defined in terms of some GridFunctions if such GridFunctions change?

There is no need for update - the evaluation of a CoefficientFunction always takes the current values of a GridFunction

Or, do you want to replace the GridFunction by another GridFunction ?

Thank you for getting back to me. Consider the following simple scenario

Vh = H1(mesh, order = order, dgjumps = True) #FE space
yh = GridFunction(Vh)
yh.Set(x+y)
g11 = yh + sin(yh) #CoefficientFunction in terms of yh

I am wondering whether updating the value of yh automatically updates the values of g11. Think, for instance, about yh being updated after each Newton iteration. To be more precised, suppose I have another GridFunction ysub and I do

yh.vec.data = y_sub.vec

Does this automatically update g11?

yes, it does.

g11 does not store its own big data, it stores only the expression tree of its definition, which contains the pointers to yh

1 Like

Thanks! Great to know!

I suppose that is still the case if immediately after defining g11 I do g11.Compile(). Is that correct?