ellipt.cc 1.58 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
3
4
5
6
7
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:

#include <iostream>

#include <dune/amdis/AMDiS.hpp>
#include <dune/amdis/ProblemStat.hpp>
8
#include <dune/amdis/Operators.hpp>
9
#include <dune/amdis/common/Literals.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
10

11
12
using namespace AMDiS;

Praetorius, Simon's avatar
Praetorius, Simon committed
13
// 1 component with polynomial degree 1
14
15
//using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>;
using ElliptParam   = YaspGridBasis<AMDIS_DIM, 1>;
Praetorius, Simon's avatar
Praetorius, Simon committed
16
17
18
19
20
using ElliptProblem = ProblemStat<ElliptParam>;

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

22
23
  using namespace Dune::Indices;

Praetorius, Simon's avatar
Praetorius, Simon committed
24
25
  ElliptProblem prob("ellipt");
  prob.initialize(INIT_ALL);
26

Praetorius, Simon's avatar
Praetorius, Simon committed
27
  AdaptInfo adaptInfo("adapt");
28

29
  auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
30
  prob.addMatrixOperator(opL, _0, _0);
31

32
  auto opForce = makeOperator(tag::test{}, [](auto const& x) { return -1.0; }, 0);
33
  prob.addVectorOperator(opForce, _0);
34
35


Praetorius, Simon's avatar
Praetorius, Simon committed
36
37
38
  // set boundary condition
  auto predicate = [](auto const& x){ return x[0] < 1.e-8 || x[1] < 1.e-8; }; // define boundary
  auto dbcValues = [](auto const& x){ return 0.0; }; // set value
39
  prob.addDirichletBC(predicate, _0, _0, dbcValues);
40

Praetorius, Simon's avatar
Praetorius, Simon committed
41
  *prob.getSolution() = 0.0; // maybe not necessary
42

Praetorius, Simon's avatar
Praetorius, Simon committed
43
  prob.buildAfterCoarsen(adaptInfo, Flag(0));
44

Praetorius, Simon's avatar
Praetorius, Simon committed
45
  // write matrix to file
46
  if (Parameters::get<int>("elliptMesh->global refinements").value_or(0) < 5) {
Praetorius, Simon's avatar
Praetorius, Simon committed
47
    mtl::io::matrix_market_ostream out("matrix.mtx");
48
    out << prob.getSystemMatrix()->getMatrix();
49

50
    std::cout << prob.getSystemMatrix()->getMatrix() << '\n';
Praetorius, Simon's avatar
Praetorius, Simon committed
51
  }
52

Praetorius, Simon's avatar
Praetorius, Simon committed
53
  prob.solve(adaptInfo);
54
  prob.writeFiles(adaptInfo, true);
55

Praetorius, Simon's avatar
Praetorius, Simon committed
56
57
  AMDiS::finalize();
  return 0;
58
}