ProblemInterpolScal.cc 1.65 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "ProblemInterpolScal.h"
#include "Mesh.h"
#include "DOFVector.h"
#include "Parameters.h"
#include "AdaptInfo.h"

namespace AMDiS {

  ProblemInterpolScal::ProblemInterpolScal(const char *name,
					   ProblemScal *spaceProblem,
					   AbstractFunction<double, WorldVector<double> > *fct,
					   AbstractFunction<WorldVector<double>, WorldVector<double> > *grdFct)
    : ProblemScal(name),
Thomas Witkowski's avatar
Thomas Witkowski committed
14
15
      interpolFct(fct),
      grdInterpolFct(grdFct)
16
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
17
    Flag adoptFlag = INIT_SYSTEM | INIT_MESH | INIT_FE_SPACE;
18
19
20
    Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER & ~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER;
    if(initFlag.isSet(CREATE_MESH))
      WARNING("CREATE_MESH is set\n");
21
22
23
    initialize(initFlag, spaceProblem, adoptFlag);
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
24
25
  void ProblemInterpolScal::solve(AdaptInfo *adaptInfo) 
  {
26
    mesh->dofCompress();
Thomas Witkowski's avatar
Thomas Witkowski committed
27
    solution->interpol(interpolFct);
28
29
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
30
31
  void ProblemInterpolScal::estimate(AdaptInfo *adaptInfo, double) 
  {
32
    FUNCNAME("ProblemIterpolScal::estimate()");
33
34
    double errMax = 0.0;
    double errSum = 0.0;
35
36
37
    int errorNorm = 0;

    int relErr = 0;
Thomas Witkowski's avatar
Thomas Witkowski committed
38
    GET_PARAMETER(0, name + "->rel error", "%d", &relErr);
39

Thomas Witkowski's avatar
Thomas Witkowski committed
40
    if (grdInterpolFct) 
41
42
      errorNorm = 1;
    else
Thomas Witkowski's avatar
Thomas Witkowski committed
43
      if (interpolFct) 
44
45
46
47
	errorNorm = 2;

    switch (errorNorm) {
    case 1:
Thomas Witkowski's avatar
Thomas Witkowski committed
48
      errSum = Error<double>::H1Err(*grdInterpolFct, *solution, relErr, &errMax, true);
49
50
      break;
    case 2:
Thomas Witkowski's avatar
Thomas Witkowski committed
51
      errSum = Error<double>::L2Err(*interpolFct, *solution, relErr, &errMax, true);
52
53
54
55
56
57
58
59
60
61
62
63
      break;
    default: 
      ERROR_EXIT("invalid error norm\n");
    }

    MSG("estimate: %e\n", errSum);

    adaptInfo->setEstSum(errSum, 0);
    adaptInfo->setEstMax(errMax, 0);
  }

}