From 234ea16eccfa434ca3ffc17a6caedacf1a2664a5 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Thu, 25 Oct 2012 09:07:06 +0000
Subject: [PATCH] Hopefully fixed problem with local-global matrix indices for
 the last.

---
 AMDiS/src/parallel/MeshDistributor.cc    |  2 --
 AMDiS/src/parallel/ParallelDofMapping.cc |  5 +++--
 AMDiS/src/parallel/ParallelDofMapping.h  | 17 ++++++-----------
 AMDiS/src/parallel/PetscSolver.cc        |  4 ++--
 AMDiS/src/parallel/PetscSolverFeti.cc    |  3 +--
 5 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc
index c84d4e23..88aff704 100644
--- a/AMDiS/src/parallel/MeshDistributor.cc
+++ b/AMDiS/src/parallel/MeshDistributor.cc
@@ -1686,8 +1686,6 @@ namespace AMDiS {
       vector<const FiniteElemSpace*>& dofMapSpaces = dofMaps[i]->getFeSpaces();
       
       dofMaps[i]->clear();
-      if (hasPeriodicBoundary)
-	dofMaps[i]->setComputeMatIndex(true);
 
       for (int j = 0; j < static_cast<int>(dofMapSpaces.size()); j++)
 	updateLocalGlobalNumbering(*(dofMaps[i]), dofMapSpaces[j]);
diff --git a/AMDiS/src/parallel/ParallelDofMapping.cc b/AMDiS/src/parallel/ParallelDofMapping.cc
index 1b2540af..4a39b2d0 100644
--- a/AMDiS/src/parallel/ParallelDofMapping.cc
+++ b/AMDiS/src/parallel/ParallelDofMapping.cc
@@ -208,12 +208,13 @@ namespace AMDiS {
   }
 
 
-  ParallelDofMapping::ParallelDofMapping(DofMappingMode mode) 
+  ParallelDofMapping::ParallelDofMapping(DofMappingMode mode, 
+					 bool matIndexFromGlobal) 
     : meshLevel(0),
       levelData(NULL),
       dofComm(NULL),
       globalMapping(true),
-      needMatIndexFromGlobal(true),
+      needMatIndexFromGlobal(matIndexFromGlobal),
       nRankDofs(1),
       nLocalDofs(1),
       nOverallDofs(1),
diff --git a/AMDiS/src/parallel/ParallelDofMapping.h b/AMDiS/src/parallel/ParallelDofMapping.h
index 45e2e902..0bb64f7e 100644
--- a/AMDiS/src/parallel/ParallelDofMapping.h
+++ b/AMDiS/src/parallel/ParallelDofMapping.h
@@ -643,10 +643,13 @@ namespace AMDiS {
     /** \brief 
      * Constructur for parallel DOF mapping.
      *
-     * \param[in]   mode  Defines if DOF mapping is defined either per 
-     *                    component or per FE space.
+     * \param[in]  mode            Defines if DOF mapping is defined either per
+     *                             component or per FE space.
+     * \param[in]  matIndexGlobal  If true, the mat index is defined on global
+     *                             DOF indices, otherwise on local ones.
      */
-    ParallelDofMapping(DofMappingMode mode);
+    ParallelDofMapping(DofMappingMode mode, 
+		       bool matIndexFromGlobal = false);
 
     /** \brief 
      * Initialize the parallel DOF mapping.
@@ -694,19 +697,11 @@ namespace AMDiS {
       return *dofComm;
     }
 
-    /// Changes the computation of matrix indices based of either local or
-    /// global DOF indices, see \ref needMatIndexFromGlobal
-    void setComputeMatIndex(bool global)
-    {
-      needMatIndexFromGlobal = global;
-    }
-
     inline bool isMatIndexFromGlobal()
     {
       return needMatIndexFromGlobal;
     }
 
-
     /// Access the DOF mapping for a given component number.
     inline ComponentDofMap& operator[](int compNumber)
     {
diff --git a/AMDiS/src/parallel/PetscSolver.cc b/AMDiS/src/parallel/PetscSolver.cc
index bbb2f45c..e8f0300a 100644
--- a/AMDiS/src/parallel/PetscSolver.cc
+++ b/AMDiS/src/parallel/PetscSolver.cc
@@ -22,8 +22,8 @@ namespace AMDiS {
 
   PetscSolver::PetscSolver()
     : ParallelCoarseSpaceMatVec(),
-      dofMap(FESPACE_WISE),
-      dofMapSd(FESPACE_WISE),
+      dofMap(FESPACE_WISE, true),
+      dofMapSd(FESPACE_WISE, true),
       kspPrefix(""),
       removeRhsNullspace(false),    
       hasConstantNullspace(false),
diff --git a/AMDiS/src/parallel/PetscSolverFeti.cc b/AMDiS/src/parallel/PetscSolverFeti.cc
index e91404cc..58dbf068 100644
--- a/AMDiS/src/parallel/PetscSolverFeti.cc
+++ b/AMDiS/src/parallel/PetscSolverFeti.cc
@@ -1286,12 +1286,11 @@ namespace AMDiS {
 	    massMapping = massMatrixSolver->getDofMapping();
 	  } else {
 	    massMapping = 
-	      new ParallelDofMapping(COMPONENT_WISE);
+	      new ParallelDofMapping(COMPONENT_WISE, true);
 	    massMapping->init(meshDistributor->getMeshLevelData(), 
 			      pressureFeSpace, pressureFeSpace);
 	    massMapping->setDofComm(meshDistributor->getDofComm());
 	    massMapping->setMpiComm(meshDistributor->getMeshLevelData().getMpiComm(0), 0);
-	    massMapping->setComputeMatIndex(true);
 	  }	   
 	  (*massMapping)[0] = interfaceDofMap[pressureComponent];
 	  massMapping->update();
-- 
GitLab