4#include <dune/geometry/quadraturerules.hh>
5#include <dune/grid/common/partitionset.hh>
7#include <amdis/GridFunctions.hpp>
8#include <amdis/Output.hpp>
9#include <amdis/common/Order.hpp>
24 template <
class Expr,
class GV>
25 auto integrate(Expr&& expr, GV
const& gridView,
int localFctOrder = -1)
28 auto localFct = localFunction(gridFct);
30 using LF = TYPEOF(localFct);
31 auto quadOrder = [localFctOrder](
auto const& lf) {
32 DUNE_UNUSED_PARAMETER(localFctOrder);
33 if constexpr(Concepts::Polynomial<LF>)
39 test_exit(Concepts::Polynomial<LF> || localFctOrder >= 0,
"Polynomial degree of expression can not be deduced. You need to provide an explicit value for the quadrature degree or a quadrature rule in `integrate()`.");
41 using Range =
typename decltype(localFct)::Range;
44 using Rules = Dune::QuadratureRules<typename GV::ctype, GV::dimension>;
45 for (
auto const& element : elements(gridView, Dune::Partitions::interior)) {
46 auto geometry = element.geometry();
48 localFct.bind(element);
49 auto const& quad = Rules::rule(element.type(), quadOrder(localFct));
51 for (
auto const qp : quad)
52 result += localFct(qp.position()) * geometry.integrationElement(qp.position()) * qp.weight();
56 return gridView.comm().sum(result);
decltype(auto) makeGridFunction(PreGridFct const &preGridFct, GridView const &gridView)
Generator for Gridfunctions from Expressions (PreGridfunctions)
Definition: GridFunction.hpp:168