EpetraExt Development
EpetraExt_BlockDiagMatrix.h
Go to the documentation of this file.
00001 //@HEADER
00002 /*
00003 ************************************************************************
00004 
00005               EpetraExt: Extended Linear Algebra Services Package 
00006                 Copyright (2001) 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 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 
00027 ************************************************************************
00028 */
00029 //@HEADER
00030 
00031 #ifndef EPETRAEXT_BLOCKDIAGMATRIX_H
00032 #define EPETRAEXT_BLOCKDIAGMATRIX_H
00033 
00034 #include "Epetra_BLAS.h"
00035 #include "Epetra_LAPACK.h"
00036 #include "Epetra_DistObject.h"
00037 #include "Epetra_BlockMap.h"
00038 #include "Epetra_Map.h"
00039 #include "Epetra_Operator.h"
00040 #include "Teuchos_ParameterList.hpp"
00041 
00042 class Epetra_Comm;
00043 
00045 
00054 //=========================================================================
00055 class EpetraExt_BlockDiagMatrix : public virtual Epetra_Operator, public Epetra_DistObject,public Epetra_BLAS {
00056 
00057  public:
00059   EpetraExt_BlockDiagMatrix(const Epetra_BlockMap& Map,bool zero_out=true);
00060 
00061   
00063   EpetraExt_BlockDiagMatrix(const EpetraExt_BlockDiagMatrix& Source);
00064     
00066   virtual ~EpetraExt_BlockDiagMatrix();
00067 
00069 
00075   EpetraExt_BlockDiagMatrix& operator = (const EpetraExt_BlockDiagMatrix& Source);
00076   
00078 
00081   double* operator [] (int index) {return &Values_[DataMap_->FirstPointInElement(index)];}
00083 
00086   const double* operator [] (int index) const {return &Values_[DataMap_->FirstPointInElement(index)];}
00088 
00089 
00091 
00092 
00094   virtual int SetUseTranspose(bool UseTranspose){return -1;}
00095 
00097   virtual int SetParameters(Teuchos::ParameterList & List);
00098 
00100   virtual int Compute();
00101 
00103 
00104   
00106 
00107 
00109   virtual const char * Label() const{return "EpetraExt::BlockDiagMatrix";}//HAQ
00110   
00112   virtual bool UseTranspose() const {return false;}
00113 
00115   virtual bool HasNormInf() const {return false;}
00116 
00118   virtual const Epetra_Comm & Comm() const {return Map().Comm();}
00119 
00121   virtual const Epetra_Map & OperatorDomainMap() const {return *dynamic_cast<const Epetra_Map*>(&Map());}
00122 
00124   virtual const Epetra_Map & OperatorRangeMap() const {return *dynamic_cast<const Epetra_Map*>(&Map());}
00125 
00127   virtual const Epetra_BlockMap & BlockMap() const {return Map();} 
00128   
00130   double* Values() const {return(Values_);}
00131 
00133   int BlockSize(int LID) const {return Map().ElementSize(LID);}
00134 
00136   int DataSize(int LID) const {return DataMap_->ElementSize(LID);}
00137 
00139   bool ConstantBlockSize() const {return Map().ConstantElementSize();}
00140   
00142   int NumMyBlocks() const {return(Map().NumMyElements());}
00143 
00145   int NumGlobalBlocks() const {return(Map().NumGlobalElements());}
00146   
00148   int NumMyUnknowns() const {return(Map().NumMyPoints());}
00149 
00151   int NumGlobalUnknowns() const {return(Map().NumGlobalPoints());}
00152 
00154   int NumData() const {return DataMap_->NumMyPoints();}
00155   
00157   int GetApplyMode() {return ApplyMode_;}
00158 
00160   virtual void Print(ostream & os) const;  
00161 
00163 
00164   
00166 
00167 
00169 
00176   virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {return -1;}
00177   
00179 
00190   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00191 
00193   virtual double NormInf() const{return -1;}
00194 
00196   void PutScalar(double value);
00197 
00199   virtual const Epetra_BlockMap & DataMap() const {return *DataMap_;}   
00200 
00202 
00203   
00204 private:
00205   void Allocate();
00206   
00207   int DoCopy(const EpetraExt_BlockDiagMatrix& Source);
00208 
00209   // Routines to implement Epetra_DistObject virtual methods
00210   // Allows the source and target (\e this) objects to be compared for compatibility, return nonzero if not.
00211   int CheckSizes(const Epetra_SrcDistObject& Source);
00212   // Perform ID copies and permutations that are on processor.
00213   int CopyAndPermute(const Epetra_SrcDistObject& Source,
00214                      int NumSameIDs, 
00215                      int NumPermuteIDs,
00216                      int * PermuteToLIDs,
00217                      int * PermuteFromLIDs,
00218                      const Epetra_OffsetIndex * Indexor);
00219 
00220   // Perform any packing or preparation required for call to DoTransfer().
00221   int PackAndPrepare(const Epetra_SrcDistObject& Source,
00222                      int NumExportIDs,
00223                      int* ExportLIDs,
00224                      int& LenExports,
00225                      char*& Exports,
00226                      int& SizeOfPacket,
00227                      int* Sizes,
00228                      bool & VarSizes,
00229                      Epetra_Distributor& Distor);
00230   
00231   // Perform any unpacking and combining after call to DoTransfer().
00232   int UnpackAndCombine(const Epetra_SrcDistObject& Source, 
00233                        int NumImportIDs,
00234                        int* ImportLIDs, 
00235                        int LenImports,
00236                        char* Imports,
00237                        int& SizeOfPacket, 
00238                        Epetra_Distributor& Distor,
00239                        Epetra_CombineMode CombineMode,
00240                        const Epetra_OffsetIndex * Indexor);
00241 
00242   Epetra_LAPACK LAPACK;
00243   Teuchos::ParameterList List_;
00244 
00246   bool HasComputed_;
00247   
00249   int ApplyMode_;
00250 
00252   Epetra_BlockMap* DataMap_;
00253   
00255   double *Values_;
00256 
00258   int *Pivots_;
00259 
00260 };  /* EPETRAEXT_BLOCKDIAGMATRIX_H */
00261 
00262 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines