EpetraExt Development
EpetraExt_PointToBlockDiagPermute.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_POINTTOBLOCKDIAGPERMUTE_H
00043 #define EPETRAEXT_POINTTOBLOCKDIAGPERMUTE_H
00044 
00045 #include "Epetra_DistObject.h"
00046 #include "Epetra_BlockMap.h"
00047 #include "Epetra_BlockMap.h"
00048 #include "Epetra_Map.h"
00049 #include "Epetra_Operator.h"
00050 #include "Epetra_CrsMatrix.h"
00051 #include "Epetra_FECrsMatrix.h"
00052 #include "Teuchos_ParameterList.hpp"
00053 
00054 class Epetra_Comm;
00055 class Epetra_Import;
00056 class Epetra_Export;
00057 class EpetraExt_BlockDiagMatrix;
00058 
00060 
00068 // NTS: Map() == RowMap is the convention
00069 
00070 //=========================================================================
00071 class EpetraExt_PointToBlockDiagPermute : public virtual Epetra_Operator, public Epetra_DistObject {
00072 public:
00073 
00075 
00076 
00077   EpetraExt_PointToBlockDiagPermute(const Epetra_CrsMatrix& MAT);
00079   
00081 
00082 
00083   virtual ~EpetraExt_PointToBlockDiagPermute();
00085 
00086   
00088 
00089 
00091   virtual int SetParameters(Teuchos::ParameterList & List);
00092   
00094   virtual int SetUseTranspose(bool UseTranspose){return -1;}
00095 
00097   virtual int Compute();
00098   
00100   
00102 
00103 
00105 
00113   virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00114 
00116 
00127   virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00128   
00130   virtual double NormInf() const {return -1;}
00132   
00134 
00135 
00137   virtual const char * Label() const{return "Fix Me";}
00138 
00140   virtual bool UseTranspose() const {return false;}
00141 
00143   virtual bool HasNormInf() const {return false;}
00144 
00146   virtual const Epetra_Comm & Comm() const {return Map().Comm();}
00147   
00149   //operator. 
00150   virtual const Epetra_Map & OperatorDomainMap() const {return Matrix_->OperatorDomainMap();}
00151 
00153   //operator.
00154   virtual const Epetra_Map & OperatorRangeMap() const {return Matrix_->OperatorRangeMap();}
00155 
00156   
00158   virtual const EpetraExt_BlockDiagMatrix & BlockMatrix(){return *BDMat_;}
00159   
00160 
00162   virtual Epetra_FECrsMatrix * CreateFECrsMatrix();
00163 
00165 
00166 
00167   virtual void Print(ostream& os) const;
00168 
00170 
00171 
00173 
00174 
00176 
00188   int Import(const Epetra_SrcDistObject& A, const Epetra_Import& Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
00189 
00191 
00203   int Import(const Epetra_SrcDistObject& A, const Epetra_Export& Exporter, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
00204 
00206 
00218   int Export(const Epetra_SrcDistObject& A, const Epetra_Import & Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
00219 
00221 
00233   int Export(const Epetra_SrcDistObject& A, const Epetra_Export& Exporter, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
00235   
00236  protected:
00237 
00238 
00240 
00241 
00242   virtual int CheckSizes(const Epetra_SrcDistObject& Source);
00244   virtual int CopyAndPermute(const Epetra_SrcDistObject& Source,
00245                              int NumSameIDs, 
00246                              int NumPermuteIDs,
00247                              int * PermuteToLIDs,
00248                              int * PermuteFromLIDs,
00249                              const Epetra_OffsetIndex * Indexor);
00250 
00252   virtual int PackAndPrepare(const Epetra_SrcDistObject& Source,
00253                              int NumExportIDs,
00254                              int* ExportLIDs,
00255                              int& LenExports,
00256                              char*& Exports,
00257                              int& SizeOfPacket,
00258                              int* Sizes,
00259                              bool & VarSizes,
00260                              Epetra_Distributor& Distor);
00261   
00263   virtual int UnpackAndCombine(const Epetra_SrcDistObject& Source, 
00264                                int NumImportIDs,
00265                                int* ImportLIDs, 
00266                                int LenImports,
00267                                char* Imports,
00268                                int& SizeOfPacket, 
00269                                Epetra_Distributor& Distor,
00270                                Epetra_CombineMode CombineMode,
00271                                const Epetra_OffsetIndex * Indexor);
00272 
00274 
00275 private:
00277   int ExtractBlockDiagonal();
00278 
00280   int SetupContiguousMode();
00281   int CleanupContiguousMode();
00282 
00283   // Copied from Epetra_CrsMatrix
00284   void UpdateImportVector(int NumVectors) const;
00285   void UpdateExportVector(int NumVectors) const;
00286 
00287   Teuchos::ParameterList List_;
00288   const Epetra_CrsMatrix* Matrix_;  
00289   bool PurelyLocalMode_;  
00290 
00291   // For contiguous blocking only
00292   bool ContiguousBlockMode_;
00293   int ContiguousBlockSize_;
00294 
00295   int NumBlocks_;
00296   int *Blockstart_;
00297   int *Blockids_;
00298   Epetra_BlockMap *BDMap_;
00299   Epetra_Map *CompatibleMap_; //A map compatible with BD's block map - used for imports
00300   EpetraExt_BlockDiagMatrix* BDMat_;
00301   Epetra_Import *Importer_;
00302   Epetra_Export *Exporter_;
00303   mutable Epetra_MultiVector *ImportVector_;
00304   mutable Epetra_MultiVector *ExportVector_;
00305   
00306 
00307 };  /* EPETRAEXT_POINTTOBLOCKDIAGPERMUTE_H */
00308 
00309 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines