EpetraExt_Dirichlet_CrsMatrix.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_Dirichlet_CrsMatrix.h>
00030 
00031 #include <Epetra_CrsMatrix.h>
00032 #include <Epetra_IntVector.h>
00033 #include <Epetra_Import.h>
00034 #include <Epetra_Map.h>
00035 
00036 namespace EpetraExt {
00037 
00038 bool
00039 CrsMatrix_Dirichlet::
00040 fwd()
00041 {
00042   Epetra_CrsMatrix & Matrix = *origObj_;
00043 
00044   const Epetra_Map & RowMap = Matrix.RowMap();
00045   const Epetra_Map & ColMap = Matrix.ColMap();
00046 
00047   int NumMyElements = RowMap.NumMyElements();
00048   int NumMyColElements = ColMap.NumMyElements();
00049 
00050   if( symmetric_ && colSet_.empty() ) // get non-local column info
00051   {
00052     if( Matrix.IndicesAreGlobal() )
00053     {
00054       Epetra_Import Importer( ColMap, RowMap );
00055       Epetra_IntVector colLocations( ColMap );
00056       colLocations.Import( locations_, Importer, Insert );
00057       for( int i = 0; i < NumMyColElements; ++ i )
00058         if( colLocations[i] ) colSet_.insert(i);
00059     }
00060     else
00061     {
00062       for( int i = 0; i < NumMyElements; ++i )
00063         if( locations_[i] ) colSet_.insert(i);
00064     }
00065   }
00066 
00067   for( int i = 0; i < NumMyElements; ++i ) 
00068   {
00069     int * Indices;
00070     double * Vals;
00071     int NumIndices;
00072     if( locations_[i] ) //this is a Dirichlet BC location
00073     {
00074       Matrix.ExtractMyRowView( i, NumIndices, Vals, Indices );
00075       for( int j = 0; j < NumIndices; ++j )
00076       {
00077         if( Indices[j] == i ) Vals[i] = 1.0;
00078         else                  Vals[i] = 0.0;
00079       }
00080     }
00081     else if( symmetric_ )
00082     {
00083       Matrix.ExtractMyRowView( i, NumIndices, Vals, Indices );
00084       for( int j = 0; j < NumIndices; ++j )
00085         if( colSet_.count( Indices[j] ) ) Vals[j] = 0.0;
00086     }
00087   }
00088 
00089   return true;
00090 }
00091 
00092 bool
00093 CrsMatrix_Dirichlet::
00094 rvs()
00095 {
00096   return true;
00097 }
00098 
00099 } //namespace EpetraExt
00100 

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