|
EpetraExt Development
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // EpetraExt: Epetra Extended - Linear Algebra Services Package 00005 // Copyright (2001) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #include <EpetraExt_LPTrans_From_MatrixTrans.h> 00030 00031 #include <Epetra_Export.h> 00032 #include <Epetra_Import.h> 00033 #include <Epetra_LinearProblem.h> 00034 #include <Epetra_CrsGraph.h> 00035 #include <Epetra_CrsMatrix.h> 00036 #include <Epetra_MultiVector.h> 00037 #include <Epetra_Vector.h> 00038 #include <Epetra_IntVector.h> 00039 #include <Epetra_Map.h> 00040 #include <Epetra_Comm.h> 00041 00042 namespace EpetraExt { 00043 00044 LinearProblem_MatrixTrans:: 00045 ~LinearProblem_MatrixTrans() 00046 { 00047 if( Exporter_ ) delete Exporter_; 00048 if( Importer_ ) delete Importer_; 00049 00050 if( NewProblem_ ) delete NewProblem_; 00051 if( NewRHS_ ) delete NewRHS_; 00052 if( NewLHS_ ) delete NewLHS_; 00053 } 00054 00055 LinearProblem_MatrixTrans::NewTypeRef 00056 LinearProblem_MatrixTrans:: 00057 operator()( OriginalTypeRef orig ) 00058 { 00059 OldProblem_ = &orig; 00060 OldMatrix_ = dynamic_cast<Epetra_CrsMatrix*>( orig.GetMatrix() ); 00061 OldRHS_ = orig.GetRHS(); 00062 OldLHS_ = orig.GetLHS(); 00063 OldRowMap_ = const_cast<Epetra_Map*>(&OldMatrix_->RowMap()); 00064 00065 int ierr = 0; 00066 00067 00068 if( !OldMatrix_ ) ierr = -2; 00069 if( !OldRHS_ ) ierr = -3; 00070 if( !OldLHS_ ) ierr = -4; 00071 00072 NewMatrix_ = &(matrixTrans_( *OldMatrix_ )); 00073 00074 Epetra_BlockMap & NewRowMap = const_cast<Epetra_BlockMap&>(NewMatrix_->Graph().RowMap()); 00075 00076 NewRHS_ = new Epetra_MultiVector( NewRowMap, 1 ); 00077 NewLHS_ = new Epetra_MultiVector( NewRowMap, 1 ); 00078 00079 Exporter_ = new Epetra_Export( *OldRowMap_, NewRowMap ); 00080 Importer_ = new Epetra_Import( NewRowMap, *OldRowMap_ ); 00081 00082 NewProblem_ = new Epetra_LinearProblem( NewMatrix_, NewLHS_, NewRHS_ ); 00083 00084 return *NewProblem_; 00085 } 00086 00087 bool 00088 LinearProblem_MatrixTrans:: 00089 fwd() 00090 { 00091 NewLHS_->Export( *OldLHS_, *Exporter_, Insert ); 00092 NewRHS_->Export( *OldRHS_, *Exporter_, Insert ); 00093 NewMatrix_->Export( *OldMatrix_, *Exporter_, Insert ); 00094 00095 return true; 00096 } 00097 00098 bool 00099 LinearProblem_MatrixTrans:: 00100 rvs() 00101 { 00102 OldLHS_->Import( *NewLHS_, *Exporter_, Insert ); 00103 OldRHS_->Import( *NewRHS_, *Exporter_, Insert ); 00104 OldMatrix_->Import( *NewMatrix_, *Exporter_, Insert ); 00105 00106 return true; 00107 } 00108 00109 } //namespace EpetraExt 00110
1.7.4