Skip to content

[forms] Implement sums of nullary operator with constants

Carsten Gräser requested to merge feature/forms-sum-with-constants into master

This adds overloads for sums and differences of operators with constant values. In order to preserve the multi-linearity and arity, this is naturally restricted to the case of nullary operators. Technically it was possible to represent such sums (and differences) before using (for a constant T and a nullary operator S)

auto T_op = Coefficient(Dune::Functions::makeGridViewFunction([](auto) { return T;}, gridView));
auto sum = T_op + S;

Now this can be written as

auto sum = T + S;

The latter also improves performance: Normally we multiply out products of sums to benefit from the lowest possible quadrature order for each term. E.g. (T_op+S)*R is translated to T_op*R+S*R. In the special case above, this behavior is never beneficial. Since T+S requires the same order as S, we cannot benefit from a lower quadrature order. However, we have to pay for evaluating R for two quadrature rules with different order, when multiplying out. This no longer happens for (T+S)*R with the new notation and (T+S) is always kept as a single term requiring the same order as S.

Everything written above applies to differences, too.

Edited by Carsten Gräser

Merge request reports

Loading