RefinementManager.cc 2.72 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

  void RefinementManager::refineElement(Mesh *aMesh, Element *el)
  {
    FUNCNAME("RefineManager::refineElement()");
    
    mesh = aMesh;
    int nElements = mesh->getNumberOfLeaves();
    newCoords = false;
    doMoreRecursiveRefine = false;
    stack = new TraverseStack;
    
    ElInfo *elInfo = 
      stack->traverseFirst(mesh, -1, 
			   Mesh::CALL_LEAF_EL | Mesh::FILL_NEIGH | Mesh::FILL_BOUND);
    while (elInfo) {
      if (elInfo->getElement() == el) {
	refineFunction(elInfo);

	TEST_EXIT(!doMoreRecursiveRefine)("Okay, this will not work in that way!\n");

	break;
      }
      elInfo = stack->traverseNext(elInfo);
    }

#if 0
    if (newCoords)
      setNewCoords(); // call of sub-class method      
#endif

    delete stack;

    nElements -= mesh->getNumberOfLeaves();
   
    if (nElements != 0)
      aMesh->incChangeIndex();    
  }

118
}