Closed joshichaitanya3 closed 1 year ago
I really like this idea, @joshichaitanya3. Can you go ahead and add to other functionals, please?
I will merge this in anyway as it's a valuable experimental feature. We may rethink some of the interface for functionals for 0.6 or beyond, but it's great to have this functionality exposed as we learn more about how it might be used.
This PR sets up a machinery for adding a
integrandForElement
method to functionals**. This can be really useful for applications that require point-wise operations (perturbing one vertex at a time in a Monte-Carlo simulation, for example).This can be used like so:
We define a small
functional_mapintegrandforelement
method in C that computes the value of the integrand at a given element id. The element type depends on the grade on which the functional is defined.We further define a
FUNCTIONAL_INTEGRANDFORELEMENT
macro in functional.h that makes it easy to define this method for simpler functionals using a single line. The existingFUNCTIONAL_METHOD
macro proves to be sufficient to define it for functionals that contain a reference (see the implementation forLineCurvatureSq
in this PR).In this PR, we have added this method for the following functionals:
Length
(defined on grade 1 elements)AreaEnclosed
(defined on grade 1 elements)Area
(defined on grade 2 elements)LineCurvatureSq
(defined on grade 0 elements)If this looks good, we can add this method to all existing functionals.
** Upon discussions, the idea of having this as an optional behavior for the
integrand
method itself was rejected on the grounds of clarity and readability of the code.