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   virtual void Print(ostream & os) const;
00159 
00160   
00162 
00163 
00165 
00172   virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {return -1;}
00173   
00175 
00186   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00187 
00189   virtual double NormInf() const{return -1;}
00190 
00192   void PutScalar(double value);
00193 
00195   
00196   
00197 private:
00198   void Allocate();
00199   
00200   int DoCopy(const EpetraExt_BlockDiagMatrix& Source);
00201 
00202   // Routines to implement Epetra_DistObject virtual methods
00203   // Allows the source and target (\e this) objects to be compared for compatibility, return nonzero if not.
00204   int CheckSizes(const Epetra_SrcDistObject& Source);
00205   // Perform ID copies and permutations that are on processor.
00206   int CopyAndPermute(const Epetra_SrcDistObject& Source,
00207                      int NumSameIDs, 
00208                      int NumPermuteIDs,
00209                      int * PermuteToLIDs,
00210                      int * PermuteFromLIDs,
00211                      const Epetra_OffsetIndex * Indexor);
00212 
00213   // Perform any packing or preparation required for call to DoTransfer().
00214   int PackAndPrepare(const Epetra_SrcDistObject& Source,
00215                      int NumExportIDs,
00216                      int* ExportLIDs,
00217                      int& LenExports,
00218                      char*& Exports,
00219                      int& SizeOfPacket,
00220                      int* Sizes,
00221                      bool & VarSizes,
00222                      Epetra_Distributor& Distor);
00223   
00224   // Perform any unpacking and combining after call to DoTransfer().
00225   int UnpackAndCombine(const Epetra_SrcDistObject& Source, 
00226                        int NumImportIDs,
00227                        int* ImportLIDs, 
00228                        int LenImports,
00229                        char* Imports,
00230                        int& SizeOfPacket, 
00231                        Epetra_Distributor& Distor,
00232                        Epetra_CombineMode CombineMode,
00233                        const Epetra_OffsetIndex * Indexor);
00234 
00235   Epetra_LAPACK LAPACK;
00236   Teuchos::ParameterList List_;
00237 
00239   bool HasComputed_;
00240   
00242   int ApplyMode_;
00243 
00245   Epetra_BlockMap* DataMap_;
00246   
00248   double *Values_;
00249 
00251   int *Pivots_;
00252 
00253 };  /* EPETRAEXT_BLOCKDIAGMATRIX_H */
00254 
00255 #endif

Generated on Wed May 12 21:24:45 2010 for EpetraExt by  doxygen 1.4.7