From bb968a2cab986af9ea01e4178d716ea69e15ce55 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Mon, 22 Oct 2012 05:38:17 +0000
Subject: [PATCH] Fixed last issues in code change of parallel DOF mapping, now
 go on for debugging.

---
 AMDiS/src/Mesh.h                         | 76 ++++++++++--------------
 AMDiS/src/parallel/MeshDistributor.cc    |  2 +
 AMDiS/src/parallel/ParallelDofMapping.cc | 26 ++++++++
 AMDiS/src/parallel/ParallelDofMapping.h  | 34 ++++-------
 AMDiS/src/parallel/PetscSolverFeti.cc    |  6 ++
 5 files changed, 77 insertions(+), 67 deletions(-)

diff --git a/AMDiS/src/Mesh.h b/AMDiS/src/Mesh.h
index 10f067ef..c44a3a69 100644
--- a/AMDiS/src/Mesh.h
+++ b/AMDiS/src/Mesh.h
@@ -602,8 +602,8 @@ namespace AMDiS {
     void deleteMeshStructure();
 
 #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
-    /// In parallel computations the level of all macro elements is equal to the number
-    /// of global pre refinements, \ref nParallelPreRefinements.
+    /// In parallel computations the level of all macro elements is equal to the 
+    /// number of global pre refinements, \ref nParallelPreRefinements.
     inline int getMacroElementLevel()
     {
       return nParallelPreRefinements;
@@ -741,32 +741,26 @@ namespace AMDiS {
     /// Number of faces in this Mesh
     int nFaces;
 
-    /** \brief
-     * Maximal number of elements that share one edge; used to allocate memory 
-     * to store pointers to the neighbour at the refinement/coarsening edge 
-     * (only 3d);
-     */
+    /// Maximal number of elements that share one edge; used to allocate memory 
+    /// to store pointers to the neighbour at the refinement/coarsening edge 
+    /// (only 3d);
     int maxEdgeNeigh;
 
     /// Diameter of the mesh in the DIM_OF_WORLD directions
     WorldVector<double> diam;
 
-    /** \brief
-     * Is pointer to NULL if mesh contains no parametric elements else pointer 
-     * to a Parametric object containing coefficients of the parameterization 
-     * and related information
-     */
+    /// Is pointer to NULL if mesh contains no parametric elements else pointer 
+    /// to a Parametric object containing coefficients of the parameterization 
+    /// and related information
     Parametric *parametric;
 
-    /** \brief
-     * When an element is refined, not all dofs of the coarse element must be 
-     * part of the new elements. An example are centered dofs when using higher
-     * lagrange basis functions. The midpoint dof of the parents element is not
-     * a dof of the both children elements. Therefore, the dof can be deleted. In
-     * some situation, e.g., when using multigrid techniques, it can be necessary to
-     * store this coarse dofs. Then this variable must be set to true. If false, the
-     * not required coarse dofs will be deleted.
-     */
+    /// When an element is refined, not all dofs of the coarse element must be 
+    /// part of the new elements. An example are centered dofs when using higher
+    /// lagrange basis functions. The midpoint dof of the parents element is not
+    /// a dof of the both children elements. Therefore, the dof can be deleted.
+    /// In some situation, e.g., when using multigrid techniques, it can be 
+    /// necessary to store this coarse dofs. Then this variable must be set to
+    /// true. If false, the not required coarse dofs will be deleted.
     bool preserveCoarseDOFs;
 
     /// Number of all DOFs on a single element
@@ -821,24 +815,20 @@ namespace AMDiS {
     /// Used by check functions
     static vector<DegreeOfFreedom> dof_used;
 
-    /** \brief
-     * This map is used for serialization and deserialization of mesh elements. 
-     * During the serialization process, all elements are visited and their dof indices
-     * are written to the file. If a dof index at a position, i.e. vertex, line or face,
-     * was written to file, the combination of dof index and position is inserted to
-     * this map. That ensures that the same dof at the same position, but being part of
-     * another element, is not written twice to the file. 
-     * When a state should be deserialized, the information can be used to construct
-     * exactly the same dof structure.
-     */
+    /// This map is used for serialization and deserialization of mesh elements.
+    /// During the serialization process, all elements are visited and their
+    /// DOF indices are written to the file. If a dof index at a position, i.e. 
+    /// vertex, line or face, was written to file, the combination of dof index
+    /// and position is inserted to this map. That ensures that the same dof at
+    /// the same position, but being part of another element, is not written
+    /// twice to the file. When a state should be deserialized, the information
+    /// can be used to construct exactly the same dof structure.
     static map<pair<DegreeOfFreedom, int>, DegreeOfFreedom*> serializedDOFs;
 
-    /** \brief
-     * Used while mesh refinement. To create new elements 
-     * elementPrototype->clone() is called, which returns a Element of the
-     * same type as elementPrototype. So e.g. Elements of the different
-     * dimensions can be created in a uniform way. 
-     */
+    /// Used while mesh refinement. To create new elements 
+    /// elementPrototype->clone() is called, which returns a Element of the
+    /// same type as elementPrototype. So e.g. Elements of the different
+    /// dimensions can be created in a uniform way. 
     Element* elementPrototype;
 
     /// Prototype for leaf data. Used for creation of new leaf data while 
@@ -875,16 +865,12 @@ namespace AMDiS {
     /// for findElement-Fcts
     DimVec<double> final_lambda;
 
-    /** \brief
-     * Temporary variables that are used in functions \ref fineElInfoatPoint and
-     * \ref fineElementAtPointRecursive.
-     */
+    /// Temporary variables that are used in functions \ref fineElInfoatPoint
+    /// and \ref fineElementAtPointRecursive.
     const WorldVector<double> *g_xy0, *g_xy;
 
-    /** \brief
-     * Temporary variable that is used in functions \ref fineElInfoatPoint and
-     * \ref fineElementAtPointRecursive.
-     */    
+    /// Temporary variable that is used in functions \ref fineElInfoatPoint and
+    /// \ref fineElementAtPointRecursive.  
     double *g_sp;
    
     friend class MacroInfo;
diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc
index c2974377..ca2b0dff 100644
--- a/AMDiS/src/parallel/MeshDistributor.cc
+++ b/AMDiS/src/parallel/MeshDistributor.cc
@@ -79,6 +79,8 @@ namespace AMDiS {
       refineManager(NULL),
       info(10),
       partitioner(NULL),
+      dofMap(FESPACE_WISE),
+      dofMapSd(FESPACE_WISE),
       deserialized(false),
       writeSerializationFile(false),
       repartitioningAllowed(false),
diff --git a/AMDiS/src/parallel/ParallelDofMapping.cc b/AMDiS/src/parallel/ParallelDofMapping.cc
index 6638d45d..fae07266 100644
--- a/AMDiS/src/parallel/ParallelDofMapping.cc
+++ b/AMDiS/src/parallel/ParallelDofMapping.cc
@@ -227,6 +227,32 @@ namespace AMDiS {
   }
 
 
+  ParallelDofMapping::ParallelDofMapping(DofMappingMode mode) 
+    : levelData(NULL),
+      dofComm(NULL),
+      isNonLocal(true),
+      needMatIndexFromGlobal(false),
+      nRankDofs(1),
+      nLocalDofs(1),
+      nOverallDofs(1),
+      rStartDofs(1)
+  {
+    switch (mode) {
+    case COMPONENT_WISE:
+      data = new ComponentDataDiffFeSpace();
+      break;
+    case FESPACE_WISE:
+      data = new ComponentDataEqFeSpace();
+      break;
+    }
+    
+    nRankDofs = -1;
+    nLocalDofs = -1;
+    nOverallDofs = -1;
+    rStartDofs = -1;
+  } 
+
+
   void ParallelDofMapping::init(MeshLevelData &ldata,
 				vector<const FiniteElemSpace*> &fe,
 				vector<const FiniteElemSpace*> &uniqueFe,
diff --git a/AMDiS/src/parallel/ParallelDofMapping.h b/AMDiS/src/parallel/ParallelDofMapping.h
index c1704515..33fc94b7 100644
--- a/AMDiS/src/parallel/ParallelDofMapping.h
+++ b/AMDiS/src/parallel/ParallelDofMapping.h
@@ -98,11 +98,9 @@ namespace AMDiS {
   };
 
 
-  /**
-   * This class defines the parallel mapping of DOFs for one FE space. It is used
-   * by the class \ref ParallelDofMapping to specifiy the mapping for a set of 
-   * FE spaces.
-   */
+  /// This class defines the parallel mapping of DOFs for one FE space. It is
+  /// used by the class \ref ParallelDofMapping to specifiy the mapping for a
+  /// set of  FE spaces.
   class ComponentDofMap
   {
   public:
@@ -338,7 +336,7 @@ namespace AMDiS {
   };
 
 
-  class ComponentDataEqFeSpace : ComponentDataInterface
+  class ComponentDataEqFeSpace : public ComponentDataInterface
   {
   public:
     ComponentDataEqFeSpace()
@@ -475,7 +473,7 @@ namespace AMDiS {
   };
 
 
-  class ComponentDataDiffFeSpace : ComponentDataInterface
+  class ComponentDataDiffFeSpace : public ComponentDataInterface
   {
   public:
     ComponentDataDiffFeSpace()
@@ -574,6 +572,12 @@ namespace AMDiS {
     friend class Iterator;
   };
 
+  /// Used to specify whether a parallel DOF mapping is defined for each
+  /// specific component or for each FE space.
+  enum DofMappingMode {
+    COMPONENT_WISE,
+    FESPACE_WISE
+  };
 
   /**
    * Implements the mapping from sets of distributed DOF indices to local and
@@ -583,21 +587,7 @@ namespace AMDiS {
   class ParallelDofMapping
   {
   public:
-    ParallelDofMapping() 
-      : levelData(NULL),
-	dofComm(NULL),
-	isNonLocal(true),
-	needMatIndexFromGlobal(false),
-	nRankDofs(1),
-	nLocalDofs(1),
-	nOverallDofs(1),
-	rStartDofs(1)
-    {
-      nRankDofs = -1;
-      nLocalDofs = -1;
-      nOverallDofs = -1;
-      rStartDofs = -1;
-    } 
+    ParallelDofMapping(DofMappingMode mode);
 
     /** \brief Initialize the parallel DOF mapping.
      *
diff --git a/AMDiS/src/parallel/PetscSolverFeti.cc b/AMDiS/src/parallel/PetscSolverFeti.cc
index e8a7ac46..ce3ffabc 100644
--- a/AMDiS/src/parallel/PetscSolverFeti.cc
+++ b/AMDiS/src/parallel/PetscSolverFeti.cc
@@ -30,6 +30,12 @@ namespace AMDiS {
 
   PetscSolverFeti::PetscSolverFeti()
     : PetscSolver(),
+      primalDofMap(COMPONENT_WISE),
+      dualDofMap(COMPONENT_WISE),
+      interfaceDofMap(COMPONENT_WISE),
+      localDofMap(COMPONENT_WISE),
+      lagrangeMap(COMPONENT_WISE),
+      interiorDofMap(COMPONENT_WISE),
       schurPrimalSolver(0),
       multiLevelTest(false),
       subdomain(NULL),
-- 
GitLab