Zoltan2
Zoltan2_PartitionMapping.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //   Zoltan2: A package of combinatorial algorithms for scientific computing
00006 //                  Copyright 2012 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Karen Devine      (kddevin@sandia.gov)
00039 //                    Erik Boman        (egboman@sandia.gov)
00040 //                    Siva Rajamanickam (srajama@sandia.gov)
00041 //
00042 // ***********************************************************************
00043 //
00044 // @HEADER
00045 
00050 #ifndef _ZOLTAN2_PARTITIONMAPPING_HPP_
00051 #define _ZOLTAN2_PARTITIONMAPPING_HPP_
00052 #include "Zoltan2_Model.hpp"
00053 #include "Zoltan2_PartitioningSolution.hpp"
00054 #include "Teuchos_Comm.hpp"
00055 #include "Zoltan2_Environment.hpp"
00056 #include "Zoltan2_MachineRepresentation.hpp"
00057 
00058 namespace Zoltan2 {
00059 
00063 template <typename Adapter>
00064   class PartitionMapping
00065 {
00066 public:
00067 
00068 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00069   typedef typename Adapter::gno_t gno_t;
00070   typedef typename Adapter::scalar_t scalar_t;
00071   typedef typename Adapter::lno_t lno_t;
00072   typedef typename Adapter::zgid_t zgid_t;
00073   typedef typename Adapter::part_t part_t;
00074   typedef typename Adapter::user_t user_t;
00075 #endif
00076 
00077   const Teuchos::Comm<int> *comm;
00078   const Zoltan2::MachineRepresentation <scalar_t> *machine;
00079   const Zoltan2::Model<typename Adapter::base_adapter_t> *model;
00080   const Zoltan2::PartitioningSolution<Adapter> *soln;
00081   const Environment *env;
00082 
00089   PartitionMapping(
00090     const Teuchos::Comm<int> *comm_,
00091     const Zoltan2::MachineRepresentation<scalar_t> *machine_, // If NULL, assume homogeneous
00092                                                   // Make optional
00093     const Zoltan2::Model<typename Adapter::base_adapter_t> *model_, // Needed to get information about
00094                                          // the application data (coords, graph)
00095     const Zoltan2::PartitioningSolution<Adapter> *soln_, // Needed for mapping a partition
00096     const Environment *envConst_  // Perhaps envConst should be optional
00097                                          // so applications can create a mapping
00098                                          // directly
00099   ):comm(comm_),
00100       machine(machine_),
00101       model(model_),
00102       soln(soln_),
00103       env(envConst_)
00104           {} ;
00105 
00106   PartitionMapping():
00107           comm(0),
00108           machine(0),
00109           model(0),
00110           soln(0),
00111           env(0){};
00112 
00113   PartitionMapping(const Environment *envConst_):
00114           comm(0),
00115           machine(0),
00116           model(0),
00117           soln(0),
00118           env(envConst_){};
00119 
00120   PartitionMapping(
00121           const Environment *envConst_,
00122           const Teuchos::Comm<int> *comm_,
00123           const MachineRepresentation<scalar_t> *machine_
00124           ):
00125           comm(comm_),
00126           machine(machine_),
00127           model(0),
00128           soln(0),
00129           env(envConst_){};
00130 
00131 
00132   virtual ~PartitionMapping(){}
00133 
00136   virtual size_t getLocalNumberOfParts() const = 0;
00137 
00145   // TODO:  KDDKDD Decide whether information should be avail for any process
00146   // TODO:  KDDKDD (requiring more storage or a directory) or only for the 
00147   // TODO:  KDDKDD local process.
00148   // TODO:  KDDKDD Could require O(nprocs) storage
00149   virtual void getPartsForProc(int procId, part_t &numParts, part_t *parts)
00150     const = 0;
00151 
00158   // TODO:  KDDKDD Arguments should be count and array, not min and max.
00159   // TODO:  KDDKDD Could require O(nGlobalParts) storage
00160   virtual void getProcsForPart(part_t partId, part_t &numProcs, part_t *procs) const = 0;
00161 
00162 private:
00163 };
00164 
00165 }  // namespace Zoltan2
00166 
00167 #endif