Is the derivative of a bound local-function automatically bound?
Summary
In the paper "The interface for functions in the dune-functions module", Christian Engwer, Carsten Gräser, Steffen Müthing, Oliver Sander, https://arxiv.org/abs/1512.06136, the concept of differentiable functions is described. Also gridview functions and local-functions are explained. On page 10 it is stated that the derivative of a global or local function should be actually the same, in the sense that dfe1
and dfe2
in
auto df = derivative(f);
auto dfe1 = localFunction(df);
dfe1.bind(element);
auto fe = localFunction(f);
fe.bind(element);
auto dfe2 = derivative(fe);
both behave the same. The obvious difference in the code for me is: dfe1
is bound to the element
, while dfe2
is not (explicitly).
What is the correct behaviour? If a local-function, like fe
, is already bound to an element
, should the derivative of this local-function (that is constructed after the bind
call) be bound already to the same element, i.e., the boundedness survives the differentiation, or should we bind it again.
My first thought is:
- It would be nice if it is already bound, because then a bound differentiable local-function can be used like a differentiable function.
- On the other hand, it is a bit harder to implement. In
LocalAnalyticGridViewFunction
we see that the current implementation does not preserve boundedness, i.e., the cached geometry is not transported to the derivative-local-function.
Application
In core/dune-geometry!170 (closed) I have started a merge request for a geometry parametrized by local-functions. Since the geometry needs derivatives (for the jacobianInverseTransposed()
function), I have to differentiate the local-function. Here comes the question into play whether another bound is necessary, since the geometry does not know anything about a grid element and where the local-function came from, I would expect that the local-function should handle the bind of its derivative.
In this example, I either make the assumption that I get a local-functions that is bound to a localContext
, can access this local context and the derivative can bound to this context:
auto df = derivative(lf);
df.bind(lf.localContext());
return df(local);
or I construct a wrapper around any classical local-function that would do exactly these step in the derivative(lf)
call.