ProblemInterpolScal.cc 1.54 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
21
22
    Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER & ~INIT_ESTIMATOR;
  
    initialize(initFlag, spaceProblem, adoptFlag);
  }

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

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

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

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

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

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

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

}