Add preprocess method to local assemblers
In (new dune-functions-based) local assemblers it is sometimes helpful to associate some persistent data to the ansatz tree. E.g. when using a cache of shape function values. However, using this cache requires a local view or at least a tree. Currently there's three possibilities to get hold of one:
- Either the local assembler uses the
LocalView
s passed as argument when called. Then it has to be passed to the persistent data on each call. This makes the cache implementation far more ugly, because you cannot simply create a cache access cache values, but have to pass the tree each time. This may even be costly, because one has to access the tree children each time anew. - Alternatively, one can bind the cache to the tree on each assembler call, but this suffers from the same drawbacks.
- The cache can store its own
LocalView
and be bound to the element on each assembler call. This is wasting computational time, because binding aLocalView
is not for free and we maintain one anyway in the global assembler.
As an alternative, the global assemblers can pass the LocalView
(s) in advance to the local assembler using some preprocess method. This would be accompanied with the guarantee, that these are the same LocalView
(s) that are passed during subsequent assembler calls. Then the cache can be bound once to this LocalView
or its tree.
While the local assemblers are currently used as plain callbacks using operator()
, it's probably not complicated to extend this and call localAssembler.preprocess(...)
conditionally, only if it exists.