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/common/filledarray.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#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;
Dune::FieldVector<double,dim> L(1.0);
std::array<int,dim> N(Dune::filledArray<dim,int>(64));
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]
// [Sum for parallel case]
integral = grid.leafGridView().comm().sum(integral);
std::cout << "Integral: " << integral << std::endl;
}
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:252
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.
|
Legal Statements / Impressum |
Hosted by TU Dresden |
generated with Hugo v0.111.3
(Nov 12, 23:30, 2024)