gridview.cc 1.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// -*- 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/AdaptInstationary.hpp>
#include <dune/amdis/ProblemInstat.hpp>
#include <dune/amdis/ProblemStat.hpp>
#include <dune/amdis/Terms.hpp>
#include <dune/amdis/common/Literals.hpp>

#include <dune/grid/utility/structuredgridfactory.hh>

using namespace AMDiS;

using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>;

// 1 component with polynomial degree 1
20
using Param   = LagrangeTraits<Grid, 1>;
21
22
23
24
25
26
27
28
29
30
31
32
using ElliptProblem = ProblemStat<Param>;
using ElliptProblemInstat = ProblemInstat<Param>;

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

  // Create grid from structured grid
  std::array<unsigned int, 2> n = {{4, 4}};
  Dune::FieldVector<double, 2> lower = {{0.0, 0.0}};
  Dune::FieldVector<double, 2> upper = {{1.0, 1.0}};
  auto grid = Dune::StructuredGridFactory<Grid>::createSimplexGrid(lower, upper, n);
Praetorius, Simon's avatar
Praetorius, Simon committed
33
  // NOTE: can not be used with AlbertaGrid
34
35
36
37
38
39
40
41
42

  ElliptProblem prob("ellipt", *grid);
  prob.initialize(INIT_ALL);

  ElliptProblemInstat probInstat("ellipt", prob);
  probInstat.initialize(INIT_UH_OLD);

  AdaptInfo adaptInfo("adapt");

43
  using Op = ElliptProblem::ElementOperator;
44
45
46
47
48
49
50
51
  Op opL, opForce;

  opL.addSOT(1.0);
  prob.addMatrixOperator(opL, 0, 0);

  opForce.addZOT( eval([](auto const& x) { return -1.0; }) );
  prob.addVectorOperator(opForce, 0);

52
53
54
55
  using BOp = ElliptProblem::IntersectionOperator;
  BOp opB;
  opB.addZOT(1.0);
  prob.addVectorOperator({1}, opB, 0);
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

  // 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, 0, 0, dbcValues);

  *prob.getSolution() = 0.0; // maybe not necessary

  prob.buildAfterCoarsen(adaptInfo, Flag(0));
  prob.solve(adaptInfo);
  prob.writeFiles(adaptInfo, true);

  AMDiS::finalize();
  return 0;
}