Estimator.cc 2.41 KB
Newer Older
1
2
3
#include "Estimator.h"
#include "Traverse.h"
#include "Parameters.h"
4
#include "DualTraverse.h"
5
6
7

namespace AMDiS {

8
  Estimator::Estimator(std::string name_, int r) 
9
10
    : name(name_),
      norm(NO_NORM),
11
12
13
14
      row(r),
      mesh(NULL),
      auxMesh(NULL),
      traverseInfo(0)
15
  {
16
17
    FUNCNAME("Estimator::Estimator()");

18
    GET_PARAMETER(0, name + "->error norm", "%d", &norm);
19
20
  }

21

22
23
24
  double Estimator::estimate(double ts)
  {
    FUNCNAME("Estimator::estimate()");
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

    bool dualTraverse = false;
    for (unsigned int i = 0; i < matrix.size(); i++) {
      TEST_EXIT(traverseInfo.getStatus(row, i) != SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX)
	("Not yet implemented!\n");

      if (traverseInfo.getStatus(row, i) == SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX ||
	  traverseInfo.getStatus(row, i) == SingleComponentInfo::DIF_SPACES_NO_AUX ||
	  traverseInfo.getStatus(row, i) == SingleComponentInfo::DIF_SPACES_WITH_AUX)
	dualTraverse = true;
    }

    if (!dualTraverse) {
      mesh = uh[row == -1 ? 0 : row]->getFESpace()->getMesh();
      auxMesh = NULL;
    } else {
      const FiniteElemSpace *mainFeSpace = traverseInfo.getRowFeSpace(row);
      const FiniteElemSpace *auxFeSpace = traverseInfo.getNonRowFeSpace(row);

      TEST_EXIT(mainFeSpace)("No main FE space!\n");
      TEST_EXIT(auxFeSpace)("No aux FE space!\n"); 

      mesh = mainFeSpace->getMesh();
      auxMesh = auxFeSpace->getMesh();

      TEST_EXIT_DBG(mainFeSpace->getBasisFcts()->getDegree() ==
		    auxFeSpace->getBasisFcts()->getDegree())
	("Mh, do you really want to do this? Think about it ...\n");
    }
      
55
    init(ts);
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    if (!dualTraverse)
      singleMeshTraverse();
    else
      dualMeshTraverse();

    exit();

    return est_sum;
  }


  void Estimator::singleMeshTraverse()
  {
    FUNCNAME("Estimator::singleMeshTraverse()");

72
73
    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh, -1, traverseFlag);
74
    while (elInfo) {
75
76
      estimateElement(elInfo);
      elInfo = stack.traverseNext(elInfo);
77
    }  
78
  }
79
80


81
82
83
84
85
86
87
88
89
90
91
92
93
94
  void Estimator::dualMeshTraverse()
  {
    FUNCNAME("Estimator::dualMeshTraverse()");

    DualTraverse dualTraverse;
    DualElInfo dualElInfo;

    bool cont = dualTraverse.traverseFirst(mesh, auxMesh, -1, -1, 
					   traverseFlag, traverseFlag,
					   dualElInfo);
    while (cont) {
      estimateElement(dualElInfo.rowElInfo, &dualElInfo);      
      cont = dualTraverse.traverseNext(dualElInfo);
    }
95
96
  }
}