IFPACK Development
Ifpack_Graph_Epetra_RowMatrix.cpp
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) 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 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 */
00042 
00043 #include "Ifpack_ConfigDefs.h"
00044 #include "Ifpack_Graph.h"
00045 #include "Ifpack_Graph_Epetra_RowMatrix.h"
00046 #include "Epetra_Comm.h"
00047 #include "Epetra_Map.h"
00048 #include "Epetra_RowMatrix.h"
00049 
00050 //==============================================================================
00051 Ifpack_Graph_Epetra_RowMatrix::Ifpack_Graph_Epetra_RowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& RowMatrix) :
00052 RowMatrix_(RowMatrix)
00053 {
00054   NumMyRows_ = RowMatrix_->NumMyRows();
00055   NumMyCols_ = RowMatrix_->NumMyCols();
00056   NumGlobalRows_ = RowMatrix_->NumGlobalRows64();
00057   NumGlobalCols_ = RowMatrix_->NumGlobalCols64();
00058   MaxNumIndices_ = RowMatrix_->MaxNumEntries();
00059 
00060   Values_.resize(MaxNumIndices_);
00061 }
00062 
00063 //==============================================================================
00064 const Epetra_Comm& Ifpack_Graph_Epetra_RowMatrix::Comm() const
00065 {
00066   return(RowMatrix_->Comm());
00067 }
00068 
00069 //==============================================================================
00070 bool Ifpack_Graph_Epetra_RowMatrix::Filled() const
00071 {
00072   return(RowMatrix_->Filled());
00073 }
00074  
00075 //==============================================================================
00076 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00077 int Ifpack_Graph_Epetra_RowMatrix::GRID(int LRID_in) const
00078 {
00079   return(RowMatrix_->RowMatrixRowMap().GID(LRID_in));
00080 }
00081 
00082 //==============================================================================
00083 int Ifpack_Graph_Epetra_RowMatrix::GCID(int LCID_in) const
00084 {
00085   return(RowMatrix_->RowMatrixColMap().GID(LCID_in));
00086 }
00087 #endif
00088 
00089 long long Ifpack_Graph_Epetra_RowMatrix::GRID64(int LRID_in) const
00090 {
00091   return(RowMatrix_->RowMatrixRowMap().GID64(LRID_in));
00092 }
00093 
00094 //==============================================================================
00095 long long Ifpack_Graph_Epetra_RowMatrix::GCID64(int LCID_in) const
00096 {
00097   return(RowMatrix_->RowMatrixColMap().GID64(LCID_in));
00098 }
00099 
00100 //==============================================================================
00101 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00102 int Ifpack_Graph_Epetra_RowMatrix::LRID(int GRID_in) const
00103 {
00104   return(RowMatrix_->RowMatrixRowMap().LID(GRID_in));
00105 }
00106 
00107 //==============================================================================
00108 int Ifpack_Graph_Epetra_RowMatrix::LCID(int GCID_in) const
00109 {
00110   return(RowMatrix_->RowMatrixColMap().LID(GCID_in));
00111 }
00112 #endif
00113 //==============================================================================
00114 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00115 int Ifpack_Graph_Epetra_RowMatrix::LRID(long long GRID_in) const
00116 {
00117   return(RowMatrix_->RowMatrixRowMap().LID(GRID_in));
00118 }
00119 
00120 //==============================================================================
00121 int Ifpack_Graph_Epetra_RowMatrix::LCID(long long GCID_in) const
00122 {
00123   return(RowMatrix_->RowMatrixColMap().LID(GCID_in));
00124 }
00125 #endif
00126 //==============================================================================
00127 int Ifpack_Graph_Epetra_RowMatrix::
00128 ExtractMyRowCopy(int MyRow, int LenOfIndices, 
00129          int &NumIndices, int *Indices) const
00130 {
00131   return(RowMatrix_->ExtractMyRowCopy(MyRow, LenOfIndices,
00132                       NumIndices, &Values_[0],
00133                       Indices));
00134 }
00135 
00136 //==============================================================================
00137 int Ifpack_Graph_Epetra_RowMatrix::NumMyNonzeros() const
00138 {
00139   return(RowMatrix_->NumMyNonzeros());
00140 }
00141 
00142 // ======================================================================
00143 ostream& Ifpack_Graph_Epetra_RowMatrix::Print(std::ostream& os) const
00144 {
00145 
00146   if (Comm().MyPID())
00147     return(os);
00148 
00149   os << "================================================================================" << endl;
00150   os << "Ifpack_Graph_Epetra_RowMatrix" << endl;
00151   os << "Number of local rows  = " << NumMyRows_ << endl;
00152   os << "Number of global rows = " << NumGlobalRows_ << endl;
00153   os << "================================================================================" << endl;
00154 
00155   return(os);
00156 
00157 }
00158 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends