DUNE PDELab (git)

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
// 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:91
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:252
[ provides Dune::Grid ]
Definition: yaspgrid.hh:166
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 (Nov 23, 23:29, 2024)