heat.cc 1.74 KB
Newer Older
1 2 3 4 5 6
// -*- 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>
7
#include <dune/amdis/AdaptInstationary.hpp>
8 9
#include <dune/amdis/ProblemInstat.hpp>
#include <dune/amdis/ProblemStat.hpp>
10
#include <dune/amdis/Operators.hpp>
11
#include <dune/amdis/Terms.hpp>
12
#include <dune/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   = LagrangeBasis<Grid::LeafGridView, 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 43 44
  auto opTimeRhs = makeOperator(tag::test{},
    func([invTau](double u) { return u * (*invTau); }, valueOf(prob.getSolution(0))) );
  prob.addVectorOperator(opTimeRhs, 0);
45

46
  auto opForce = makeOperator(tag::test{}, [](auto const& x) { return -1.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
}