ellipt.cc 2.25 KB
Newer Older
1 2
#include "AMDiS.h"

Praetorius, Simon's avatar
Praetorius, Simon committed
3 4
#include "boost/date_time/posix_time/posix_time.hpp"

5
using namespace AMDiS;
Praetorius, Simon's avatar
Praetorius, Simon committed
6
using namespace boost::posix_time;
7

8 9 10 11 12
// ===========================================================================
// ===== function definitions ================================================
// ===========================================================================

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

17 18 19
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
20
    return exp(-10.0 * (x * x));
21
  }
22 23
};

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

29
  F() : AbstractFunction<double, WorldVector<double> >() {}
30

31 32 33
  /// Implementation of AbstractFunction::operator().
  double operator()(const WorldVector<double>& x) const 
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
34 35 36 37
    int dow = Global::getGeo(WORLD);
    double r2 = (x * x);
    double ux = exp(-10.0 * r2);
    return -(400.0 * r2 - 20.0 * dow) * ux;
38
  }
39 40
};

41 42 43 44
// ===========================================================================
// ===== main program ========================================================
// ===========================================================================

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

49
  AMDiS::init(argc, argv);
50

51
  // ===== create and init the scalar problem ===== 
Praetorius, Simon's avatar
Praetorius, Simon committed
52
  ProblemStat ellipt("ellipt");
53
  ellipt.initialize(INIT_ALL);
Praetorius, Simon's avatar
Praetorius, Simon committed
54

55

56
  // === create adapt info ===
57
  AdaptInfo adaptInfo("ellipt->adapt", ellipt.getNumComponents());
58

59 60

  // === create adapt ===
Praetorius, Simon's avatar
Praetorius, Simon committed
61
  AdaptStationary adapt("ellipt->adapt", ellipt, adaptInfo);
62 63
  
  // ===== create matrix operator =====
64
  Operator matrixOperator(ellipt.getFeSpace());
Praetorius, Simon's avatar
Praetorius, Simon committed
65
  matrixOperator.addTerm(new Simple_ZOT);
66
  ellipt.addMatrixOperator(matrixOperator, 0, 0);
67

68 69

  // ===== create rhs operator =====
Praetorius, Simon's avatar
Praetorius, Simon committed
70 71 72
//   Operator rhsOperator(ellipt.getFeSpace());
//   rhsOperator.addTerm(new CoordsAtQP_ZOT(new F));
//   ellipt.addVectorOperator(rhsOperator, 0);
Praetorius, Simon's avatar
Praetorius, Simon committed
73
  
74
  // ===== add boundary conditions =====
Praetorius, Simon's avatar
Praetorius, Simon committed
75
  ellipt.addDirichletBC(1, 0, 0, new AMDiS::Const<double, WorldVector<double> >(1.0));
76 77


78
  // ===== start adaption loop =====
79 80
  adapt.adapt();
  
Thomas Witkowski's avatar
Thomas Witkowski committed
81
  ellipt.writeFiles(adaptInfo, true);
82 83

  AMDiS::finalize();
84 85 86
}