|
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_Overlap_CrsGraph.h> 00030 00031 #include <Epetra_Import.h> 00032 #include <Epetra_CrsGraph.h> 00033 #include <Epetra_Map.h> 00034 00035 namespace EpetraExt { 00036 00037 CrsGraph_Overlap:: 00038 ~CrsGraph_Overlap() 00039 { 00040 if( newObj_ ) delete newObj_; 00041 00042 if( OverlapMap_ ) delete OverlapMap_; 00043 } 00044 00045 CrsGraph_Overlap::NewTypeRef 00046 CrsGraph_Overlap:: 00047 operator()( OriginalTypeRef orig ) 00048 { 00049 origObj_ = &orig; 00050 00051 //check that this is a distributed graph and overlap level is not zero 00052 if( orig.DomainMap().DistributedGlobal() && levelOverlap_ ) 00053 { 00054 Epetra_CrsGraph * OverlapGraph = new Epetra_CrsGraph( orig ); 00055 OverlapMap_ = new Epetra_BlockMap( orig.RowMap() ); 00056 00057 Epetra_BlockMap * DomainMap = &(const_cast<Epetra_BlockMap&>(orig.DomainMap())); 00058 Epetra_BlockMap * RangeMap = &(const_cast<Epetra_BlockMap&>(orig.RangeMap())); 00059 00060 for( int level = 0; level < levelOverlap_; ++level ) 00061 { 00062 Epetra_BlockMap * OldRowMap = OverlapMap_; 00063 Epetra_CrsGraph * OldGraph = OverlapGraph; 00064 00065 Epetra_Import & OverlapImporter = *(const_cast<Epetra_Import *>( OldGraph->Importer() )); 00066 OverlapMap_ = new Epetra_BlockMap( OverlapImporter.TargetMap() ); 00067 00068 //filter to local square block on last level if required 00069 if( squareLocalBlock_ && level==(levelOverlap_-1) ) 00070 OverlapGraph = new Epetra_CrsGraph( Copy, *OverlapMap_, *OverlapMap_, 0 ); 00071 else 00072 OverlapGraph = new Epetra_CrsGraph( Copy, *OverlapMap_, 0 ); 00073 00074 OverlapGraph->Import( *OldGraph, OverlapImporter, Insert ); 00075 OverlapGraph->FillComplete( *DomainMap, *RangeMap ); 00076 00077 delete OldGraph; 00078 delete OldRowMap; 00079 } 00080 00081 newObj_ = OverlapGraph; 00082 } 00083 else //just create a copy since this is not a InPlaceTransform 00084 newObj_ = new Epetra_CrsGraph( orig ); 00085 00086 return *newObj_; 00087 } 00088 00089 } // namespace EpetraExt
1.7.4