EpetraExt_LPTrans_From_GraphTrans.cpp

Go to the documentation of this file.
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_GraphTrans.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_GraphTrans::
00045 ~LinearProblem_GraphTrans()
00046 {
00047   if( MatExporter_ ) delete MatExporter_;
00048   if( VecExporter_ ) delete VecExporter_;
00049   if( Importer_ ) delete Importer_;
00050 
00051   if( NewProblem_ ) delete NewProblem_;
00052   if( NewRHS_ ) delete NewRHS_;
00053   if( NewLHS_ ) delete NewLHS_;
00054   if( NewMatrix_ ) delete NewMatrix_;
00055 }
00056 
00057 LinearProblem_GraphTrans::NewTypeRef
00058 LinearProblem_GraphTrans::
00059 operator()( OriginalTypeRef orig )
00060 {
00061   OldProblem_ = &orig;
00062   OldMatrix_ = dynamic_cast<Epetra_CrsMatrix*>( orig.GetMatrix() );
00063   OldGraph_ = const_cast<Epetra_CrsGraph*>(&OldMatrix_->Graph());
00064   OldRHS_ = orig.GetRHS();
00065   OldLHS_ = orig.GetLHS();
00066   OldRowMap_ = const_cast<Epetra_Map*>(&OldMatrix_->RowMap());
00067 
00068   int ierr = 0;
00069 
00070 
00071   if( !OldMatrix_ ) ierr = -2;
00072   if( !OldRHS_ )    ierr = -3;
00073   if( !OldLHS_ )    ierr = -4;
00074 
00075   Epetra_CrsGraph & NewGraph = graphTrans_( *OldGraph_ );
00076   NewMatrix_ = new Epetra_CrsMatrix( Copy, NewGraph );
00077 
00078   Epetra_BlockMap & NewRowMap = const_cast<Epetra_BlockMap&>(NewGraph.RowMap());
00079 
00080   NewRHS_ = new Epetra_MultiVector( NewRowMap, 1 );
00081   NewLHS_ = new Epetra_MultiVector( NewRowMap, 1 );
00082 
00083   MatExporter_ = new Epetra_Export( *OldRowMap_, NewRowMap );
00084   VecExporter_ = new Epetra_Export( *OldRowMap_, NewRowMap );
00085   Importer_ = new Epetra_Import( *OldRowMap_, NewRowMap );
00086 
00087   NewProblem_ = new Epetra_LinearProblem( NewMatrix_, NewLHS_, NewRHS_ );
00088 
00089   return *NewProblem_;
00090 }
00091 
00092 bool
00093 LinearProblem_GraphTrans::
00094 fwd()
00095 {
00096   NewLHS_->Export( *OldLHS_, *VecExporter_, Insert );
00097   NewRHS_->Export( *OldRHS_, *VecExporter_, Insert );
00098   NewMatrix_->Export( *OldMatrix_, *MatExporter_, Insert );
00099 
00100   return true;
00101 }
00102 
00103 bool
00104 LinearProblem_GraphTrans::
00105 rvs()
00106 {
00107   OldLHS_->Import( *NewLHS_, *Importer_, Insert );
00108 //  OldRHS_->Import( *NewRHS_, *Importer_, Insert );
00109 //  OldMatrix_->Import( *NewMatrix_, *Importer_, Insert );
00110 
00111   return true;
00112 }
00113 
00114 } //namespace EpetraExt
00115 

Generated on Thu Sep 18 12:31:43 2008 for EpetraExt by doxygen 1.3.9.1