ProblemInterpolScal.cc 1.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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),
      interpolFct_(fct),
      grdInterpolFct_(grdFct)
  {
    Flag adoptFlag = 
      INIT_SYSTEM | 
      INIT_MESH |
      INIT_FE_SPACE;

    Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER & ~INIT_ESTIMATOR;
  
    initialize(initFlag, spaceProblem, adoptFlag);
  }

  void ProblemInterpolScal::solve(AdaptInfo *adaptInfo) {
28
29
    mesh->dofCompress();
    solution->interpol(interpolFct_);
30
31
32
33
  }

  void ProblemInterpolScal::estimate(AdaptInfo *adaptInfo, double) {
    FUNCNAME("ProblemIterpolScal::estimate()");
34
35
    double errMax = 0.0;
    double errSum = 0.0;
36
37
38
    int errorNorm = 0;

    int relErr = 0;
Thomas Witkowski's avatar
Thomas Witkowski committed
39
    GET_PARAMETER(0, name + "->rel error", "%d", &relErr);
40
41
42
43
44
45
46
47
48

    if (grdInterpolFct_) 
      errorNorm = 1;
    else
      if (interpolFct_) 
	errorNorm = 2;

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

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

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

}