Commit 41774d49 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Update due to small bug in Residualestimator

parent 44e4efd1
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace AMDiS { namespace AMDiS {
ParMetisMesh::ParMetisMesh(Mesh *mesh, MPI::Comm *comm) ParMetisMesh::ParMetisMesh(Mesh *mesh, MPI::Comm *comm)
: numElements_(0), : nElements(0),
mpiComm(comm) mpiComm(comm)
{ {
FUNCNAME("ParMetisMesh::ParMetisMesh()"); FUNCNAME("ParMetisMesh::ParMetisMesh()");
...@@ -45,19 +45,19 @@ namespace AMDiS { ...@@ -45,19 +45,19 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
numElements_ = elementCounter; nElements = elementCounter;
TEST_EXIT(numElements_ > 0)("no elements in ParMETIS mesh\n"); TEST_EXIT(nElements > 0)("no elements in ParMETIS mesh\n");
// allocate memory // allocate memory
eptr_ = GET_MEMORY(int, numElements_ + 1); eptr_ = GET_MEMORY(int, nElements + 1);
eind_ = GET_MEMORY(int, numElements_ * (dim_ + 1)); eind_ = GET_MEMORY(int, nElements * (dim_ + 1));
elmdist_ = GET_MEMORY(int, mpiSize + 1); elmdist = GET_MEMORY(int, mpiSize + 1);
elem_p2a_ = GET_MEMORY(int, numElements_); elem_p2a_ = GET_MEMORY(int, nElements);
if (dim_ == dow) { if (dim_ == dow) {
xyz_ = GET_MEMORY(float, numElements_ * dim_); xyz_ = GET_MEMORY(float, nElements * dim_);
} else { } else {
xyz_ = NULL; xyz_ = NULL;
} }
...@@ -69,11 +69,11 @@ namespace AMDiS { ...@@ -69,11 +69,11 @@ namespace AMDiS {
float *ptr_xyz = xyz_; float *ptr_xyz = xyz_;
// gather element numbers and create elmdist // gather element numbers and create elmdist
mpiComm->Allgather(&numElements_, 1, MPI_INT, elmdist_ + 1, 1, MPI_INT); mpiComm->Allgather(&nElements, 1, MPI_INT, elmdist + 1, 1, MPI_INT);
elmdist_[0] = 0; elmdist[0] = 0;
for (int i = 2; i < mpiSize + 1; i++) { for (int i = 2; i < mpiSize + 1; i++) {
elmdist_[i] += elmdist_[i - 1]; elmdist[i] += elmdist[i - 1];
} }
// traverse mesh and fill distributed ParMETIS data // traverse mesh and fill distributed ParMETIS data
...@@ -130,19 +130,19 @@ namespace AMDiS { ...@@ -130,19 +130,19 @@ namespace AMDiS {
ParMetisMesh::~ParMetisMesh() ParMetisMesh::~ParMetisMesh()
{ {
if (eptr_) if (eptr_)
FREE_MEMORY(eptr_, int, numElements_ + 1); FREE_MEMORY(eptr_, int, nElements + 1);
if (eind_) if (eind_)
FREE_MEMORY(eind_, int, numElements_ * (dim_ + 1)); FREE_MEMORY(eind_, int, nElements * (dim_ + 1));
if (elmdist_) if (elmdist)
FREE_MEMORY(elmdist_, int, mpiComm->Get_size() + 1); FREE_MEMORY(elmdist, int, mpiComm->Get_size() + 1);
if (xyz_) if (xyz_)
FREE_MEMORY(xyz_, float, numElements_ * dim_); FREE_MEMORY(xyz_, float, nElements * dim_);
if (elem_p2a_) if (elem_p2a_)
FREE_MEMORY(elem_p2a_, int, numElements_); FREE_MEMORY(elem_p2a_, int, nElements);
} }
ParMetisGraph::ParMetisGraph(ParMetisMesh *parMetisMesh, ParMetisGraph::ParMetisGraph(ParMetisMesh *parMetisMesh,
...@@ -198,7 +198,6 @@ namespace AMDiS { ...@@ -198,7 +198,6 @@ namespace AMDiS {
elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_LEAF_EL); elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_LEAF_EL);
while (elInfo) { while (elInfo) {
Element *element = elInfo->getElement(); Element *element = elInfo->getElement();
//int index = element->getIndex();
TEST_EXIT(element->getElementData(PARTITION_ED) == NULL) TEST_EXIT(element->getElementData(PARTITION_ED) == NULL)
("mesh already partitioned\n"); ("mesh already partitioned\n");
......
...@@ -81,7 +81,7 @@ namespace AMDiS { ...@@ -81,7 +81,7 @@ namespace AMDiS {
} }
inline int *getElementDist() { inline int *getElementDist() {
return elmdist_; return elmdist;
} }
inline int getDim() { inline int getDim() {
...@@ -93,7 +93,7 @@ namespace AMDiS { ...@@ -93,7 +93,7 @@ namespace AMDiS {
} }
inline int getNumElements() { inline int getNumElements() {
return numElements_; return nElements;
} }
protected: protected:
...@@ -101,13 +101,21 @@ namespace AMDiS { ...@@ -101,13 +101,21 @@ namespace AMDiS {
int *eind_; int *eind_;
int *elmdist_; /* \brief
* Array that specifies the distribution of the mesh elements.
*
* elmdist[0] = 0;
* elmdist[1] = number of elements of proc 0;
* elmdist[2] = elmdist[1] + number of elements of proc 1;
* ...
*/
int *elmdist;
int dim_; int dim_;
float *xyz_; float *xyz_;
int numElements_; int nElements;
std::map<int, int> elem_a2p_; std::map<int, int> elem_a2p_;
...@@ -131,11 +139,11 @@ namespace AMDiS { ...@@ -131,11 +139,11 @@ namespace AMDiS {
inline int *getXAdj() { inline int *getXAdj() {
return xadj_; return xadj_;
}; }
inline int *getAdjncy() { inline int *getAdjncy() {
return adjncy_; return adjncy_;
}; }
protected: protected:
ParMetisMesh *parMetisMesh_; ParMetisMesh *parMetisMesh_;
...@@ -152,7 +160,7 @@ namespace AMDiS { ...@@ -152,7 +160,7 @@ namespace AMDiS {
: mesh_(mesh), : mesh_(mesh),
mpiComm(comm), mpiComm(comm),
parMetisMesh_(NULL) parMetisMesh_(NULL)
{}; {}
void partition(std::map<int, double> *elemWeights, void partition(std::map<int, double> *elemWeights,
PartitionMode mode = INITIAL, PartitionMode mode = INITIAL,
...@@ -163,6 +171,10 @@ namespace AMDiS { ...@@ -163,6 +171,10 @@ namespace AMDiS {
void fillLeafPartitionVec(std::map<int, int> *coarseVec, void fillLeafPartitionVec(std::map<int, int> *coarseVec,
std::map<int, int> *fineVec); std::map<int, int> *fineVec);
/* \brief
* Creates an initial paritioning of the AMDiS mesh by seting the partition status
* of all elements to either IN or UNDEFINED.
*/
void createPartitionData(); void createPartitionData();
void deletePartitionData(); void deletePartitionData();
......
...@@ -226,7 +226,7 @@ namespace AMDiS { ...@@ -226,7 +226,7 @@ namespace AMDiS {
TEST_EXIT(localCoarseGridLevel_ >= globalCoarseGridLevel_) TEST_EXIT(localCoarseGridLevel_ >= globalCoarseGridLevel_)
("local coarse grid level < global coarse grid level\n"); ("local coarse grid level < global coarse grid level\n");
partitioner_ = NEW ParMetisPartitioner(mesh, &mpiComm); partitioner = NEW ParMetisPartitioner(mesh, &mpiComm);
GET_PARAMETER(0, name_ + "->adaptive thresholds", "%d", GET_PARAMETER(0, name_ + "->adaptive thresholds", "%d",
&adaptiveThresholds_); &adaptiveThresholds_);
...@@ -251,7 +251,7 @@ namespace AMDiS { ...@@ -251,7 +251,7 @@ namespace AMDiS {
ParallelProblem::~ParallelProblem() ParallelProblem::~ParallelProblem()
{ {
DELETE partitioner_; DELETE partitioner;
} }
bool ParallelProblem::doPartitioning(AdaptInfo *adaptInfo, double localWeightSum) bool ParallelProblem::doPartitioning(AdaptInfo *adaptInfo, double localWeightSum)
...@@ -262,8 +262,7 @@ namespace AMDiS { ...@@ -262,8 +262,7 @@ namespace AMDiS {
int *partArray = GET_MEMORY(int, mpiSize); int *partArray = GET_MEMORY(int, mpiSize);
int part = 0; int part = 0;
mpiComm.Gather(&localWeightSum, 1, MPI_DOUBLE, mpiComm.Gather(&localWeightSum, 1, MPI_DOUBLE, weightSum, 1, MPI_DOUBLE, 0);
weightSum, 1, MPI_DOUBLE, 0);
if (mpiRank == 0) { if (mpiRank == 0) {
...@@ -332,14 +331,14 @@ namespace AMDiS { ...@@ -332,14 +331,14 @@ namespace AMDiS {
static bool initial = true; static bool initial = true;
if (initial) { if (initial) {
initial = false; initial = false;
partitioner_->fillCoarsePartitionVec(&oldPartitionVec); partitioner->fillCoarsePartitionVec(&oldPartitionVec);
partitioner_->partition(&elemWeights_, INITIAL); partitioner->partition(&elemWeights_, INITIAL);
} else { } else {
oldPartitionVec = partitionVec; oldPartitionVec = partitionVec;
partitioner_->partition(&elemWeights_, ADAPTIVE_REPART, 100.0 /*0.000001*/); partitioner->partition(&elemWeights_, ADAPTIVE_REPART, 100.0 /*0.000001*/);
} }
partitioner_->fillCoarsePartitionVec(&partitionVec); partitioner->fillCoarsePartitionVec(&partitionVec);
} }
void ParallelProblem::refineOverlap(AdaptInfo *adaptInfo) void ParallelProblem::refineOverlap(AdaptInfo *adaptInfo)
...@@ -749,8 +748,8 @@ namespace AMDiS { ...@@ -749,8 +748,8 @@ namespace AMDiS {
void ParallelProblem::exchangeDOFVector(AdaptInfo *adaptInfo, void ParallelProblem::exchangeDOFVector(AdaptInfo *adaptInfo,
DOFVector<double> *values) DOFVector<double> *values)
{ {
partitioner_->fillLeafPartitionVec(&oldPartitionVec, &oldPartitionVec); partitioner->fillLeafPartitionVec(&oldPartitionVec, &oldPartitionVec);
partitioner_->fillLeafPartitionVec(&partitionVec, &partitionVec); partitioner->fillLeafPartitionVec(&partitionVec, &partitionVec);
// === get send and recieve orders === // === get send and recieve orders ===
std::vector<std::vector<DegreeOfFreedom> > sendOrder; std::vector<std::vector<DegreeOfFreedom> > sendOrder;
...@@ -1353,7 +1352,7 @@ namespace AMDiS { ...@@ -1353,7 +1352,7 @@ namespace AMDiS {
if (mpiSize > 1) { if (mpiSize > 1) {
clock_t partitioningStart = clock(); clock_t partitioningStart = clock();
partitioner_->createPartitionData(); partitioner->createPartitionData();
setElemWeights(adaptInfo); setElemWeights(adaptInfo);
partitionMesh(adaptInfo); partitionMesh(adaptInfo);
...@@ -1388,8 +1387,7 @@ namespace AMDiS { ...@@ -1388,8 +1387,7 @@ namespace AMDiS {
if (mpiRank == 0) { if (mpiRank == 0) {
clock_t partitioningEnd = clock(); clock_t partitioningEnd = clock();
partitioningTime = TIME_USED(partitioningStart, partitioningTime = TIME_USED(partitioningStart, partitioningEnd);
partitioningEnd);
computationStart = partitioningEnd; computationStart = partitioningEnd;
} }
...@@ -1416,7 +1414,7 @@ namespace AMDiS { ...@@ -1416,7 +1414,7 @@ namespace AMDiS {
if (!timeIF_) if (!timeIF_)
problem->writeFiles(adaptInfo, true); problem->writeFiles(adaptInfo, true);
partitioner_->deletePartitionData(); partitioner->deletePartitionData();
if (!usersEstimator) if (!usersEstimator)
DELETE problem->getEstimator(); DELETE problem->getEstimator();
...@@ -1531,7 +1529,7 @@ namespace AMDiS { ...@@ -1531,7 +1529,7 @@ namespace AMDiS {
FUNCNAME("ParallelProblem::initParallelization()"); FUNCNAME("ParallelProblem::initParallelization()");
if (mpiSize > 1) { if (mpiSize > 1) {
partitioner_->createPartitionData(); partitioner->createPartitionData();
setElemWeights(adaptInfo); setElemWeights(adaptInfo);
partitionMesh(adaptInfo); partitionMesh(adaptInfo);
...@@ -1594,7 +1592,7 @@ namespace AMDiS { ...@@ -1594,7 +1592,7 @@ namespace AMDiS {
if (!timeIF_) if (!timeIF_)
problem->writeFiles(adaptInfo, true); problem->writeFiles(adaptInfo, true);
partitioner_->deletePartitionData(); partitioner->deletePartitionData();
for (int i = 0; i < nComponents; i++) { for (int i = 0; i < nComponents; i++) {
if (static_cast<int>(usersEstimator.size()) == nComponents) if (static_cast<int>(usersEstimator.size()) == nComponents)
......
...@@ -63,7 +63,7 @@ namespace AMDiS { ...@@ -63,7 +63,7 @@ namespace AMDiS {
ProblemIterationInterface *iterationIF, ProblemIterationInterface *iterationIF,
ProblemTimeInterface *timeIF); ProblemTimeInterface *timeIF);
virtual ~ParallelProblemBase() {}; virtual ~ParallelProblemBase() {}
/** \brief /** \brief
* Must return true, if a new partitioning of the domain (due to unbalanced * Must return true, if a new partitioning of the domain (due to unbalanced
...@@ -104,53 +104,47 @@ namespace AMDiS { ...@@ -104,53 +104,47 @@ namespace AMDiS {
virtual void exitParallelization(AdaptInfo *adaptInfo); virtual void exitParallelization(AdaptInfo *adaptInfo);
virtual void setTime(AdaptInfo *adaptInfo) virtual void setTime(AdaptInfo *adaptInfo) {
{
if (timeIF_) if (timeIF_)
timeIF_->setTime(adaptInfo); timeIF_->setTime(adaptInfo);
}; }
virtual void initTimestep(AdaptInfo *adaptInfo) virtual void initTimestep(AdaptInfo *adaptInfo) {
{
if (timeIF_) if (timeIF_)
timeIF_->initTimestep(adaptInfo); timeIF_->initTimestep(adaptInfo);
}; }
virtual void closeTimestep(AdaptInfo *adaptInfo); virtual void closeTimestep(AdaptInfo *adaptInfo);
virtual void solveInitialProblem(AdaptInfo *adaptInfo) virtual void solveInitialProblem(AdaptInfo *adaptInfo) {
{
if (timeIF_) if (timeIF_)
timeIF_->solveInitialProblem(adaptInfo); timeIF_->solveInitialProblem(adaptInfo);
}; }
virtual void transferInitialSolution(AdaptInfo *adaptInfo) virtual void transferInitialSolution(AdaptInfo *adaptInfo) {
{
if (timeIF_) if (timeIF_)
timeIF_->transferInitialSolution(adaptInfo); timeIF_->transferInitialSolution(adaptInfo);
}; }
virtual void beginIteration(AdaptInfo *adaptInfo) virtual void beginIteration(AdaptInfo *adaptInfo) {
{
iterationIF_->beginIteration(adaptInfo); iterationIF_->beginIteration(adaptInfo);
}; }
virtual Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION); virtual Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION);
virtual void endIteration(AdaptInfo *adaptInfo) { virtual void endIteration(AdaptInfo *adaptInfo) {
iterationIF_->endIteration(adaptInfo); iterationIF_->endIteration(adaptInfo);
}; }
virtual void startDelayedTimestepCalculation() {}; virtual void startDelayedTimestepCalculation() {}
virtual bool existsDelayedCalculation() { virtual bool existsDelayedCalculation() {
return false; return false;
}; }
MPI::Intracomm* getMpiComm() { MPI::Intracomm* getMpiComm() {
return &mpiComm; return &mpiComm;
}; }
bool getDebugServerProcess() { bool getDebugServerProcess() {
return debugServerProcess; return debugServerProcess;
...@@ -260,15 +254,15 @@ namespace AMDiS { ...@@ -260,15 +254,15 @@ namespace AMDiS {
void setRepartitionSteps(int steps) { void setRepartitionSteps(int steps) {
repartitionSteps_ = steps; repartitionSteps_ = steps;
}; }
void puEveryTimestep(bool pu) { void puEveryTimestep(bool pu) {
puEveryTimestep_ = pu; puEveryTimestep_ = pu;
}; }
void addDOFVector(DOFVector<double> *vec) { void addDOFVector(DOFVector<double> *vec) {
dofVectors_.push_back(vec); dofVectors_.push_back(vec);
}; }
/** \brief /** \brief
* Every process creates the mesh structure code of its mesh, and all * Every process creates the mesh structure code of its mesh, and all
...@@ -278,44 +272,33 @@ namespace AMDiS { ...@@ -278,44 +272,33 @@ namespace AMDiS {
static bool writeElement(ElInfo *elInfo); static bool writeElement(ElInfo *elInfo);
virtual void startDebugServer() {}; virtual void startDebugServer() {}
virtual void serialize(std::ostream&) {}; virtual void serialize(std::ostream&) {}
virtual void deserialize(std::istream&) {}; virtual void deserialize(std::istream&) {}
protected: protected:
/** \brief ///
*
*/
double errors2map(std::map<int, double> &errMap, int comp, bool add); double errors2map(std::map<int, double> &errMap, int comp, bool add);
///
std::vector<int> iList; std::vector<int> iList;
/** \brief ///
*
*/
std::string name_; std::string name_;
/** \brief /// Mesh of the problem.
* Mesh of the problem.
*/
Mesh *mesh; Mesh *mesh;
/** \brief ///
*
*/
RefinementManager *refinementManager; RefinementManager *refinementManager;
/** \brief ///
*
*/
CoarseningManager *coarseningManager; CoarseningManager *coarseningManager;
/** \brief /// Pointer to the paritioner which is used to devide a mesh into partitions.
* Pointer to the paritioner which is used to devide a mesh into partitions. ParMetisPartitioner *partitioner;
*/
ParMetisPartitioner *partitioner_;
/** \brief /** \brief
* Stores to every coarse element index the number of the partition it * Stores to every coarse element index the number of the partition it
...@@ -329,24 +312,16 @@ namespace AMDiS { ...@@ -329,24 +312,16 @@ namespace AMDiS {
*/ */
std::map<int, int> oldPartitionVec; std::map<int, int> oldPartitionVec;
/** \brief ///
*
*/
std::map<int, double> elemWeights_; std::map<int, double> elemWeights_;
/** \brief /// Stores to every element the set of partitions it corresponds to.
* Stores to every element the set of partitions it corresponds to.
*/
std::map<Element*, std::set<int> > elementPartitions_; std::map<Element*, std::set<int> > elementPartitions_;
/** \brief /// Stores to every DOF the set of partitions it corresponds to.
* Stores to every DOF the set of partitions it corresponds to.
*/
std::map<DegreeOfFreedom, std::set<int> > vertexPartitions; std::map<DegreeOfFreedom, std::set<int> > vertexPartitions;
/** \brief ///
*
*/
int repartitionSteps_; int repartitionSteps_;
/** \brief /** \brief
...@@ -418,7 +393,7 @@ namespace AMDiS { ...@@ -418,7 +393,7 @@ namespace AMDiS {
* *
*/ */
double maxLowerTH_; double maxLowerTH_;
}; }