surface.cc 1.61 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <amdis/AMDiS.hpp>
#include <amdis/Integrate.hpp>
#include <amdis/LocalOperators.hpp>
#include <amdis/ProblemStat.hpp>

#include <dune/grid/albertagrid/albertareader.hh>
#include <dune/foamgrid/foamgrid.hh>

#include "FactoryParametrization.hpp"
#include "SphereMapping.hpp"

using namespace AMDiS;

14
using Grid = Dune::FoamGrid<GRIDDIM, WORLDDIM>;
15
using Basis = LagrangeBasis<Grid, 1>;
Praetorius, Simon's avatar
Praetorius, Simon committed
16
17
18
19
20
21
22

struct UnitRadius
{
  template <class T>
  static double eval(T&&) { return 1.0; }
};

23
24
25
#if !HAVE_ALBERTA
#error "Need Alberta!!"
#endif
Praetorius, Simon's avatar
Praetorius, Simon committed
26
27
28
29

// solve the equation -laplace(u) - k^2 u = f on the sphere
int main(int argc, char** argv)
{
30
  Environment env(argc, argv);
Praetorius, Simon's avatar
Praetorius, Simon committed
31
32
33
34

  std::string gridName = Parameters::get<std::string>("surface->mesh").value();
  std::string gridFileName = Parameters::get<std::string>(gridName + "->macro file name").value();

35
  using Param = Parametrization<Grid, SphereMapping<GRIDDIM, WORLDDIM, UnitRadius>>;
Praetorius, Simon's avatar
Praetorius, Simon committed
36
37
38
39
40
41
42
43
  Dune::GridFactory<Param> gridFactory;
  Dune::AlbertaReader<Param>().readGrid(gridFileName, gridFactory);
  std::unique_ptr<Grid> grid(gridFactory.create());

  ProblemStat<Basis> prob("surface", *grid);
  prob.initialize(INIT_ALL);

  auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
44
  prob.addMatrixOperator(opL);
Praetorius, Simon's avatar
Praetorius, Simon committed
45
46
47

  double kappa = Parameters::get<double>("surface->kappa").value_or(1.0);
  auto opM = makeOperator(tag::test_trial{}, -kappa*kappa);
48
  prob.addMatrixOperator(opM);
Praetorius, Simon's avatar
Praetorius, Simon committed
49
50

  auto opForce = makeOperator(tag::test{}, X(0) + X(1) + X(2));
51
  prob.addVectorOperator(opForce);
Praetorius, Simon's avatar
Praetorius, Simon committed
52
53
54
55
56
57
58
59
60

  AdaptInfo adaptInfo("adapt");
  prob.assemble(adaptInfo);
  prob.solve(adaptInfo);

  prob.writeFiles(adaptInfo);

  return 0;
}