EpetraExt Development
EpetraExt_BlockDiagMatrix.h
Go to the documentation of this file.
00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00005 //                 Copyright (2011) Sandia Corporation
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
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 #ifndef EPETRAEXT_BLOCKDIAGMATRIX_H
00043 #define EPETRAEXT_BLOCKDIAGMATRIX_H
00044 
00045 #include "Epetra_BLAS.h"
00046 #include "Epetra_LAPACK.h"
00047 #include "Epetra_DistObject.h"
00048 #include "Epetra_BlockMap.h"
00049 #include "Epetra_Map.h"
00050 #include "Epetra_Operator.h"
00051 #include "Teuchos_ParameterList.hpp"
00052 
00053 class Epetra_Comm;
00054 
00056 
00065 //=========================================================================
00066 class EpetraExt_BlockDiagMatrix : public virtual Epetra_Operator, public Epetra_DistObject,public Epetra_BLAS {
00067 
00068  public:
00070   EpetraExt_BlockDiagMatrix(const Epetra_BlockMap& Map,bool zero_out=true);
00071 
00072   
00074   EpetraExt_BlockDiagMatrix(const EpetraExt_BlockDiagMatrix& Source);
00075     
00077   virtual ~EpetraExt_BlockDiagMatrix();
00078 
00080 
00086   EpetraExt_BlockDiagMatrix& operator = (const EpetraExt_BlockDiagMatrix& Source);
00087   
00089 
00092   double* operator [] (int index) {return &Values_[DataMap_->FirstPointInElement(index)];}
00094 
00097   const double* operator [] (int index) const {return &Values_[DataMap_->FirstPointInElement(index)];}
00099 
00100 
00102 
00103 
00105   virtual int SetUseTranspose(bool UseTranspose){return -1;}
00106 
00108   virtual int SetParameters(Teuchos::ParameterList & List);
00109 
00111   virtual int Compute();
00112 
00114 
00115   
00117 
00118 
00120   virtual const char * Label() const{return "EpetraExt::BlockDiagMatrix";}//HAQ
00121   
00123   virtual bool UseTranspose() const {return false;}
00124 
00126   virtual bool HasNormInf() const {return false;}
00127 
00129   virtual const Epetra_Comm & Comm() const {return Map().Comm();}
00130 
00132   virtual const Epetra_Map & OperatorDomainMap() const {return *dynamic_cast<const Epetra_Map*>(&Map());}
00133 
00135   virtual const Epetra_Map & OperatorRangeMap() const {return *dynamic_cast<const Epetra_Map*>(&Map());}
00136 
00138   virtual const Epetra_BlockMap & BlockMap() const {return Map();} 
00139   
00141   double* Values() const {return(Values_);}
00142 
00144   int BlockSize(int LID) const {return Map().ElementSize(LID);}
00145 
00147   int DataSize(int LID) const {return DataMap_->ElementSize(LID);}
00148 
00150   bool ConstantBlockSize() const {return Map().ConstantElementSize();}
00151   
00153   int NumMyBlocks() const {return(Map().NumMyElements());}
00154 
00156   int NumGlobalBlocks() const {return(Map().NumGlobalElements());}
00157   
00159   int NumMyUnknowns() const {return(Map().NumMyPoints());}
00160 
00162   int NumGlobalUnknowns() const {return(Map().NumGlobalPoints());}
00163 
00165   int NumData() const {return DataMap_->NumMyPoints();}
00166   
00168   int GetApplyMode() {return ApplyMode_;}
00169 
00171   virtual void Print(ostream & os) const;  
00172 
00174 
00175   
00177 
00178 
00180 
00187   virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {return -1;}
00188   
00190 
00201   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00202 
00204   virtual double NormInf() const{return -1;}
00205 
00207   void PutScalar(double value);
00208 
00210   virtual const Epetra_BlockMap & DataMap() const {return *DataMap_;}   
00211 
00213 
00214   
00215 private:
00216   void Allocate();
00217   
00218   int DoCopy(const EpetraExt_BlockDiagMatrix& Source);
00219 
00220   // Routines to implement Epetra_DistObject virtual methods
00221   // Allows the source and target (\e this) objects to be compared for compatibility, return nonzero if not.
00222   int CheckSizes(const Epetra_SrcDistObject& Source);
00223   // Perform ID copies and permutations that are on processor.
00224   int CopyAndPermute(const Epetra_SrcDistObject& Source,
00225                      int NumSameIDs, 
00226                      int NumPermuteIDs,
00227                      int * PermuteToLIDs,
00228                      int * PermuteFromLIDs,
00229                      const Epetra_OffsetIndex * Indexor);
00230 
00231   // Perform any packing or preparation required for call to DoTransfer().
00232   int PackAndPrepare(const Epetra_SrcDistObject& Source,
00233                      int NumExportIDs,
00234                      int* ExportLIDs,
00235                      int& LenExports,
00236                      char*& Exports,
00237                      int& SizeOfPacket,
00238                      int* Sizes,
00239                      bool & VarSizes,
00240                      Epetra_Distributor& Distor);
00241   
00242   // Perform any unpacking and combining after call to DoTransfer().
00243   int UnpackAndCombine(const Epetra_SrcDistObject& Source, 
00244                        int NumImportIDs,
00245                        int* ImportLIDs, 
00246                        int LenImports,
00247                        char* Imports,
00248                        int& SizeOfPacket, 
00249                        Epetra_Distributor& Distor,
00250                        Epetra_CombineMode CombineMode,
00251                        const Epetra_OffsetIndex * Indexor);
00252 
00253   Epetra_LAPACK LAPACK;
00254   Teuchos::ParameterList List_;
00255 
00257   bool HasComputed_;
00258   
00260   int ApplyMode_;
00261 
00263   Epetra_BlockMap* DataMap_;
00264   
00266   double *Values_;
00267 
00269   int *Pivots_;
00270 
00271 };  /* EPETRAEXT_BLOCKDIAGMATRIX_H */
00272 
00273 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines