neumann.cc 2.15 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
#include <config.h>

3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

#if HAVE_DUNE_SPGRID
#include <dune/grid/spgrid.hh>
#endif
#if HAVE_DUNE_ALUGRID
#include <dune/alugrid/grid.hh>
#endif
#include <dune/grid/uggrid.hh>

#include <amdis/AMDiS.hpp>
#include <amdis/Integrate.hpp>
#include <amdis/ProblemStat.hpp>
16
#include <amdis/LocalOperators.hpp>
17

18
19
#define GRID_ID 3

20
21
22
23
24
25
26
using namespace AMDiS;

template <class Grid>
void run(Grid& grid)
{
  grid.globalRefine(Grid::dimension == 2 ? 4 : 2);

27
  using Traits = LagrangeBasis<Grid, 2>;
28
29
  ProblemStat<Traits> prob("ellipt", grid);
  prob.initialize(INIT_ALL);
30
  prob.boundaryManager()->setBoxBoundary({1,2,2,1});
31
32

  auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
33
  prob.addMatrixOperator(opL);
34
35
36

  // set dirichlet boundary condition
  auto g = [](auto const& x) { return 0.0; };
37
  prob.addDirichletBC(BoundaryType{1}, g);
38
39
40

  // set neumann boundary condition
  auto opNeumann = makeOperator(tag::test{}, 1.0);
41
  prob.addVectorOperator(BoundaryType{2}, opNeumann);
42
43
44
45
46

  AdaptInfo adaptInfo("adapt");

  prob.assemble(adaptInfo);
  prob.solve(adaptInfo);
Praetorius, Simon's avatar
Praetorius, Simon committed
47
  prob.writeFiles(adaptInfo);
48
49
50
51
52
}


int main(int argc, char** argv)
{
53
  Environment env(argc, argv);
54

55
#if GRID_ID == 0
56
57
58
  // 2d grids
  Dune::YaspGrid<2> grid0({1.0,1.0},{2,2});
  run(grid0);
59
#endif
60

61
#if GRID_ID == 1 && HAVE_DUNE_SPGRID
62
63
64
65
66
  Dune::SPDomain<double,2> domain({0.0,0.0}, {1.0,1.0});
  Dune::SPGrid<double,2> grid1(domain, Dune::SPMultiIndex<2>({2,2}));
  run(grid1);
#endif

67
#if GRID_ID == 2 && HAVE_DUNE_ALUGRID
68
69
70
71
72
73
74
  using Grid2 = Dune::ALUGrid<2,2,Dune::simplex,Dune::conforming>;
  using Factory2 = Dune::StructuredGridFactory<Grid2>;
  auto grid2 = Factory2::createSimplexGrid({0.0,0.0}, {1.0,1.0},
                                            std::array<unsigned int,2>{2u,2u});
  run(*grid2);
#endif

75
#if GRID_ID == 3 && HAVE_DUNE_UGGRID
76
77
78
79
80
81
82
  using Grid3 = Dune::UGGrid<2>;
  using Factory3 = Dune::StructuredGridFactory<Grid3>;
  auto grid3 = Factory3::createSimplexGrid({0.0,0.0}, {1.0,1.0},
                                            std::array<unsigned int,2>{2u,2u});
  run(*grid3);
#endif

83
#if GRID_ID == 4
84
85
86
  // 3d grids
  Dune::YaspGrid<3> grid4({1.0,1.0,1.0},{2,2,2});
  run(grid4);
87
#endif
88
89
90

  return 0;
}