heat.cc 1.71 KB
Newer Older
1
2
3
4
5
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:

#include <iostream>

6
7
8
9
10
11
12
#include <amdis/AMDiS.hpp>
#include <amdis/AdaptInstationary.hpp>
#include <amdis/ProblemInstat.hpp>
#include <amdis/ProblemStat.hpp>
#include <amdis/Operators.hpp>
#include <amdis/GridFunctions.hpp>
#include <amdis/common/Literals.hpp>
13
14
15
16

using namespace AMDiS;

// 1 component with polynomial degree 1
17
18
//using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>;
using HeatParam   = YaspGridBasis<AMDIS_DIM, 2>;
19
20
21
22
23
using HeatProblem = ProblemStat<HeatParam>;
using HeatProblemInstat = ProblemInstat<HeatParam>;

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

26
27
  HeatProblem prob("heat");
  prob.initialize(INIT_ALL);
28

29
30
  HeatProblemInstat probInstat("heat", prob);
  probInstat.initialize(INIT_UH_OLD);
31

32
  AdaptInfo adaptInfo("adapt");
33

34
  double* invTau = probInstat.getInvTau();
35

36
  auto opTimeLhs = makeOperator(tag::test_trial{}, std::ref(*invTau));
37
  prob.addMatrixOperator(opTimeLhs, 0, 0);
38

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

42
  auto opTimeRhs = makeOperator(tag::test{},
43
    invokeAtQP([invTau](double u) { return u * (*invTau); }, prob.getSolution(0)), 2);
44
  prob.addVectorOperator(opTimeRhs, 0);
45

46
  auto opForce = makeOperator(tag::test{}, [](auto const& x) { return -1.0; }, 0);
47
  prob.addVectorOperator(opForce, 0);
48
49


50
51
52
53
  // set boundary condition
  auto predicate = [](auto const& p){ return p[0] < 1.e-8 || p[1] < 1.e-8; };
  auto dbcValues = [](auto const& p){ return 0.0; };
  prob.addDirichletBC(predicate, 0, 0, dbcValues);
54

55
56
  AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo);
  adapt.adapt();
57

58
59
  AMDiS::finalize();
  return 0;
60
}