neumann.cc 2.02 KB
Newer Older
1
2
3
4
5
#include "AMDiS.h"

using namespace AMDiS;
using namespace std;

6
class N_ : public AbstractFunction<double, WorldVector<double> >
7
8
{
public:
9
10
  double operator()(const WorldVector<double>& x) const 
  {
11
12
    return 1.0;
  }
13
14
};

15
/// Dirichlet boundary function
16
17
18
class G : public AbstractFunction<double, WorldVector<double> >
{
public:
19
20
21
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
22
23
    return exp(-10.0 * (x * x));
  }
24
25
};

26
/// RHS function
27
28
29
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
30
  F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
31

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

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

47
  AMDiS::init(argc, argv);
48
49

  // ===== create and init the scalar problem ===== 
50
  ProblemStat neumann("neumann");
51
52
53
  neumann.initialize(INIT_ALL);

  // === create adapt info ===
54
  AdaptInfo *adaptInfo = new AdaptInfo("neumann->adapt", neumann.getNumComponents());
55
56

  // === create adapt ===
57
  AdaptStationary *adapt = new AdaptStationary("neumann->adapt",
58
59
60
61
					       &neumann,
					       adaptInfo);
  
  // ===== create matrix operator =====
62
  Operator matrixOperator(neumann.getFeSpace());
63
  matrixOperator.addTerm(new Simple_SOT);
64
  neumann.addMatrixOperator(&matrixOperator, 0, 0);
65
66

  // ===== create rhs operator =====
67
  int degree = neumann.getFeSpace()->getBasisFcts()->getDegree();
68
  Operator rhsOperator(neumann.getFeSpace());
69
  rhsOperator.addTerm(new CoordsAtQP_ZOT(new F(degree)));
70
  neumann.addVectorOperator(&rhsOperator, 0);
71

72
  // ===== add boundary conditions =====
73
  neumann.addNeumannBC(1, 0, 0, new N_);
74
  neumann.addDirichletBC(2, 0, 0, new G);
75

76
77
78
79
  // ===== start adaption loop =====
  adapt->adapt();

  neumann.writeFiles(adaptInfo, true);
80
81

  AMDiS::finalize();
82
83
84
}