stokes3.cc 1.2 KB
Newer Older
1
#include <amdis/AMDiS.hpp>
2
#include <amdis/LocalOperators.hpp>
3
#include <amdis/ProblemStat.hpp>
4
#include <amdis/localoperators/StokesOperator.hpp>
5
6
7

using namespace AMDiS;

Praetorius, Simon's avatar
Praetorius, Simon committed
8
using Grid = Dune::YaspGrid<2>;
9
using StokesParam = TaylorHoodBasis<Grid>;
10
11
using StokesProblem = ProblemStat<StokesParam>;

12
13
int main(int argc, char** argv)
{
14
  Environment env(argc, argv);
15

16
  StokesProblem prob("stokes");
17
18
19
20
21
  prob.initialize(INIT_ALL);

  double viscosity = 1.0;
  Parameters::get("stokes->viscosity", viscosity);

22
  // tree-paths for components
23
24
  auto _v = Dune::Indices::_0;
  auto _p = Dune::Indices::_1;
25

26
  auto opStokes = makeOperator(tag::stokes{}, viscosity);
27
  prob.addMatrixOperator(opStokes);
28
29

  // define boundary values
Praetorius, Simon's avatar
Praetorius, Simon committed
30
  auto parabolic_y = [](auto const& x)
31
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
32
    return FieldVector<double,2>{0.0, x[1]*(1.0 - x[1])};
33
34
  };

Praetorius, Simon's avatar
Praetorius, Simon committed
35
  FieldVector<double,2> zero(0);
36
37

  // set boundary conditions for velocity
Praetorius, Simon's avatar
Praetorius, Simon committed
38
39
40
  prob.boundaryManager()->setBoxBoundary({1,2,2,2});
  prob.addDirichletBC(1, _v, _v, parabolic_y);
  prob.addDirichletBC(2, _v, _v, zero);
41

42
  AdaptInfo adaptInfo("adapt");
43
44

  // assemble and solve system
Praetorius, Simon's avatar
Praetorius, Simon committed
45
  prob.assemble(adaptInfo);
46
47
48
  prob.solve(adaptInfo);

  // output solution
49
  prob.writeFiles(adaptInfo);
50
51
52

  return 0;
}