RefinementManager.cc 2 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
28
29
30
31
32
#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 {

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

  int RefinementManager::globalRefineFct(ElInfo* elinfo)
  {
    FUNCNAME("RefineManager::globalRefineFct");

    elinfo->getElement()->setMark(globalMark);
    return 0;
  }

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

33
34
35
    if (mark <= 0) 
      return static_cast<Flag>(0);

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    globalMark = mark;
    aMesh->traverse(-1, 
		    Mesh::CALL_LEAF_EL |
		    Mesh::FILL_COORDS |
		    Mesh::FILL_BOUND, 
		    globalRefineFct);
    return refineMesh(aMesh);
  }




  Flag RefinementManager::refineMesh(Mesh *aMesh)
  {
    FUNCNAME("RefinementManager::refineMesh()");

    mesh = aMesh;
    int n_elements = mesh->getNumberOfLeaves();
    ElInfo *el_info;

56
    newCoords = false;
57
58
59

    stack = NEW TraverseStack;
    doMoreRecursiveRefine = true;
60
61
62
63
64
65
66
67
68
69
70
    while (doMoreRecursiveRefine) {
      doMoreRecursiveRefine = false;
      el_info = stack->traverseFirst(mesh, -1, 
				     Mesh::CALL_LEAF_EL | Mesh::FILL_NEIGH| Mesh::FILL_BOUND);
      while (el_info) {
	if (el_info->getElement()->getMark() > 0) {
	  doMoreRecursiveRefine = doMoreRecursiveRefine || 
	    (el_info->getElement()->getMark() > 1);
	  el_info = refineFunction(el_info);
	}
	el_info = stack->traverseNext(el_info);
71
      }
72
    }
73
  
74
    if (newCoords) {
75
76
77
78
79
80
81
82
83
84
85
      setNewCoords(); // call of sub-class method  
    }

    DELETE stack;

    n_elements = mesh->getNumberOfLeaves() - n_elements;

    return(n_elements ? MESH_REFINED : Flag(0));
  }

}