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

using namespace std;
using namespace AMDiS;

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

10
/// Dirichlet boundary function
11
12
13
class G : public AbstractFunction<double, WorldVector<double> >
{
public:
14
15
16
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
17
18
    return exp(-10.0 * (x * x));
  }
19
20
};

21
/// RHS function
22
23
24
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
25
  F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
26

27
28
29
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
30
    int dim = x.getSize();
31
32
33
    double r2 = (x * x);
    double ux = exp(-10.0 * r2);
    return -(400.0 * r2 - 20.0 * dim) * ux;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  };
};

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

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

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

48

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

52

53
54
55
56
  // ===== create and init the scalar problem ===== 
  ProblemVec vecellipt("vecellipt");
  vecellipt.initialize(INIT_ALL);

57

58
  // === create adapt info ===
59
60
  AdaptInfo adaptInfo("vecellipt->adapt", vecellipt.getNumComponents());

61
62

  // === create adapt ===
63
  AdaptStationary adapt("vecellipt->adapt", vecellipt, adaptInfo);
64

65
66
67
  
  // ===== create matrix operators =====
  Operator matrixOperator00(Operator::MATRIX_OPERATOR, 
68
			    vecellipt.getFeSpace(0), vecellipt.getFeSpace(0));
69
70
  matrixOperator00.addSecondOrderTerm(new Laplace_SOT);
  vecellipt.addMatrixOperator(matrixOperator00, 0, 0);
71

72
  Operator matrixOperator10(Operator::MATRIX_OPERATOR, 
73
			    vecellipt.getFeSpace(1), vecellipt.getFeSpace(0));
74
75
  matrixOperator10.addZeroOrderTerm(new Simple_ZOT);
  vecellipt.addMatrixOperator(matrixOperator10, 1, 0);
76
77

  Operator matrixOperator11(Operator::MATRIX_OPERATOR,
78
			    vecellipt.getFeSpace(1), vecellipt.getFeSpace(1));
79
80
  matrixOperator11.addZeroOrderTerm(new Simple_ZOT(-1.0));
  vecellipt.addMatrixOperator(matrixOperator11, 1, 1);
81
82


83
  // ===== create rhs operator =====
84
85
  int degree = vecellipt.getFeSpace(0)->getBasisFcts()->getDegree();
  Operator rhsOperator0(Operator::VECTOR_OPERATOR, vecellipt.getFeSpace(0));
86
87
  rhsOperator0.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
  vecellipt.addVectorOperator(rhsOperator0, 0);
88

89
90
91
  // ===== add boundary conditions =====
  vecellipt.addDirichletBC(1, 0, 0, new G);

92
93

  // ===== start adaption loop =====
94
  adapt.adapt();
95
96
97
98
99

  vecellipt.writeFiles(adaptInfo, true);
}