Isorropia: Partitioning, Load Balancing and more
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 
00095   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00096               const Teuchos::ParameterList& paramlist, int base);
00097 
00098 
00113   Operator(Teuchos::RCP<const Epetra_BlockMap> input_map,
00114               const Teuchos::ParameterList& paramlist, int base);
00115 
00116 
00117 
00137   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00138      Teuchos::RCP<const Epetra_MultiVector> input_coords,
00139            const Teuchos::ParameterList& paramlist, int base);
00140 
00141 
00161   Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00162             Teuchos::RCP<CostDescriber> costs,
00163               const Teuchos::ParameterList& paramlist, int base);
00164 
00165 
00191   Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00192             Teuchos::RCP<CostDescriber> costs,
00193       Teuchos::RCP<const Epetra_MultiVector> coords,
00194       Teuchos::RCP<const Epetra_MultiVector> weights,
00195               const Teuchos::ParameterList& paramlist, int base);
00196 
00197 
00213   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00214      const Teuchos::ParameterList& paramlist, int base);
00215 
00216 
00236   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00237      Teuchos::RCP<const Epetra_MultiVector> coords,
00238      const Teuchos::ParameterList& paramlist, int base);
00239 
00240 
00260   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00261      Teuchos::RCP<CostDescriber> costs,
00262      const Teuchos::ParameterList& paramlist, int base);
00263 
00264 
00291   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00292      Teuchos::RCP<CostDescriber> costs,
00293      Teuchos::RCP<const Epetra_MultiVector> coords,
00294      Teuchos::RCP<const Epetra_MultiVector> weights,
00295      const Teuchos::ParameterList& paramlist, int base);
00296 
00297 
00314   Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
00315      const Teuchos::ParameterList& paramlist, int base);
00316 
00336   Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
00337            Teuchos::RCP<const Epetra_MultiVector> weights,
00338      const Teuchos::ParameterList& paramlist, int base);
00339 
00341   virtual ~Operator();
00342 
00346   void setParameters(const Teuchos::ParameterList& paramlist);
00347 
00351   Teuchos::RCP<Isorropia::Epetra::CostDescriber> & getCosts() { return costs_; }
00352 
00353   virtual void compute(bool force_compute) = 0 ;
00354 
00357   bool alreadyComputed() const {
00358     return operation_already_computed_;
00359   }
00360 
00361   int numProperties() const {
00362     return (numberOfProperties_);
00363   }
00364 
00365   int numLocalProperties() const {
00366     return (localNumberOfProperties_);
00367   }
00368 
00372   virtual const int& operator[](int myElem) const;
00373 
00376   virtual int numElemsWithProperty(int property) const;
00377 
00381   virtual void elemsWithProperty(int property,
00382        int* elementList,
00383        int len) const;
00384 
00385   virtual int extractPropertiesCopy(int len,
00386             int& size,
00387             int* array) const ;
00388 
00389   virtual int extractPropertiesView(int& size,
00390             const int*& array) const;
00391 
00392 private:
00393 
00394   void paramsToUpper(Teuchos::ParameterList &, int &changed, bool rmUnderscore=true);
00395   void stringToUpper(std::string &s, int &changed, bool rmUnderscore=false);
00396   int numberOfProperties_;
00397   int localNumberOfProperties_;
00398   std::vector<int> numberElemsByProperties_;
00399 
00400 protected:
00401   Teuchos::RCP<const Epetra_BlockMap> input_map_;
00402   Teuchos::RCP<const Epetra_CrsGraph> input_graph_;
00403   Teuchos::RCP<const Epetra_RowMatrix> input_matrix_;
00404   Teuchos::RCP<const Epetra_MultiVector> input_coords_;
00405   Teuchos::RCP<Isorropia::Epetra::CostDescriber> costs_;
00406   Teuchos::RCP<const Epetra_MultiVector> weights_;
00407 
00408   Teuchos::ParameterList paramlist_;
00409 
00410   int exportsSize_;
00411   std::vector<int> imports_;
00412   std::vector<int> properties_;
00413 
00414   bool operation_already_computed_;
00415 
00416   int global_num_vertex_weights_;
00417   int global_num_graph_edge_weights_;
00418   int global_num_hg_edge_weights_;
00419 
00420   Teuchos::RCP<Library> lib_;
00421 
00422   int base_;
00423 
00424   void computeNumberOfProperties();
00425 };//class Operator
00426 
00427 }//namespace Epetra
00428 }//namespace Isorropia
00429 
00430 #endif //HAVE_EPETRA
00431 
00432 #endif
00433