From ce3ea44057351a8d20ab95a44f611d69b7a7c9e5 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Mon, 28 Mar 2011 14:47:11 +0000 Subject: [PATCH] Fixed bug in parallel code for coupled problems. --- AMDiS/src/DOFMatrix.cc | 4 ++- AMDiS/src/parallel/MeshDistributor.cc | 44 ++++++++++++++++++--------- AMDiS/src/parallel/MeshDistributor.h | 9 +++++- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/AMDiS/src/DOFMatrix.cc b/AMDiS/src/DOFMatrix.cc index 11faf18c..6b19f136 100644 --- a/AMDiS/src/DOFMatrix.cc +++ b/AMDiS/src/DOFMatrix.cc @@ -183,7 +183,9 @@ namespace AMDiS { { FUNCNAME("DOFMatrix::addElementMatrix()"); - TEST_EXIT_DBG(inserter)("DOFMatrix is not in insertion mode"); + TEST_EXIT_DBG(inserter)("DOFMatrix is not in insertion mode\n"); + TEST_EXIT_DBG(rowFeSpace)("Have now rowFeSpace!\n"); + inserter_type &ins= *inserter; // === Get indices mapping from local to global matrix indices. === diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc index 3b1496c6..d85c82c6 100644 --- a/AMDiS/src/parallel/MeshDistributor.cc +++ b/AMDiS/src/parallel/MeshDistributor.cc @@ -62,6 +62,7 @@ namespace AMDiS { MeshDistributor::MeshDistributor() : probStat(0), + initialized(false), name("parallel"), feSpace(NULL), mesh(NULL), @@ -163,6 +164,8 @@ namespace AMDiS { #if (DEBUG != 0) ParallelDebug::writeDebugFile(*this, debugOutputDir + "mpi-dbg", "dat"); #endif + + initialized = true; return; } @@ -320,6 +323,8 @@ namespace AMDiS { // === Remove periodic boundary conditions in sequential problem definition. === removePeriodicBoundaryConditions(); + + initialized = true; } @@ -412,6 +417,12 @@ namespace AMDiS { } probStat.push_back(probVec); + + // If the mesh distributor is already initialized, don't forgett to set rank + // DOFs object to the matrices and vectors of the added stationary problem. + + if (initialized) + setRankDofs(probVec); } @@ -623,22 +634,27 @@ namespace AMDiS { } - void MeshDistributor::setRankDofs() + void MeshDistributor::setRankDofs(ProblemVec *probVec) { - for (unsigned int i = 0; i < probStat.size(); i++) { - int nComponents = probStat[i]->getNumComponents(); - for (int j = 0; j < nComponents; j++) { - for (int k = 0; k < nComponents; k++) - if (probStat[i]->getSystemMatrix(j, k)) - probStat[i]->getSystemMatrix(j, k)->setRankDofs(isRankDof); + int nComponents = probVec->getNumComponents(); + for (int i = 0; i < nComponents; i++) { + for (int j = 0; j < nComponents; j++) + if (probVec->getSystemMatrix(i, j)) + probVec->getSystemMatrix(i, j)->setRankDofs(isRankDof); + + TEST_EXIT_DBG(probVec->getRhs()->getDOFVector(i))("No RHS vector!\n"); + TEST_EXIT_DBG(probVec->getSolution()->getDOFVector(i))("No solution vector!\n"); + + probVec->getRhs()->getDOFVector(i)->setRankDofs(isRankDof); + probVec->getSolution()->getDOFVector(i)->setRankDofs(isRankDof); + } + } - TEST_EXIT_DBG(probStat[i]->getRhs()->getDOFVector(j))("No RHS vector!\n"); - TEST_EXIT_DBG(probStat[i]->getSolution()->getDOFVector(j))("No solution vector!\n"); - - probStat[i]->getRhs()->getDOFVector(j)->setRankDofs(isRankDof); - probStat[i]->getSolution()->getDOFVector(j)->setRankDofs(isRankDof); - } - } + + void MeshDistributor::setRankDofs() + { + for (unsigned int i = 0; i < probStat.size(); i++) + setRankDofs(probStat[i]); } diff --git a/AMDiS/src/parallel/MeshDistributor.h b/AMDiS/src/parallel/MeshDistributor.h index d21771ad..07b16877 100644 --- a/AMDiS/src/parallel/MeshDistributor.h +++ b/AMDiS/src/parallel/MeshDistributor.h @@ -346,6 +346,10 @@ namespace AMDiS { */ void repartitionMesh(); + /// Sets \ref isRankDof to all matrices and rhs vectors in a given + /// stationary problem. + void setRankDofs(ProblemVec *probVec); + /// Sets \ref isRankDof to all matrices and rhs vectors in all stationary problems. void setRankDofs(); @@ -419,9 +423,12 @@ namespace AMDiS { } protected: - /// + /// List of all stationary problems that are managed by this mesh distributor. vector<ProblemVec*> probStat; + /// If true, the mesh distributor is already initialized; + bool initialized; + /// The rank of the current process. int mpiRank; -- GitLab