DUNE PDELab (git)

Integrating grid functions

First, we define some example grid function to integrate.

auto analyticFunction = Dune::PDELab::makeGridFunctionFromCallable (grid.leafGridView(), [&](const auto& x){
return exp(-(x*x));
});

Computing the integral of a grid function is just a single call:

auto integral = Dune::PDELab::integrateGridFunction(analyticFunction,10);
GF::Traits::RangeType integrateGridFunction(const GF &gf, unsigned qorder=1)
Integrate a GridFunction.
Definition: functionutilities.hh:51

When run in parallel, this integrates over the local interior domain. So, in that case, we still need to sum over all processes for the full integral.

integral = grid.leafGridView().comm().sum(integral);

Full example code: recipe-integrating-grid-functions.cc

Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)