Isorropia: Partitioning, Load Balancing and more
Isorropia_EpetraOperator.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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 //************************************************************************
00038 //@HEADER
00039 
00040 #ifndef _Isorropia_EpetraOperator_hpp_
00041 #define _Isorropia_EpetraOperator_hpp_
00042 
00043 #include <Isorropia_ConfigDefs.hpp>
00044 #include <Teuchos_RCP.hpp>
00045 #include <Teuchos_ParameterList.hpp>
00046 
00047 #include <Isorropia_EpetraCostDescriber.hpp>
00048 #include <Isorropia_Operator.hpp>
00049 #include <Isorropia_EpetraLibrary.hpp>
00050 
00051 #ifdef HAVE_EPETRA
00052 class Epetra_Map;
00053 class Epetra_BlockMap;
00054 class Epetra_Import;
00055 class Epetra_Vector;
00056 class Epetra_MultiVector;
00057 class Epetra_CrsGraph;
00058 class Epetra_CrsMatrix;
00059 class Epetra_RowMatrix;
00060 class Epetra_LinearProblem;
00061 
00062 namespace Isorropia {
00063 
00064 namespace Epetra {
00065   class CostDescriber;
00066 
00072 class Operator : virtual public Isorropia::Operator {
00073 public:
00074 
00075 //   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, int base);
00076 
00077 //   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, int base);
00078 
00079 //   Operator(Teuchos::RCP<const Epetra_MultiVector> input_coords, int base);
00080 
00081 //   Operator(Teuchos::RCP<const Epetra_BlockMap> input_map, int base);
00082 
00083 //   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph, 
00084 //     Teuchos::RCP<const Epetra_MultiVector> input_coords, int base);
00085 
00086 //   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, 
00087 //     Teuchos::RCP<const Epetra_MultiVector> input_coords, int base);
00088 
00089 
00105   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00106               const Teuchos::ParameterList& paramlist, int base);
00107 
00108 
00123   Operator(Teuchos::RCP<const Epetra_BlockMap> input_map,
00124               const Teuchos::ParameterList& paramlist, int base);
00125 
00126 
00127 
00147   Operator(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00148      Teuchos::RCP<const Epetra_MultiVector> input_coords,
00149            const Teuchos::ParameterList& paramlist, int base);
00150 
00151 
00171   Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00172             Teuchos::RCP<CostDescriber> costs,
00173               const Teuchos::ParameterList& paramlist, int base);
00174 
00175 
00201   Operator (Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00202             Teuchos::RCP<CostDescriber> costs,
00203       Teuchos::RCP<const Epetra_MultiVector> coords,
00204       Teuchos::RCP<const Epetra_MultiVector> weights,
00205               const Teuchos::ParameterList& paramlist, int base);
00206 
00207 
00223   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00224      const Teuchos::ParameterList& paramlist, int base);
00225 
00226 
00246   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00247      Teuchos::RCP<const Epetra_MultiVector> coords,
00248      const Teuchos::ParameterList& paramlist, int base);
00249 
00250 
00270   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00271      Teuchos::RCP<CostDescriber> costs,
00272      const Teuchos::ParameterList& paramlist, int base);
00273 
00274 
00301   Operator(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00302      Teuchos::RCP<CostDescriber> costs,
00303      Teuchos::RCP<const Epetra_MultiVector> coords,
00304      Teuchos::RCP<const Epetra_MultiVector> weights,
00305      const Teuchos::ParameterList& paramlist, int base);
00306 
00307 
00324   Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
00325      const Teuchos::ParameterList& paramlist, int base);
00326 
00346   Operator(Teuchos::RCP<const Epetra_MultiVector> coords,
00347            Teuchos::RCP<const Epetra_MultiVector> weights,
00348      const Teuchos::ParameterList& paramlist, int base);
00349 
00351   virtual ~Operator();
00352 
00356   void setParameters(const Teuchos::ParameterList& paramlist);
00357 
00361   Teuchos::RCP<Isorropia::Epetra::CostDescriber> & getCosts() { return costs_; }
00362 
00363   virtual void compute(bool force_compute) = 0 ;
00364 
00367   bool alreadyComputed() const {
00368     return operation_already_computed_;
00369   }
00370 
00371   int numProperties() const {
00372     return (numberOfProperties_);
00373   }
00374 
00375   int numLocalProperties() const {
00376     return (localNumberOfProperties_);
00377   }
00378 
00382   virtual const int& operator[](int myElem) const;
00383 
00386   virtual int numElemsWithProperty(int property) const;
00387 
00391   virtual void elemsWithProperty(int property,
00392        int* elementList,
00393        int len) const;
00394 
00395   virtual int extractPropertiesCopy(int len,
00396             int& size,
00397             int* array) const ;
00398 
00399   virtual int extractPropertiesView(int& size,
00400             const int*& array) const;
00401 
00402 private:
00403 
00404   void paramsToUpper(Teuchos::ParameterList &, int &changed, bool rmUnderscore=true);
00405   void stringToUpper(std::string &s, int &changed, bool rmUnderscore=false);
00406   int numberOfProperties_;
00407   int localNumberOfProperties_;
00408   std::vector<int> numberElemsByProperties_;
00409 
00410 protected:
00411   Teuchos::RCP<const Epetra_BlockMap> input_map_;
00412   Teuchos::RCP<const Epetra_CrsGraph> input_graph_;
00413   Teuchos::RCP<const Epetra_RowMatrix> input_matrix_;
00414   Teuchos::RCP<const Epetra_MultiVector> input_coords_;
00415   Teuchos::RCP<Isorropia::Epetra::CostDescriber> costs_;
00416   Teuchos::RCP<const Epetra_MultiVector> weights_;
00417 
00418   Teuchos::ParameterList paramlist_;
00419 
00420   int exportsSize_;
00421   std::vector<int> imports_;
00422   std::vector<int> properties_;
00423 
00424   bool operation_already_computed_;
00425 
00426   int global_num_vertex_weights_;
00427   int global_num_graph_edge_weights_;
00428   int global_num_hg_edge_weights_;
00429 
00430   Teuchos::RCP<Library> lib_;
00431 
00432   int base_;
00433 
00434   void computeNumberOfProperties();
00435 };//class Operator
00436 
00437 }//namespace Epetra
00438 }//namespace Isorropia
00439 
00440 #endif //HAVE_EPETRA
00441 
00442 #endif
00443