neumann.cc 2.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#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>
17
#include <amdis/LocalOperators.hpp>
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <amdis/common/Literals.hpp>

using namespace AMDiS;
using namespace Dune::Indices;

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

  using Traits = LagrangeBasis<typename Grid::LeafGridView, 2>;
  ProblemStat<Traits> prob("ellipt", grid);
  prob.initialize(INIT_ALL);
  prob.boundaryManager().setBoxBoundary({1,2,2,1});

  auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
  prob.addMatrixOperator(opL, 0, 0);

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

  // set neumann boundary condition
  auto opNeumann = makeOperator(tag::test{}, 1.0);
  prob.addVectorOperator(BoundaryType{2}, opNeumann, 0);

  AdaptInfo adaptInfo("adapt");

  prob.assemble(adaptInfo);
  prob.solve(adaptInfo);
  prob.writeFiles(adaptInfo, true);
}


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

  // 2d grids

  Dune::YaspGrid<2> grid0({1.0,1.0},{2,2});
  run(grid0);

#if HAVE_DUNE_SPGRID
  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

#if HAVE_DUNE_ALUGRID
  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

#if HAVE_DUNE_UGGRID
  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

  // 3d grids

  Dune::YaspGrid<3> grid4({1.0,1.0,1.0},{2,2,2});
  run(grid4);

  AMDiS::finalize();
  return 0;
}