RefinementManager.cc 3.06 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
#include "RefinementManager.h"
#include "Mesh.h"
#include "Traverse.h"
#include "ElInfo.h"
#include "DOFAdmin.h"
#include "AdaptStationary.h"
#include "AdaptInstationary.h"
#include "FixVec.h"
#include "RCNeighbourList.h"
#include "ProblemStatBase.h"
#include "PeriodicBC.h"

namespace AMDiS {

  bool RefinementManager::doMoreRecursiveRefine = false;
  int RefinementManager::callRefineInterpol = 0;
  RCNeighbourList* RefinementManager3d::refList = NULL;


  Flag RefinementManager::globalRefine(Mesh *aMesh, int mark)
  {
    FUNCNAME("RefinementManager::globalRefine()");

24
25
26
    if (mark <= 0) 
      return static_cast<Flag>(0);

27
28
29
30
31
32
33
34
    TraverseStack stack;
    ElInfo *elInfo = 
      stack.traverseFirst(aMesh, -1, 
			  Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_BOUND);
    while (elInfo) {
      elInfo->getElement()->setMark(mark);
      elInfo = stack.traverseNext(elInfo);
    }
35
36

    return refineMesh(aMesh);
37
38
  }

39

40
41
42
43
44
  Flag RefinementManager::refineMesh(Mesh *aMesh)
  {
    FUNCNAME("RefinementManager::refineMesh()");

    mesh = aMesh;
45
    int nElements = mesh->getNumberOfLeaves();
46
    newCoords = false;
Thomas Witkowski's avatar
Thomas Witkowski committed
47
    stack = new TraverseStack;
48
    doMoreRecursiveRefine = true;
49

50
51
    while (doMoreRecursiveRefine) {
      doMoreRecursiveRefine = false;
52
      ElInfo *elInfo = 
53
54
	stack->traverseFirst(mesh, -1, 
			     Mesh::CALL_LEAF_EL | Mesh::FILL_NEIGH | Mesh::FILL_BOUND);
55
      while (elInfo) {
56
	if (elInfo->getElement()->getMark() > 0) {	  
57
58
	  doMoreRecursiveRefine = 
	    doMoreRecursiveRefine || (elInfo->getElement()->getMark() > 1);
59
60
61
	  elInfo = refineFunction(elInfo);
	}	
	elInfo = stack->traverseNext(elInfo);
62
      }
63
    }
64
  
65
66
    if (newCoords)
      setNewCoords(); // call of sub-class method      
67

Thomas Witkowski's avatar
Thomas Witkowski committed
68
    delete stack;
69

70
    nElements -= mesh->getNumberOfLeaves();
71
 
72
73
74
75
76
77
    if (nElements != 0) {
      aMesh->incChangeIndex();
      return MESH_REFINED;
    } else {
      return Flag(0);
    }
78
79
  }

80

81
  void RefinementManager::refineMacroElement(Mesh *aMesh, int macroElIndex)
82
  {
83
    FUNCNAME("RefineManager::refineMacroElement()");
84
85
86
87
    
    mesh = aMesh;
    int nElements = mesh->getNumberOfLeaves();
    newCoords = false;
88
    doMoreRecursiveRefine = true;
89
90
    stack = new TraverseStack;
    
91
92
    while (doMoreRecursiveRefine) {
      doMoreRecursiveRefine = false;
93
94
95

      MSG("HERE 1\n");

96
97
98
99
100
101
102
103
104
105
      ElInfo *elInfo = 
	stack->traverseFirstOneMacro(mesh, macroElIndex, -1, 
				     Mesh::CALL_LEAF_EL | Mesh::FILL_NEIGH | Mesh::FILL_BOUND);
      
      while (elInfo) {
	if (elInfo->getElement()->getMark() > 0) {	  
	  doMoreRecursiveRefine = 
	    doMoreRecursiveRefine || (elInfo->getElement()->getMark() > 1);
	  elInfo = refineFunction(elInfo);
	}	
106
	MSG("WIRKLICH HERE? 1\n");
107
	elInfo = stack->traverseNext(elInfo);
108
	MSG("WIRKLICH HERE? 2\n");
109
      }
110
111

      MSG("HERE 2\n");
112
113
    }

114

115
116
    MSG("HERE 3\n");

117
    if (newCoords)
118
      setNewCoords(macroElIndex); // call of sub-class method
119

120
    MSG("HERE 4\n");
121
    delete stack;
122
        MSG("HERE 5\n");
123
    nElements -= mesh->getNumberOfLeaves();
124
       MSG("HERE 6\n");
125
126
    if (nElements != 0)
      aMesh->incChangeIndex();    
127
    MSG("HERE 7\n");
128
129
  }

130
}