ConditionalMarker.cc 2.24 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "ConditionalMarker.h"

namespace AMDiS
{
  ConditionalMarker::ConditionalMarker(const std::string name_,
				       int row,
				       Marker *decoratedMarker,
				       int globalCoarseGridLevel,
				       int localCoarseGridLevel)
    : Marker(name_, row), 
      decoratedMarker_(decoratedMarker),
      globalCoarseGridLevel_(globalCoarseGridLevel),    
      localCoarseGridLevel_(localCoarseGridLevel)
  {
    if (decoratedMarker != NULL)
      name = decoratedMarker->getName();
    else
      std::cout << "no decorated Marker, mark outer path is" << name << "->mark outer" << std::endl;
    
    int swap;      
    int retVal = Parameters::getGlobalParameter(0, name + "->mark outer", "%d", &swap);

    if (retVal>0)
      markOuter = (bool)swap;
    else
      markOuter = false;

    MSG("markOuter:" + markOuter);
  }

  void ConditionalMarker::initMarking(AdaptInfo *adaptInfo, Mesh *mesh) 
  {
    if (decoratedMarker_) 
      decoratedMarker_->initMarking(adaptInfo, mesh);
  }

  void ConditionalMarker::finishMarking(AdaptInfo *adaptInfo)
  {
    if (decoratedMarker_) {
      int tmp = decoratedMarker_->getElMarkRefine();
      MPI::COMM_WORLD.Allreduce(&tmp,
				&elMarkRefine,
				1,
				MPI_INT,
				MPI_SUM);
      tmp = decoratedMarker_->getElMarkCoarsen();
      MPI::COMM_WORLD.Allreduce(&tmp,
				&elMarkCoarsen,
				1,
				MPI_INT,
				MPI_SUM);
      decoratedMarker_->finishMarking(adaptInfo);
    }
  }


  void ConditionalMarker::markElement(AdaptInfo *adaptInfo, ElInfo *elInfo) 
  {
    FUNCNAME("ConditionalMarker::markElement()");

    if (decoratedMarker_) {
      PartitionElementData *elData = 
	dynamic_cast<PartitionElementData*>(elInfo->getElement()->
					    getElementData(PARTITION_ED));

      TEST_EXIT_DBG(elData)("no partition data\n");

      decoratedMarker_->markElement(adaptInfo, elInfo);

      if (!markOuter && elData->getPartitionStatus() == OUT) {
	Element *element = elInfo->getElement();
	if (element->getMark() > 0)
	  element->setMark(0);	  
      }

      int minLevel = 
	elData->getPartitionStatus() != OUT ? 
	localCoarseGridLevel_ :
	globalCoarseGridLevel_;

      if (elData->getLevel() + elInfo->getElement()->getMark() < minLevel)
	elInfo->getElement()->setMark(-(elData->getLevel() - minLevel));
    }
  }
}