// ============================================================================ // == == // == 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: /// Constructor. ConditionalMarker(const std::string name, int row, Marker *decoratedMarker, int globalCoarseGridLevel, int localCoarseGridLevel) : Marker(name, row), decoratedMarker_(decoratedMarker), globalCoarseGridLevel_(globalCoarseGridLevel), localCoarseGridLevel_(localCoarseGridLevel) {} /// Implementation of MarkScal::initMarking(). virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh) { if (decoratedMarker_) decoratedMarker_->initMarking(adaptInfo, mesh); } virtual void 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 markElement(AdaptInfo *adaptInfo, ElInfo *elInfo) { FUNCNAME("ConditionalMarker::markElement()"); if (decoratedMarker_) { PartitionElementData *elData = dynamic_cast(elInfo->getElement()-> getElementData(PARTITION_ED)); TEST_EXIT_DBG(elData)("no partition data\n"); decoratedMarker_->markElement(adaptInfo, elInfo); if (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)); } } } protected: Marker *decoratedMarker_; int globalCoarseGridLevel_; int localCoarseGridLevel_; }; } #endif