convection_diffusion.cc 1.18 KB
Newer Older
1
2
3
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
4
5
6
7
#include <iostream>

#include <amdis/AMDiS.hpp>
#include <amdis/ProblemStat.hpp>
8
#include <amdis/localoperators/ConvectionDiffusionOperator.hpp>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <amdis/common/Literals.hpp>

using namespace AMDiS;

// 1 component with polynomial degree 1
//using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>;
using ElliptParam   = YaspGridBasis<AMDIS_DIM, 1>;
using ElliptProblem = ProblemStat<ElliptParam>;

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

  using namespace Dune::Indices;

  ElliptProblem prob("ellipt");
  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);
29
30
  prob.addMatrixOperator(opCD, 0, 0);
  prob.addVectorOperator(opCD, 0);
31
32
33
34

  // 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
35
  prob.addDirichletBC(predicate, 0, 0, dbcValues);
36
37

  AdaptInfo adaptInfo("adapt");
Praetorius, Simon's avatar
Praetorius, Simon committed
38
  prob.assemble(adaptInfo);
39
40
41
42
43
44
  prob.solve(adaptInfo);
  prob.writeFiles(adaptInfo, true);

  AMDiS::finalize();
  return 0;
}