DUNE PDELab (2.8)

recipe-integrating-grid-functions.cc

See explanation at Integrating grid functions

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include <dune/pdelab.hh>
int main(int argc, char** argv)
{
// Initialize Mpi
Dune::MPIHelper::instance(argc, argv);
// need a grid in order to test grid functions
constexpr unsigned int dim = 2;
std::array<int,dim> N(Dune::filledArray<dim,int>(64));
typedef Dune::YaspGrid<dim> Grid;
Grid grid(L,N);
// [Defining an analytic grid function]
auto analyticFunction = Dune::PDELab::makeGridFunctionFromCallable (grid.leafGridView(), [&](const auto& x){
return exp(-(x*x));
});
// [Compute integral]
auto integral = Dune::PDELab::integrateGridFunction(analyticFunction,10);
// [Sum for parallel case]
integral = grid.leafGridView().comm().sum(integral);
std::cout << "Integral: " << integral << std::endl;
}
vector space out of a tensor product of fields.
Definition: fvector.hh:95
[ provides Dune::Grid ]
Definition: yaspgrid.hh:160
Utility to generate an array with a certain value.
GF::Traits::RangeType integrateGridFunction(const GF &gf, unsigned qorder=1)
Integrate a GridFunction.
Definition: functionutilities.hh:51
Helpers for dealing with MPI.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)