From 56139ea64dceb05ac4d3ee90d78fa56c9eb44c85 Mon Sep 17 00:00:00 2001 From: Thomas Witkowski <thomas.witkowski@gmx.de> Date: Tue, 23 Oct 2012 11:10:18 +0000 Subject: [PATCH] bo eh --- .../src/parallel/ParallelCoarseSpaceMatVec.cc | 6 +--- AMDiS/src/parallel/ParallelDofMapping.cc | 14 ++++++++- AMDiS/src/parallel/ParallelDofMapping.h | 8 +++++ AMDiS/src/parallel/PetscSolver.cc | 29 ++++++++++--------- AMDiS/src/parallel/PetscSolver.h | 5 ++-- AMDiS/src/parallel/PetscSolverFeti.cc | 12 ++++++-- 6 files changed, 51 insertions(+), 23 deletions(-) diff --git a/AMDiS/src/parallel/ParallelCoarseSpaceMatVec.cc b/AMDiS/src/parallel/ParallelCoarseSpaceMatVec.cc index 1c703b38..3fbc4cc0 100644 --- a/AMDiS/src/parallel/ParallelCoarseSpaceMatVec.cc +++ b/AMDiS/src/parallel/ParallelCoarseSpaceMatVec.cc @@ -114,11 +114,7 @@ namespace AMDiS { bool localMatrix = (coarseSpaceMap.size() && subdomainLevel == 0); if (checkMeshChange()) { - // Mesh has been changed, recompute interior DOF mapping. - interiorMap->setComputeMatIndex(!localMatrix); - interiorMap->update(); - - int nMat = uniqueCoarseMap.size() + 1; + int nMat = uniqueCoarseMap.size() + 1; nnz.resize(nMat); for (int i = 0; i < nMat; i++) { nnz[i].resize(nMat); diff --git a/AMDiS/src/parallel/ParallelDofMapping.cc b/AMDiS/src/parallel/ParallelDofMapping.cc index d0c65bfa..eb40555a 100644 --- a/AMDiS/src/parallel/ParallelDofMapping.cc +++ b/AMDiS/src/parallel/ParallelDofMapping.cc @@ -215,7 +215,8 @@ namespace AMDiS { nRankDofs(1), nLocalDofs(1), nOverallDofs(1), - rStartDofs(1) + rStartDofs(1), + mode(mode) { switch (mode) { case COMPONENT_WISE: @@ -535,4 +536,15 @@ namespace AMDiS { ISCreateStride(mpiComm, nRankRows, firstMatIndex, 1, &is); } + + void ParallelDofMapping::printInfo() + { + FUNCNAME("ParallelDofMapping::printInfo()"); + + if (mode == COMPONENT_WISE) { + MSG("Mapping is defined by component numbers!\n"); + } else { + MSG("Mapping is defined by FE spaces!\n"); + } + } } diff --git a/AMDiS/src/parallel/ParallelDofMapping.h b/AMDiS/src/parallel/ParallelDofMapping.h index 9ed7f481..0db33235 100644 --- a/AMDiS/src/parallel/ParallelDofMapping.h +++ b/AMDiS/src/parallel/ParallelDofMapping.h @@ -820,6 +820,10 @@ namespace AMDiS { VecCreateSeq(PETSC_COMM_SELF, getRankDofs(), &vec); } + /// Prints out some information about the mapping. May be used during + /// debugging or parallel solver creation. + void printInfo(); + protected: /// Compute \ref nRankDofs. int computeRankDofs(); @@ -883,6 +887,10 @@ namespace AMDiS { /// Set of unique FE spaces. vector<const FiniteElemSpace*> feSpaces; + + /// Defines the DOF mapping either. The mapping may be defined either for + /// FE spaces or for component numbers. + DofMappingMode mode; }; } diff --git a/AMDiS/src/parallel/PetscSolver.cc b/AMDiS/src/parallel/PetscSolver.cc index 58bdacd9..bbb2f45c 100644 --- a/AMDiS/src/parallel/PetscSolver.cc +++ b/AMDiS/src/parallel/PetscSolver.cc @@ -45,7 +45,8 @@ namespace AMDiS { void PetscSolver::init(vector<const FiniteElemSpace*> &fe0, - vector<const FiniteElemSpace*> &fe1) + vector<const FiniteElemSpace*> &fe1, + bool createGlobalMapping) { FUNCNAME("PetscSolver::init()"); @@ -60,18 +61,20 @@ namespace AMDiS { int nLevels = levelData.getLevelNumber(); TEST_EXIT_DBG(nLevels >= 1)("Should not happen!\n"); - dofMap.init(levelData, componentSpaces, feSpaces); - dofMap.setMpiComm(levelData.getMpiComm(0), 0); - dofMap.setDofComm(meshDistributor->getDofComm()); - dofMap.clear(); - meshDistributor->registerDofMap(dofMap); - - if (nLevels > 1) { - dofMapSd.init(levelData, componentSpaces, feSpaces); - dofMapSd.setMpiComm(levelData.getMpiComm(1), 1); - dofMapSd.setDofComm(meshDistributor->getDofCommSd()); - dofMapSd.clear(); - meshDistributor->registerDofMap(dofMapSd); + if (createGlobalMapping) { + dofMap.init(levelData, componentSpaces, feSpaces); + dofMap.setMpiComm(levelData.getMpiComm(0), 0); + dofMap.setDofComm(meshDistributor->getDofComm()); + dofMap.clear(); + meshDistributor->registerDofMap(dofMap); + + if (nLevels > 1) { + dofMapSd.init(levelData, componentSpaces, feSpaces); + dofMapSd.setMpiComm(levelData.getMpiComm(1), 1); + dofMapSd.setDofComm(meshDistributor->getDofCommSd()); + dofMapSd.clear(); + meshDistributor->registerDofMap(dofMapSd); + } } } diff --git a/AMDiS/src/parallel/PetscSolver.h b/AMDiS/src/parallel/PetscSolver.h index 31d02674..a227fbf6 100644 --- a/AMDiS/src/parallel/PetscSolver.h +++ b/AMDiS/src/parallel/PetscSolver.h @@ -54,8 +54,9 @@ namespace AMDiS { virtual ~PetscSolver() {} - virtual void init(vector<const FiniteElemSpace*> &componentSpaces, - vector<const FiniteElemSpace*> &feSpaces); + void init(vector<const FiniteElemSpace*> &componentSpaces, + vector<const FiniteElemSpace*> &feSpaces, + bool createGlobalMapping = true); /** \brief * Create a PETSc matrix. The given DOF matrices are used to create the nnz diff --git a/AMDiS/src/parallel/PetscSolverFeti.cc b/AMDiS/src/parallel/PetscSolverFeti.cc index 253ecd46..2cd657f6 100644 --- a/AMDiS/src/parallel/PetscSolverFeti.cc +++ b/AMDiS/src/parallel/PetscSolverFeti.cc @@ -1282,20 +1282,28 @@ namespace AMDiS { if (!massMatrixSolver) { MSG("START CREATE MASS MATRIX!\n"); + ParallelDofMapping *massMapping = new ParallelDofMapping(COMPONENT_WISE); + massMapping->init(meshDistributor->getMeshLevelData(), + pressureFeSpace, pressureFeSpace); + massMapping->setDofComm(meshDistributor->getDofComm()); + (*massMapping)[0] = interfaceDofMap[pressureComponent]; + massMapping->update(); + DOFMatrix massMatrix(pressureFeSpace, pressureFeSpace); Operator op(pressureFeSpace, pressureFeSpace); Simple_ZOT zot; op.addTerm(&zot); massMatrix.assembleOperator(op); - ParallelDofMapping massMatMapping = interfaceDofMap; massMatrixSolver = new PetscSolverGlobalMatrix; massMatrixSolver->setKspPrefix("mass_"); massMatrixSolver->setMeshDistributor(meshDistributor, mpiCommGlobal, mpiCommLocal); - massMatrixSolver->setDofMapping(&massMatMapping); + massMatrixSolver->setDofMapping(massMapping); + MSG("START ASM ===\n"); massMatrixSolver->fillPetscMatrix(&massMatrix); + MSG("END ASM ===\n"); int r, c; MatGetSize(massMatrixSolver->getMatInterior(), &r, &c); -- GitLab