vecellipt.cc 1.45 KB
Newer Older
1
2
3
4
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

5
6
#include <iostream>

7
#include <amdis/AMDiS.hpp>
8
#include <amdis/LocalOperators.hpp>
9
#include <amdis/ProblemStat.hpp>
10
11
12

using namespace AMDiS;

13
using ElliptParam   = YaspGridBasis<GRIDDIM, 2,2>;
14
15
16
17
18
19
20
21
22
23
24
using ElliptProblem = ProblemStat<ElliptParam>;

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

  ElliptProblem prob("ellipt");
  prob.initialize(INIT_ALL);

  AdaptInfo adaptInfo("adapt");

25
  auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0);
26
27
  prob.addMatrixOperator(opL, 1, 1);

28
29
30
  auto opM = makeOperator(tag::test_trial{}, 1.0);
  prob.addMatrixOperator(std::ref(opM), 0, 0);
  prob.addMatrixOperator(std::ref(opM), 1, 0);
31

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


  // 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
  prob.addDirichletBC(predicate, 1, 1, dbcValues);

41
  prob.buildAfterAdapt(adaptInfo, Flag(0));
42

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

Praetorius, Simon's avatar
Praetorius, Simon committed
49
    std::cout << prob.systemMatrix().matrix() << '\n';
50
  }
51
#endif
52
53
54
55
56
57
58

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

  AMDiS::finalize();
  return 0;
}