ConditionalMarker.h 3.64 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file ConditionalMarker.h */

#ifndef AMDIS_CONDITIONALMARKER_H
#define AMDIS_CONDITIONALMARKER_H

#include "mpi.h"
#include "Marker.h"
#include "Marker.h"
#include "PartitionElementData.h"
#include "Traverse.h"
#include "ElInfo.h"

namespace AMDiS {

  /**
   * \ingroup Adaption
   * 
   * \brief
   * 
   */
  class ConditionalMarker : public Marker
  {
  public:
43
    /// Constructor.
Thomas Witkowski's avatar
Thomas Witkowski committed
44
    ConditionalMarker(std::string name,
45
46
47
48
49
50
51
52
		      int row,
		      Marker *decoratedMarker,
		      int globalCoarseGridLevel,
		      int localCoarseGridLevel)
      : Marker(name, row), 
	decoratedMarker_(decoratedMarker),
	globalCoarseGridLevel_(globalCoarseGridLevel),    
	localCoarseGridLevel_(localCoarseGridLevel)
53
    {}
54

55
56
57
58
    /// Implementation of MarkScal::initMarking().
    virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh) 
    {
      if (decoratedMarker_) 
59
	decoratedMarker_->initMarking(adaptInfo, mesh);
60
    }
61

62
63
64
    virtual void finishMarking(AdaptInfo *adaptInfo) 
    {
      if (decoratedMarker_) {
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	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);
      }
79
    }
80

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

85
      if (decoratedMarker_) {
86
87
88
89
	PartitionElementData *elData = 
	  dynamic_cast<PartitionElementData*>(elInfo->getElement()->
					      getElementData(PARTITION_ED));

90
	TEST_EXIT_DBG(elData)("no partition data\n");
91
92
93

	decoratedMarker_->markElement(adaptInfo, elInfo);

94
	if (elData->getPartitionStatus() == OUT) {
95
	  Element *element = elInfo->getElement();
Thomas Witkowski's avatar
Thomas Witkowski committed
96
97
	  if (element->getMark() > 0)
	    element->setMark(0);	  
98
99
100
101
102
103
104
	}

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

Thomas Witkowski's avatar
Thomas Witkowski committed
105
	if (elData->getLevel() + elInfo->getElement()->getMark() < minLevel)
106
107
	  elInfo->getElement()->setMark(-(elData->getLevel() - minLevel));
      }
108
    }
109
110
111
112
113
114
115
116
117
118

  protected:
    Marker *decoratedMarker_;
    int globalCoarseGridLevel_;
    int localCoarseGridLevel_;
  };

}

#endif