ellipt.cc 2.3 KB
Newer Older
1
2
3
4
5
#include "AMDiS.h"

using namespace AMDiS;
using namespace std;

6
7
8
9
10
// ===========================================================================
// ===== function definitions ================================================
// ===========================================================================

/// Dirichlet boundary function
11
12
13
14
class G : public AbstractFunction<double, WorldVector<double> >
{
public:

15
16
17
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
18
19
    return exp(-10.0 * (x * x));
  }
20
21
};

22
/// RHS function
23
24
25
26
class F : public AbstractFunction<double, WorldVector<double> >
{
public:

27
28
  F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}

29
30
31
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
32
    int dow = Global::getGeo(WORLD);
33
34
    double r2 = (x * x);
    double ux = exp(-10.0 * r2);
35
36
    return -(400.0 * r2 - 20.0 * dow) * ux;
  }
37
38
};

39
40
41
42
// ===========================================================================
// ===== main program ========================================================
// ===========================================================================

43
44
45
46
47
48
49
int main(int argc, char* argv[])
{
  FUNCNAME("main");

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

50

51
52
53
  // ===== init parameters =====
  Parameters::init(true, argv[1]);

54

55
56
57
58
  // ===== create and init the scalar problem ===== 
  ProblemScal ellipt("ellipt");
  ellipt.initialize(INIT_ALL);

59

60
  // === create adapt info ===
61
62
  AdaptInfo adaptInfo("ellipt->adapt");

63
64

  // === create adapt ===
65
66
  AdaptStationary adapt("ellipt->adapt", ellipt, adaptInfo);

67
68
  
  // ===== create matrix operator =====
69
  Operator matrixOperator(ellipt.getFeSpace());
70
  matrixOperator.addSecondOrderTerm(new Laplace_SOT);
71
72
  ellipt.addMatrixOperator(matrixOperator);

73
74

  // ===== create rhs operator =====
75
  int degree = ellipt.getFeSpace()->getBasisFcts()->getDegree();
76
  Operator rhsOperator(ellipt.getFeSpace());
77
  rhsOperator.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
78
79
  ellipt.addVectorOperator(rhsOperator);

80

81
82
83
84
  // ===== add boundary conditions =====
  ellipt.addDirichletBC(1, new G);


85
  // ===== start adaption loop =====
Thomas Witkowski's avatar
Thomas Witkowski committed
86
87
  adapt.adapt();

88

Thomas Witkowski's avatar
Thomas Witkowski committed
89
  ellipt.writeFiles(adaptInfo, true);
90
91
92
}