sphere.cc 1.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
#include "AMDiS.h"

using namespace std;
using namespace AMDiS;

// ===========================================================================
// ===== function definitions ================================================
// ===========================================================================

10
/// RHS function
11
12
13
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
14
  F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
15

16
17
18
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
19
20
    return -2.0 * x[0];
  }
21
22
23
24
25
26
27
28
29
30
};

// ===========================================================================
// ===== main program ========================================================
// ===========================================================================

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

31
  AMDiS::init(argc, argv);
32
33
34
35

  // ===== create projection =====
  WorldVector<double> ballCenter;
  ballCenter.set(0.0);
Thomas Witkowski's avatar
Thomas Witkowski committed
36
  new BallProject(1, VOLUME_PROJECTION, ballCenter, 1.0);
37
38

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

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

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

  // ===== create rhs operator =====
56
  Operator rhsOperator(sphere.getFeSpace());
57

58
  int degree = sphere.getFeSpace()->getBasisFcts()->getDegree();
59

60
  rhsOperator.addTerm(new CoordsAtQP_ZOT(new F(degree)));
61
  sphere.addVectorOperator(&rhsOperator, 0);
62
63
64
65
66
67

  // ===== start adaption loop =====
  adapt->adapt();

  sphere.writeFiles(adaptInfo, true);

68
  AMDiS::finalize();
69
70
71
}