Commit 534cc429 authored by Thomas Witkowski's avatar Thomas Witkowski

Merged with parallelization branch.

parent b49c9c79
......@@ -13,7 +13,7 @@ libamdis_la_CXXFLAGS =
if USE_PARALLEL_AMDIS
PARALLEL_AMDIS_SOURCES = \
$(PARALLEL_DIR)/ConditionalEstimator.h $(PARALLEL_DIR)/ConditionalEstimator.cc \
$(PARALLEL_DIR)/ConditionalMarker.h \
$(PARALLEL_DIR)/ConditionalMarker.h \ $(PARALLEL_DIR)/ConditionalMarker.cc \
$(PARALLEL_DIR)/ParallelError.h $(PARALLEL_DIR)/ParallelError.hh \
$(PARALLEL_DIR)/ParallelProblem.h $(PARALLEL_DIR)/ParallelProblem.cc \
$(PARALLEL_DIR)/ParMetisPartitioner.h $(PARALLEL_DIR)/ParMetisPartitioner.cc \
......
......@@ -78,7 +78,8 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ParallelDomainBase.h \
$(PARALLEL_DIR)/ParallelDomainVec.cc \
$(PARALLEL_DIR)/ConditionalEstimator.h \
$(PARALLEL_DIR)/ConditionalEstimator.cc \
$(PARALLEL_DIR)/ConditionalMarker.h \
$(PARALLEL_DIR)/ConditionalMarker.h \ \
$(PARALLEL_DIR)/ConditionalMarker.cc \
$(PARALLEL_DIR)/ParallelError.h \
$(PARALLEL_DIR)/ParallelError.hh \
$(PARALLEL_DIR)/ParallelProblem.h \
......@@ -167,7 +168,7 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ParallelDomainBase.h \
$(SOURCE_DIR)/Estimator.cc $(SOURCE_DIR)/FiniteElemSpace.h \
$(SOURCE_DIR)/FixVec.h $(SOURCE_DIR)/FixVec.hh \
$(SOURCE_DIR)/FixVecConvert.h $(SOURCE_DIR)/Flag.h \
$(SOURCE_DIR)/Global.h $(SOURCE_DIR)/UmfPackSolver.h \ \
$(SOURCE_DIR)/Global.h $(SOURCE_DIR)/UmfPackSolver.h \
$(SOURCE_DIR)/UmfPackSolver.hh $(SOURCE_DIR)/Lagrange.h \
$(SOURCE_DIR)/Line.h $(SOURCE_DIR)/MacroElement.h \
$(SOURCE_DIR)/MacroWriter.h $(SOURCE_DIR)/Markings.h \
......@@ -232,6 +233,7 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ParallelDomainBase.h \
@USE_PARALLEL_AMDIS_FALSE@am__objects_2 = $(am__objects_1)
@USE_PARALLEL_AMDIS_TRUE@am__objects_2 = \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ConditionalEstimator.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ConditionalMarker.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ParallelProblem.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ParMetisPartitioner.lo \
@USE_PARALLEL_AMDIS_TRUE@ $(am__objects_1)
......@@ -459,7 +461,8 @@ libamdis_la_CXXFLAGS = $(am__append_1) $(am__append_3) $(am__append_5) \
@USE_PARALLEL_AMDIS_FALSE@PARALLEL_AMDIS_SOURCES = $(am__append_2)
@USE_PARALLEL_AMDIS_TRUE@PARALLEL_AMDIS_SOURCES = $(PARALLEL_DIR)/ConditionalEstimator.h \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ConditionalEstimator.cc \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ConditionalMarker.h \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ConditionalMarker.h \ \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ConditionalMarker.cc \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ParallelError.h \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ParallelError.hh \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ParallelProblem.h \
......@@ -734,6 +737,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-CoarseningManager3d.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ComponentTraverseInfo.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ConditionalEstimator.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ConditionalMarker.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-CreatorMap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DOFAdmin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DOFIndexed.Plo@am__quote@
......@@ -865,6 +869,13 @@ libamdis_la-ConditionalEstimator.lo: $(PARALLEL_DIR)/ConditionalEstimator.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ConditionalEstimator.lo `test -f '$(PARALLEL_DIR)/ConditionalEstimator.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ConditionalEstimator.cc
libamdis_la-ConditionalMarker.lo: $(PARALLEL_DIR)/ConditionalMarker.cc
@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ConditionalMarker.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ConditionalMarker.Tpo" -c -o libamdis_la-ConditionalMarker.lo `test -f '$(PARALLEL_DIR)/ConditionalMarker.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ConditionalMarker.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ConditionalMarker.Tpo" "$(DEPDIR)/libamdis_la-ConditionalMarker.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ConditionalMarker.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(PARALLEL_DIR)/ConditionalMarker.cc' object='libamdis_la-ConditionalMarker.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ConditionalMarker.lo `test -f '$(PARALLEL_DIR)/ConditionalMarker.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ConditionalMarker.cc
libamdis_la-ParallelProblem.lo: $(PARALLEL_DIR)/ParallelProblem.cc
@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-ParallelProblem.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ParallelProblem.Tpo" -c -o libamdis_la-ParallelProblem.lo `test -f '$(PARALLEL_DIR)/ParallelProblem.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ParallelProblem.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ParallelProblem.Tpo" "$(DEPDIR)/libamdis_la-ParallelProblem.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ParallelProblem.Tpo"; exit 1; fi
......
......@@ -7,14 +7,32 @@
namespace AMDiS {
ConditionalEstimator::ConditionalEstimator(Estimator* decorated)
: decoratedEstimator_(decorated),
elementCount_(0),
row_(decorated ? decorated->getRow() : 0)
{
FUNCNAME("ConditionalEstimator::ConditionalEstimator(Estimator* decorated)");
if (decorated!=NULL) {
name = decorated->getName();
int swap;
int retVal =
Parameters::getGlobalParameter(0, name + "->estimate outer", "%d", &swap);
if (retVal > 0)
estimateOut = (bool)swap;
else
estimateOut = false;
}
}
double ConditionalEstimator::estimate(double ts)
{
if (decoratedEstimator_) {
double partition_sum = 0.0;
elementCount_ = 0;
decoratedEstimator_->init(ts);
mesh = decoratedEstimator_->getMesh();
......@@ -30,21 +48,27 @@ namespace AMDiS {
TEST_EXIT_DBG(elData)("no partition data on leaf element %d (rank %d)\n",
elInfo->getElement()->getIndex(),
MPI::COMM_WORLD.Get_rank());
//if(status == IN || status == OVERLAP) {
PartitionStatus status = elData->getPartitionStatus();
if (status == IN || status == OVERLAP || (estimateOut && status==OUT))
decoratedEstimator_->estimateElement(elInfo);
//} else {
// elInfo->getElement()->setMark(0);
//}
else
elInfo->getElement()->setMark(0);
elInfo = stack.traverseNext(elInfo);
}
elInfo = stack.traverseFirst(mesh, -1, traverseFlag);
while (elInfo) {
//if(status == IN) {
PartitionElementData *elData = dynamic_cast<PartitionElementData*>
(elInfo->getElement()->getElementData(PARTITION_ED));
PartitionStatus status = elData->getPartitionStatus();
if (status == IN || status==OVERLAP || (estimateOut && status==OUT)) {
elementCount_++;
partition_sum += elInfo->getElement()->getEstimation(row_);
//}
}
elInfo = stack.traverseNext(elInfo);
}
......
......@@ -4,16 +4,16 @@
// == ==
// ============================================================================
// == ==
// == TU Dresden ==
// == crystal growth group ==
// == ==
// == Institut fr Wissenschaftliches Rechnen ==
// == Zellescher Weg 12-14 ==
// == 01069 Dresden ==
// == Stiftung caesar ==
// == Ludwig-Erhard-Allee 2 ==
// == 53175 Bonn ==
// == germany ==
// == ==
// ============================================================================
// == ==
// == https://gforge.zih.tu-dresden.de/projects/amdis/ ==
// == http://www.caesar.de/cg/AMDiS ==
// == ==
// ============================================================================
......@@ -39,11 +39,11 @@ namespace AMDiS {
class ConditionalEstimator : public Estimator
{
public:
ConditionalEstimator(Estimator *decorated)
: decoratedEstimator_(decorated),
elementCount_(0),
row_(decorated ? decorated->getRow() : 0)
{}
/**
* Reads the estimateOuter parameter. default value is false!
* (i.e.: the ouer part is not estimated)
*/
ConditionalEstimator(Estimator *decorated);
double estimate(double timestep);
......@@ -63,6 +63,8 @@ namespace AMDiS {
int elementCount_;
int row_;
bool estimateOut;
};
}
......
#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));
}
}
}
......@@ -4,16 +4,16 @@
// == ==
// ============================================================================
// == ==
// == TU Dresden ==
// == crystal growth group ==
// == ==
// == Institut fr Wissenschaftliches Rechnen ==
// == Zellescher Weg 12-14 ==
// == 01069 Dresden ==
// == Stiftung caesar ==
// == Ludwig-Erhard-Allee 2 ==
// == 53175 Bonn ==
// == germany ==
// == ==
// ============================================================================
// == ==
// == https://gforge.zih.tu-dresden.de/projects/amdis/ ==
// == http://www.caesar.de/cg/AMDiS ==
// == ==
// ============================================================================
......@@ -41,76 +41,25 @@ namespace AMDiS {
{
public:
/// Constructor.
ConditionalMarker(std::string name,
ConditionalMarker(const std::string name,
int row,
Marker *decoratedMarker,
int globalCoarseGridLevel,
int localCoarseGridLevel)
: Marker(name, row),
decoratedMarker_(decoratedMarker),
globalCoarseGridLevel_(globalCoarseGridLevel),
localCoarseGridLevel_(localCoarseGridLevel)
{}
int localCoarseGridLevel);
/// Implementation of MarkScal::initMarking().
virtual void initMarking(AdaptInfo *adaptInfo, Mesh *mesh)
{
if (decoratedMarker_)
decoratedMarker_->initMarking(adaptInfo, mesh);
}
virtual void initMarking(AdaptInfo *adaptInfo, Mesh *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);
}
}
virtual void finishMarking(AdaptInfo *adaptInfo);
void 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 (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));
}
}
void markElement(AdaptInfo *adaptInfo, ElInfo *elInfo);
protected:
Marker *decoratedMarker_;
int globalCoarseGridLevel_;
int localCoarseGridLevel_;
bool markOuter;
};
}
......
......@@ -117,6 +117,12 @@ namespace AMDiS {
return elMarkCoarsen;
}
// Returns \ref name of the Marker
inline std::string getName() const
{
return name;
}
/// Creates a scalr marker depending on the strategy set in parameters.
static Marker *createMarker(std::string name, int row_);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment