QueryObject.hpp

Go to the documentation of this file.
00001 //@HEADER
00002 // ***********************************************************************
00003 // 
00004 //            Isorropia: Partitioning and Load Balancing Package
00005 //              Copyright (2006) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // 
00025 // ***********************************************************************
00026 //@HEADER
00027 
00028 #ifndef ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H
00029 #define ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H
00030 
00031 #include "Isorropia_ConfigDefs.hpp"
00032 
00033 #include <Teuchos_RCP.hpp>
00034 
00035 #include <zoltan_cpp.h>
00036 
00037 #include <set>
00038 #include <map>
00039 
00040 class Epetra_BlockMap;
00041 class Epetra_CrsGraph;
00042 class Epetra_RowMatrix;
00043 
00044 namespace Isorropia {
00045 
00046 namespace Epetra {
00047 
00048   class CostDescriber;
00049 
00057 namespace ZoltanLib {
00058 
00069 class QueryObject
00070 {
00071   Teuchos::RCP<const Epetra_CrsGraph> graph_;
00072   Teuchos::RCP<const Epetra_RowMatrix> matrix_;
00073   const Epetra_BlockMap *rowMap_;
00074   const Epetra_BlockMap *colMap_;
00075 
00076   Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs_;
00077 
00078   std::map<int,int> procmap_;
00079   std::set<int> graph_self_edges_;
00080 
00081   const bool isHypergraph_;
00082   const bool haveGraph_;
00083   int myProc_;
00084   int base_;
00085 
00086   void fill_procmap();
00087 
00093   int My_Number_Objects(int *ierr);
00094 
00098   void My_Object_List  (int num_gid_entries, int num_lid_entries,
00099                      ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00100                      int weight_dim, float * object_weights, int * ierr );
00101 
00106   void My_Number_Edges_Multi  (int num_gid_entries, int num_lid_entries,
00107                int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00108                int *num_edges, int * ierr );
00109 
00114   void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries, 
00115                int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 
00116                int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
00117                int weight_dim, float * edge_weights, int * ierr );
00118 
00121   void My_HG_Size_CS (int* num_lists, int* num_pins, int* format, 
00122                           int * ierr );
00125   void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 
00126            int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
00127                                        int * ierr );
00130   void My_HG_Size_Edge_Weights(int* num_edges, int* ierr);
00133   void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
00134         ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
00135 
00136  public:
00137 
00140   QueryObject( Teuchos::RCP<const Epetra_CrsGraph> graph,
00141          Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs,
00142                bool isHypergraph);
00143 
00144 
00147   QueryObject( Teuchos::RCP<const Epetra_RowMatrix> matrix,
00148          Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs,
00149                bool isHypergraph);
00150 
00153   virtual ~QueryObject();
00154 
00157   const Epetra_BlockMap &RowMap(void){ return *rowMap_;};
00158 
00162   bool haveVertexWeights();
00163 
00167   bool haveGraphEdgeWeights();
00168 
00172   bool haveHypergraphEdgeWeights();
00173 
00174   // General query functions
00177   static int Number_Objects(void *data, int *ierr);
00180   static void Object_List  ( void * data, int num_gid_entries, int num_lid_entries,
00181                      ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00182                      int weight_dim, float * object_weights, int * ierr );
00183 
00184   // Query functions for graph partitioning only
00187   static void Number_Edges_Multi  ( void * data, int num_gid_entries, int num_lid_entries,
00188                int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00189                int *num_edges, int * ierr );
00192   static void Edge_List_Multi( void * data, int num_gid_entries, int num_lid_entries, 
00193                int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 
00194                int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
00195                int weight_dim, float * edge_weights, int * ierr );
00196 
00197   // Query functions for hypergraph partitioning only
00200   static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format, 
00201                           int * ierr );
00204   static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins, 
00205            int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
00206                                        int * ierr );
00209   static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr);
00212   static void HG_Edge_Weights(void * data,
00213         int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
00214         ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
00215 
00216 };
00217 
00218 } //namespace ZoltanLib
00219 } //namespace Epetra
00220 } //namespace Isorropia
00221 
00222 #endif //ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H
00223