#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include<math.h>
#include<iostream>
#include<dune/common/parallel/mpihelper.hh>
#include<dune/common/parametertreeparser.hh>
#include<dune/common/timer.hh>
#include<dune/geometry/referenceelements.hh>
#include<dune/geometry/quadraturerules.hh>
int main(
int argc,
char** argv)
{
[[maybe_unused]] Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
const int dim = 4;
Dune::FieldVector<double,dim> len; for (auto& l:len) l=1.0;
std::array<int,dim> cells; for (auto& c : cells) c=5;
Grid grid(len,cells);
Dune::FieldVector<double,4> x({1,2,3,4});
auto y(x);
y *= 1.0/3.0;
[[maybe_unused]] auto s = x*y;
[[maybe_unused]] auto norm = x.two_norm();
Dune::FieldMatrix<double,4,4> A({{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}});
A.mv(x,y);
A.usmv(0.5,x,y);
auto u = [](const auto& x){return std::exp(x.two_norm());};
double integral=0.0;
auto gv = grid.leafGridView();
integral += u(e.geometry().center())*e.geometry().volume();
std::cout << "integral = " << integral << std::endl;
double integral2 = 0.0;
using QR = Dune::QuadratureRules<Grid::ctype,dim>;
{
auto geo = e.geometry();
auto quadrature = QR::rule(geo.type(),5);
for (const auto& qp : quadrature)
integral2 += u(geo.global(qp.position()))
*geo.integrationElement(qp.position())*qp.weight();
}
std::cout << "integral2 = " << integral2 << std::endl;
auto f = [](const auto& x){return x;};
double divergence=0.0;
if (!I.neighbor())
{
auto geoI = I.geometry();
divergence += f(geoI.center())*I.centerUnitOuterNormal()*geoI.volume();
}
}
std::cout << "divergence = " << divergence << std::endl;
}
int main(int argc, char **argv)
Definition: recipe-integration.cc:70
IteratorRange<... > intersections(const GV &gv, const Entity &e)
Iterates over all Intersections of an Entity with respect to the given GridView.
IteratorRange<... > elements(const GV &gv)
Iterates over all elements / cells (entities with codimension 0) of a GridView.
[ provides Dune::Grid ]
Definition: yaspgrid.hh:163