periodic.cc 1.87 KB
Newer Older
1
2
3
4
5
#include "AMDiS.h"

using namespace std;
using namespace AMDiS;

6
/// Dirichlet boundary function
7
8
9
class G : public AbstractFunction<double, WorldVector<double> >
{
public:
10
11
12
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
13
14
    return 0.0;
  }
15
16
};

17
/// RHS function
18
19
20
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
21
  F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
22

23
24
25
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
26
27
28
    int dim = x.getSize();
    double r2 = (x*x);
    double ux = exp(-10.0*r2);
29
    return -(400.0*r2 - 20.0*dim)*ux;
30
  }
31
32
33
34
35
36
};

int main(int argc, char* argv[])
{
  FUNCNAME("main");

37
  AMDiS::init(argc, argv);
38
39

  // ===== create and init the scalar problem ===== 
40
  ProblemStat periodic("periodic");
41
42
43
  periodic.initialize(INIT_ALL);

  // === create adapt info ===
44
  AdaptInfo *adaptInfo = new AdaptInfo("periodic->adapt", periodic.getNumComponents());
45
46

  // === create adapt ===
47
  AdaptStationary *adapt = new AdaptStationary("periodic->adapt",
48
49
50
51
					       &periodic,
					       adaptInfo);
  
  // ===== create matrix operator =====
52
  Operator matrixOperator(periodic.getFeSpace());
53
  matrixOperator.addTerm(new Simple_SOT);
54
  periodic.addMatrixOperator(&matrixOperator, 0, 0);
55
56

  // ===== create rhs operator =====
57
  int degree = periodic.getFeSpace()->getBasisFcts()->getDegree();
58
  Operator rhsOperator(periodic.getFeSpace());
59
  rhsOperator.addTerm(new CoordsAtQP_ZOT(new F(degree)));
60
  periodic.addVectorOperator(&rhsOperator, 0);
61

62
  // ===== add boundary conditions =====
63
  periodic.addDirichletBC(1, 0, 0, new G);
64
65

  // ===== add periodic conditions =====
66
  periodic.addPeriodicBC(-1, 0, 0);
67

68
69
70
71
  // ===== start adaption loop =====
  adapt->adapt();

  periodic.writeFiles(adaptInfo, true);
72
73

  AMDiS::finalize();
74
75
76
}