|
EpetraExt
Development
|
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 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 00157 int NumGlobalBlocks() const {return(Map().NumGlobalElements());} 00158 #endif 00159 long long NumGlobalBlocks64() const {return(Map().NumGlobalElements64());} 00160 00162 int NumMyUnknowns() const {return(Map().NumMyPoints());} 00163 00165 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 00166 int NumGlobalUnknowns() const {return(Map().NumGlobalPoints());} 00167 #endif 00168 long long NumGlobalUnknowns64() const {return(Map().NumGlobalPoints64());} 00169 00171 int NumData() const {return DataMap_->NumMyPoints();} 00172 00174 int GetApplyMode() {return ApplyMode_;} 00175 00177 virtual void Print(std::ostream & os) const; 00178 00180 00181 00183 00184 00186 00193 virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {return -1;} 00194 00196 00207 virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00208 00210 virtual double NormInf() const{return -1;} 00211 00213 void PutScalar(double value); 00214 00216 virtual const Epetra_BlockMap & DataMap() const {return *DataMap_;} 00217 00219 00220 00221 private: 00222 void Allocate(); 00223 00224 int DoCopy(const EpetraExt_BlockDiagMatrix& Source); 00225 00226 // Routines to implement Epetra_DistObject virtual methods 00227 // Allows the source and target (\e this) objects to be compared for compatibility, return nonzero if not. 00228 int CheckSizes(const Epetra_SrcDistObject& Source); 00229 // Perform ID copies and permutations that are on processor. 00230 int CopyAndPermute(const Epetra_SrcDistObject& Source, 00231 int NumSameIDs, 00232 int NumPermuteIDs, 00233 int * PermuteToLIDs, 00234 int * PermuteFromLIDs, 00235 const Epetra_OffsetIndex * Indexor, 00236 Epetra_CombineMode CombineMode = Zero); 00237 00238 // Perform any packing or preparation required for call to DoTransfer(). 00239 int PackAndPrepare(const Epetra_SrcDistObject& Source, 00240 int NumExportIDs, 00241 int* ExportLIDs, 00242 int& LenExports, 00243 char*& Exports, 00244 int& SizeOfPacket, 00245 int* Sizes, 00246 bool & VarSizes, 00247 Epetra_Distributor& Distor); 00248 00249 // Perform any unpacking and combining after call to DoTransfer(). 00250 int UnpackAndCombine(const Epetra_SrcDistObject& Source, 00251 int NumImportIDs, 00252 int* ImportLIDs, 00253 int LenImports, 00254 char* Imports, 00255 int& SizeOfPacket, 00256 Epetra_Distributor& Distor, 00257 Epetra_CombineMode CombineMode, 00258 const Epetra_OffsetIndex * Indexor); 00259 00260 Epetra_LAPACK LAPACK; 00261 Teuchos::ParameterList List_; 00262 00264 bool HasComputed_; 00265 00267 int ApplyMode_; 00268 00270 Epetra_BlockMap* DataMap_; 00271 00273 double *Values_; 00274 00276 int *Pivots_; 00277 00278 }; /* EPETRAEXT_BLOCKDIAGMATRIX_H */ 00279 00280 #endif
1.7.6.1