ProblemStatTest.cpp 1.99 KB
Newer Older
1
#include <amdis/AMDiS.hpp>
2
#include <amdis/AdaptiveGrid.hpp>
3
#include <amdis/AdaptStationary.hpp>
4
5
#include <amdis/LocalOperators.hpp>
#include <amdis/ProblemStat.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
6
#include <amdis/common/QuadMath.hpp>
7
#include <amdis/functions/GlobalBasis.hpp>
8

Praetorius, Simon's avatar
Praetorius, Simon committed
9
10
#include <dune/common/version.hh>
#include <dune/grid/yaspgrid.hh>
11

Praetorius, Simon's avatar
Praetorius, Simon committed
12
using namespace AMDiS;
13
14
15
16

template <class T>
void test()
{
Praetorius, Simon's avatar
Praetorius, Simon committed
17
  // use T as coordinate type
18
19
  using HostGrid = Dune::YaspGrid<2, Dune::EquidistantCoordinates<T,2>>;
  HostGrid hostGrid({T(1), T(1)}, {8,8});
Praetorius, Simon's avatar
Praetorius, Simon committed
20
  AdaptiveGrid<HostGrid> grid(hostGrid);
Praetorius, Simon's avatar
Praetorius, Simon committed
21
22
23
24

  // use T as range type for basis
  using namespace Dune::Functions::BasisFactory;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
25
  GlobalBasis basis{grid.leafGridView(), power<1>(lagrange<1>(), flatLexicographic())};
Praetorius, Simon's avatar
Praetorius, Simon committed
26
#else
27
  GlobalBasis basis{grid.leafGridView(), power<1>(lagrange<1,T>(), flatLexicographic())};
Praetorius, Simon's avatar
Praetorius, Simon committed
28
29
30
31
32
33
#endif
  using Basis = decltype(basis);

  // use T as coefficient type
  using Param = DefaultProblemTraits<Basis, T>;

Praetorius, Simon's avatar
Praetorius, Simon committed
34
  msg("Test<{}>", __PRETTY_FUNCTION__);
Praetorius, Simon's avatar
Praetorius, Simon committed
35
  ProblemStat<Param> prob("ellipt", grid, basis);
36
37
38
39
40
41
  prob.initialize(INIT_ALL);
  prob.boundaryManager()->setBoxBoundary({1,1,2,2});

  prob.addMatrixOperator(sot(T(1)), 0, 0);
  prob.addVectorOperator(zot(T(1)), 0);
  prob.addDirichletBC(BoundaryType{1}, 0,0, T(0));
42
43
44
45


  AdaptInfo adaptInfo("adapt");

Praetorius, Simon's avatar
Praetorius, Simon committed
46
  msg("  test copy constructor of problem");
47
48
49
50
  auto prob2(prob);
  AdaptStationary adaptStat2("adapt", prob2, adaptInfo);
  adaptStat2.adapt();

Praetorius, Simon's avatar
Praetorius, Simon committed
51
  msg("  test move constructor of problem");
52
53
54
  auto prob3(std::move(prob2));
  AdaptStationary adaptStat3("adapt", prob3, adaptInfo);
  adaptStat3.adapt();
55
56
57
58
}

int main(int argc, char** argv)
{
59
  Environment env(argc, argv);
60

Praetorius, Simon's avatar
Praetorius, Simon committed
61
#if !AMDIS_HAS_PETSC || PETSC_USE_REAL_SINGLE
62
  test<float>();
63
64
#endif

Praetorius, Simon's avatar
Praetorius, Simon committed
65
#if !AMDIS_HAS_PETSC || PETSC_USE_REAL_DOUBLE
66
  test<double>();
67
68
#endif

Praetorius, Simon's avatar
Praetorius, Simon committed
69
#if !AMDIS_HAS_PETSC
70
  test<long double>();
71
#endif
72

Praetorius, Simon's avatar
Praetorius, Simon committed
73
#if HAVE_QUADMATH && (!AMDIS_HAS_PETSC || PETSC_USE_REAL___FLOAT128) && (!AMDIS_HAS_EIGEN)
Praetorius, Simon's avatar
Praetorius, Simon committed
74
75
76
  test<Dune::Float128>();
#endif

77
78
  return 0;
}