ellipt.cc 1.55 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

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

Praetorius, Simon's avatar
Praetorius, Simon committed
25
  AdaptInfo adaptInfo("adapt");
26

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

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


Praetorius, Simon's avatar
Praetorius, Simon committed
34 35 36
  // 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
37
  prob.addDirichletBC(predicate, _0, _0, dbcValues);
38

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

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

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

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

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

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