IntegrateTest.cpp 1.11 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:

#include <iostream>

#include <dune/geometry/type.hh>

#include <amdis/AMDiS.hpp>
#include <amdis/ProblemStat.hpp>
#include <amdis/Operators.hpp>
#include <amdis/common/Literals.hpp>
#include <amdis/common/FieldMatVec.hpp>
#include <amdis/gridfunctions/Integrate.hpp>

#include "Tests.hpp"

using namespace AMDiS;

using ElliptParam   = YaspGridBasis<2, 2>;
using ElliptProblem = ProblemStat<ElliptParam>;

int main(int argc, char** argv)
{
  AMDiS::init(argc, argv);

  ElliptProblem prob("ellipt");
  prob.initialize(INIT_ALL);

  auto u = prob.getSolution(0);
  auto gv = u.basis().gridView();

  u << 1.0;
  auto i1 = integrate(1.0, gv);
  auto i2 = integrate(u, gv);
  auto i3 = integrate([](auto const& x) { return 1.0; }, gv, 0);

  AMDIS_TEST(i1 == 1.0);
  AMDIS_TEST(i2 == 1.0);
  AMDIS_TEST(i3 == 1.0);

  auto quad = Dune::QuadratureRules<double,2>::rule(Dune::GeometryTypes::quadrilateral, 0);
  auto i4 = integrate([](auto const& x) { return 1.0; }, gv, quad);

  AMDIS_TEST(i4 == 1.0);

  AMDiS::finalize();
  return 0;
}