convection_diffusion.cc 1.02 KB
Newer Older
1
#include "config.h"
2
3
4
5
#include <iostream>

#include <amdis/AMDiS.hpp>
#include <amdis/ProblemStat.hpp>
6
#include <amdis/localoperators/ConvectionDiffusionOperator.hpp>
7
8
9
10
11

using namespace AMDiS;

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

14
15
16
17
18
  // create a grid by inspecting the initfile parameters
  Dune::YaspGrid<2> grid({1.0, 1.0}, {4u, 4u});

  using namespace Dune::Functions::BasisFactory;
  ProblemStat prob("ellipt", grid, lagrange<1>());
19
20
21
22
  prob.initialize(INIT_ALL);

  // -div(A*grad(u)) + div(b*u) + c*u = f
  auto opCD = convectionDiffusion(/*A=*/1.0, /*b=*/0.0, /*c=*/1.0, /*f=*/1.0);
23
24
  prob.addMatrixOperator(opCD);
  prob.addVectorOperator(opCD);
25
26
27
28

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

  AdaptInfo adaptInfo("adapt");
Praetorius, Simon's avatar
Praetorius, Simon committed
32
  prob.assemble(adaptInfo);
33
  prob.solve(adaptInfo);
Praetorius, Simon's avatar
Praetorius, Simon committed
34
  prob.writeFiles(adaptInfo);
35
36
37

  return 0;
}