Isorropia_EpetraOperator.hpp

Go to the documentation of this file.
00001 //@HEADER
00002 /*
00003 ************************************************************************
00004 
00005               Isorropia: Partitioning and Load Balancing Package
00006                 Copyright (2006) Sandia Corporation
00007 
00008 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 license for use of this work by or on behalf of the U.S. Government.
00010 
00011 This library is free software; you can redistribute it and/or modify
00012 it under the terms of the GNU Lesser General Public License as
00013 published by the Free Software Foundation; either version 2.1 of the
00014 License, or (at your option) any later version.
00015 
00016 This library is distributed in the hope that it will be useful, but
00017 WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 Lesser General Public License for more details.
00020 
00021 You should have received a copy of the GNU Lesser General Public
00022 License along with this library; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 USA
00025 
00026 ************************************************************************
00027 */
00028 //@HEADER
00029 
00030 #ifndef _Isorropia_EpetraOperator_hpp_
00031 #define _Isorropia_EpetraOperator_hpp_
00032 
00033 #include <Isorropia_ConfigDefs.hpp>
00034 #include <Teuchos_RCP.hpp>
00035 #include <Teuchos_ParameterList.hpp>
00036 
00037 #include <Isorropia_EpetraCostDescriber.hpp>
00038 #include <Isorropia_Operator.hpp>
00039 #include <Isorropia_EpetraLibrary.hpp>
00040 
00041 #ifdef HAVE_EPETRA
00042 class Epetra_Map;
00043 class Epetra_BlockMap;
00044 class Epetra_Import;
00045 class Epetra_Vector;
00046 class Epetra_MultiVector;
00047 class Epetra_CrsGraph;
00048 class Epetra_CrsMatrix;
00049 class Epetra_RowMatrix;
00050 class Epetra_LinearProblem;
00051 
00052 namespace Isorropia {
00053 
00054 namespace Epetra {
00055   class CostDescriber;
00056 
00062 class Operator : virtual public Isorropia::Operator {
00063 public:
00064 
00065   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, int base);
00066 
00067   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, int base);
00068 
00069   Operator(Teuchos::RCP<const Epetra_MultiVector> input_coords, int base);
00070 
00071   Operator(Teuchos::RCP<const Epetra_BlockMap> input_map, int base);
00072 
00073   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, 
00074      Teuchos::RCP<const Epetra_MultiVector> input_coords, int base);
00075 
00076   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, 
00077      Teuchos::RCP<const Epetra_MultiVector> input_coords, int base);
00078 
00079 
00093   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00094               const Teuchos::ParameterList& paramlist, int base);
00095 
00096 
00110   Operator(Teuchos::RCP<const Epetra_BlockMap> input_map,
00111               const Teuchos::ParameterList& paramlist, int base);
00112 
00113 
00114 
00132   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00133      Teuchos::RCP<const Epetra_MultiVector> input_coords,
00134            const Teuchos::ParameterList& paramlist, int base);
00135 
00136 
00154   Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00155             Teuchos::RCP<CostDescriber> costs,
00156               const Teuchos::ParameterList& paramlist, int base);
00157 
00158 
00182   Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00183             Teuchos::RCP<CostDescriber> costs,
00184       Teuchos::RCP<const Epetra_MultiVector> coords,
00185       Teuchos::RCP<const Epetra_MultiVector> weights,
00186               const Teuchos::ParameterList& paramlist, int base);
00187 
00188 
00202   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00203      const Teuchos::ParameterList& paramlist, int base);
00204 
00205 
00223   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00224      Teuchos::RCP<const Epetra_MultiVector> coords,
00225      const Teuchos::ParameterList& paramlist, int base);
00226 
00227 
00245   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00246      Teuchos::RCP<CostDescriber> costs,
00247      const Teuchos::ParameterList& paramlist, int base);
00248 
00249 
00274   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00275      Teuchos::RCP<CostDescriber> costs,
00276      Teuchos::RCP<const Epetra_MultiVector> coords,
00277      Teuchos::RCP<const Epetra_MultiVector> weights,
00278      const Teuchos::ParameterList& paramlist, int base);
00279 
00280 
00295   Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
00296      const Teuchos::ParameterList& paramlist, int base);
00297 
00315   Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
00316            Teuchos::RCP<const Epetra_MultiVector> weights,
00317      const Teuchos::ParameterList& paramlist, int base);
00318 
00320   virtual ~Operator();
00321 
00325   void setParameters(const Teuchos::ParameterList& paramlist);
00326 
00327   virtual void compute(bool force_compute) = 0 ;
00328 
00331   bool alreadyComputed() const {
00332     return operation_already_computed_;
00333   }
00334 
00335   int numProperties() const {
00336     return (numberOfProperties_);
00337   }
00338 
00339   int numLocalProperties() const {
00340     return (localNumberOfProperties_);
00341   }
00342 
00346   virtual const int& operator[](int myElem) const;
00347 
00350   virtual int numElemsWithProperty(int property) const;
00351 
00355   virtual void elemsWithProperty(int property,
00356        int* elementList,
00357        int len) const;
00358 
00359   virtual int extractPropertiesCopy(int len,
00360             int& size,
00361             int* array) const ;
00362 
00363   virtual int extractPropertiesView(int& size,
00364             const int*& array) const;
00365 
00366 private:
00367 
00368   void paramsToUpper(Teuchos::ParameterList &, int &changed, bool rmUnderscore=true);
00369   void stringToUpper(std::string &s, int &changed, bool rmUnderscore=false);
00370   int numberOfProperties_;
00371   int localNumberOfProperties_;
00372   std::vector<int> numberElemsByProperties_;
00373 
00374 protected:
00375   Teuchos::RCP<const Epetra_BlockMap> input_map_;
00376   Teuchos::RCP<const Epetra_CrsGraph> input_graph_;
00377   Teuchos::RCP<const Epetra_RowMatrix> input_matrix_;
00378   Teuchos::RCP<const Epetra_MultiVector> input_coords_;
00379   Teuchos::RCP<Isorropia::Epetra::CostDescriber> costs_;
00380   Teuchos::RCP<const Epetra_MultiVector> weights_;
00381 
00382   Teuchos::ParameterList paramlist_;
00383 
00384   int exportsSize_;
00385   std::vector<int> imports_;
00386   std::vector<int> properties_;
00387 
00388   bool operation_already_computed_;
00389 
00390   int global_num_vertex_weights_;
00391   int global_num_graph_edge_weights_;
00392   int global_num_hg_edge_weights_;
00393 
00394   Teuchos::RCP<Library> lib_;
00395 
00396   int base_;
00397 
00398   void computeNumberOfProperties();
00399 };//class Operator
00400 
00401 }//namespace Epetra
00402 }//namespace Isorropia
00403 
00404 #endif //HAVE_EPETRA
00405 
00406 #endif
00407