sphere.cc 2.17 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
31
32
33
34
35
36
37
38
39
};

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

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

  // ===== check for init file =====
  TEST_EXIT(argc == 2)("usage: sphere initfile\n");

  // ===== init parameters =====
  Parameters::init(false, argv[1]);

  // ===== create projection =====
  WorldVector<double> ballCenter;
  ballCenter.set(0.0);
40
  new BallProject(1, 
41
42
43
44
45
46
47
48
49
		  BOUNDARY_PROJECTION, 
		  ballCenter, 
		  1.0);

  // ===== create and init the scalar problem ===== 
  ProblemScal sphere("sphere");
  sphere.initialize(INIT_ALL);

  // === create adapt info ===
50
  AdaptInfo *adaptInfo = new AdaptInfo("sphere->adapt");
51
52

  // === create adapt ===
53
  AdaptStationary *adapt = new AdaptStationary("sphere->adapt",
54
55
56
57
58
					       &sphere,
					       adaptInfo);
  
  // ===== create matrix operator =====
  Operator matrixOperator(Operator::MATRIX_OPERATOR,
59
			  sphere.getFeSpace());
60
  matrixOperator.addSecondOrderTerm(new Laplace_SOT);
61
62
63
64
  sphere.addMatrixOperator(&matrixOperator);

  // ===== create rhs operator =====
  Operator rhsOperator(Operator::VECTOR_OPERATOR,
65
		       sphere.getFeSpace());
66

67
  int degree = sphere.getFeSpace()->getBasisFcts()->getDegree();
68

69
  rhsOperator.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
70
71
72
73
74
75
76
77
78
79
80
  sphere.addVectorOperator(&rhsOperator);

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

  sphere.writeFiles(adaptInfo, true);

  return 0;
}