From 2eeaa8b6892027b69f274bba03a004b4e1ef4338 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Thu, 10 Feb 2011 14:24:12 +0000
Subject: [PATCH] Added simple partitioner.

---
 AMDiS/libtool                          |  6 +--
 AMDiS/src/parallel/MeshDistributor.cc  |  4 ++
 AMDiS/src/parallel/MeshPartitioner.h   |  7 ++-
 AMDiS/src/parallel/SimplePartitioner.h | 62 ++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 4 deletions(-)
 create mode 100644 AMDiS/src/parallel/SimplePartitioner.h

diff --git a/AMDiS/libtool b/AMDiS/libtool
index ace48e58..02151259 100755
--- a/AMDiS/libtool
+++ b/AMDiS/libtool
@@ -44,7 +44,7 @@ available_tags=" CXX F77"
 
 # ### BEGIN LIBTOOL CONFIG
 
-# Libtool was configured on host p1q024:
+# Libtool was configured on host deimos103:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
 # End:
 # ### BEGIN LIBTOOL TAG CONFIG: CXX
 
-# Libtool was configured on host p1q024:
+# Libtool was configured on host deimos103:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -7065,7 +7065,7 @@ include_expsyms=""
 
 # ### BEGIN LIBTOOL TAG CONFIG: F77
 
-# Libtool was configured on host p1q024:
+# Libtool was configured on host deimos103:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
diff --git a/AMDiS/src/parallel/MeshDistributor.cc b/AMDiS/src/parallel/MeshDistributor.cc
index d7acc49a..37790f16 100644
--- a/AMDiS/src/parallel/MeshDistributor.cc
+++ b/AMDiS/src/parallel/MeshDistributor.cc
@@ -26,6 +26,7 @@
 #include "parallel/MeshPartitioner.h"
 #include "parallel/ParMetisPartitioner.h"
 #include "parallel/ZoltanPartitioner.h"
+#include "parallel/SimplePartitioner.h"
 #include "parallel/MpiHelper.h"
 #include "io/ElementFileWriter.h"
 #include "io/MacroInfo.h"
@@ -105,6 +106,9 @@ namespace AMDiS {
     if (partStr == "zoltan")
       partitioner = new ZoltanPartitioner(&mpiComm);
 
+    if (partStr == "simple")
+      partitioner = new SimplePartitioner(&mpiComm);
+
     tmp = 0;
     GET_PARAMETER(0, name + "->box partitioning", "%d", &tmp);
     partitioner->setBoxPartitioning(static_cast<bool>(tmp));
diff --git a/AMDiS/src/parallel/MeshPartitioner.h b/AMDiS/src/parallel/MeshPartitioner.h
index 1bb8706e..c8db60ce 100644
--- a/AMDiS/src/parallel/MeshPartitioner.h
+++ b/AMDiS/src/parallel/MeshPartitioner.h
@@ -41,7 +41,12 @@ namespace AMDiS {
   };
 
 
-
+  /**
+   * Abstract class for mesh partitioning. This class provides only a function
+   * for a random initial partitioning. A concrete partition must override the 
+   * functions \ref MeshPartitioner::partition and 
+   * \ref MeshPartitioner::createPartitionMap.
+   */
   class MeshPartitioner
   {
   public:
diff --git a/AMDiS/src/parallel/SimplePartitioner.h b/AMDiS/src/parallel/SimplePartitioner.h
new file mode 100644
index 00000000..be853289
--- /dev/null
+++ b/AMDiS/src/parallel/SimplePartitioner.h
@@ -0,0 +1,62 @@
+// ============================================================================
+// ==                                                                        ==
+// == AMDiS - Adaptive multidimensional simulations                          ==
+// ==                                                                        ==
+// ==  http://www.amdis-fem.org                                              ==
+// ==                                                                        ==
+// ============================================================================
+//
+// Software License for AMDiS
+//
+// Copyright (c) 2010 Dresden University of Technology 
+// All rights reserved.
+// Authors: Simon Vey, Thomas Witkowski et al.
+//
+// This file is part of AMDiS
+//
+// See also license.opensource.txt in the distribution.
+
+
+
+/** \file SimplePartitioner.h */
+
+#ifndef AMDIS_SIMPLE_PARTITIONER_H
+#define AMDIS_SIMPLE_PARTITIONER_H
+
+#include "AMDiS_fwd.h"
+#include "Global.h"
+#include "parallel/MeshPartitioner.h"
+
+namespace AMDiS {
+
+  /**
+   * The "Simple partitioner" does not change the initial partitioning which is more
+   * or less a random assignment of elements to ranks. This partitioner may be useful
+   * for either debugging purposes or if the number of macro elements is equal to the
+   * number of processes. In this case, neither ParMetis nor Zoltan will be able to
+   * compute a valid partition. But a random one-to-one partition is the best possible
+   * in this case.
+   */
+  class SimplePartitioner : public MeshPartitioner
+  {
+  public:
+    SimplePartitioner(MPI::Intracomm *comm)
+      : MeshPartitioner(comm)
+    {}
+
+    ~SimplePartitioner() {}
+
+    /// \ref MeshPartitioner::partition
+    bool partition(map<int, double> &elemWeights, PartitionMode mode = INITIAL)
+    {
+      return true;
+    }
+
+    void createPartitionMap(map<int, int>& pMap)
+    {
+      pMap = partitionMap;
+    }
+  };
+}
+
+#endif
-- 
GitLab