Tpetra_BlockMultiVector_def.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //          Tpetra: Templated Linear Algebra Services Package
00005 //                 Copyright (2008) 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 #ifndef TPETRA_BLOCKMULTIVECTOR_DEF_HPP
00030 #define TPETRA_BLOCKMULTIVECTOR_DEF_HPP
00031 
00032 #include "Tpetra_ConfigDefs.hpp"
00033 
00034 namespace Tpetra {
00035 
00036 template<class Scalar,class LocalOrdinal,class GlobalOrdinal,class Node>
00037 BlockMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::BlockMultiVector(const Teuchos::RCP<const BlockMap<LocalOrdinal,GlobalOrdinal,Node> >& blockMap, size_t NumVectors, bool zeroOut)
00038  : MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(blockMap->getPointMap(), NumVectors, zeroOut),
00039    blockMap_(blockMap)
00040 {
00041 }
00042 
00043 template<class Scalar,class LocalOrdinal,class GlobalOrdinal,class Node>
00044 LocalOrdinal BlockMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getLocalPointIndex(GlobalOrdinal globalBlockRow, LocalOrdinal blockOffset) const
00045 {
00046   LocalOrdinal LBID = blockMap_->getLocalBlockID(globalBlockRow);
00047 
00048   TEST_FOR_EXCEPTION( LBID == Teuchos::OrdinalTraits<LocalOrdinal>::invalid(), std::runtime_error, "Tpetra::BlockMultiVector::getLocalPointIndex ERROR: specified globalBlockRow not found in local block-map.");
00049 
00050   LocalOrdinal blkSize = blockMap_->getLocalBlockSize(LBID);
00051 
00052   TEST_FOR_EXCEPTION( blockOffset >= blkSize, std::runtime_error,
00053      "Tpetra::BlockMultiVector::getLocalPointIndex ERROR: specified blockOffset >= blockSize.");
00054 
00055   LocalOrdinal pointIndex = blockMap_->getFirstLocalPointInLocalBlock(LBID);
00056 
00057   return pointIndex + blockOffset;
00058 }
00059 
00060 template<class Scalar,class LocalOrdinal,class GlobalOrdinal,class Node>
00061 void
00062 BlockMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceGlobalValue(GlobalOrdinal globalBlockRow, LocalOrdinal blockOffset, size_t vectorIndex, const Scalar &value)
00063 {
00064   LocalOrdinal pointIndex = getLocalPointIndex(globalBlockRow, blockOffset);
00065 
00066   replaceLocalValue(pointIndex, vectorIndex, value);
00067 }
00068 
00069 template<class Scalar,class LocalOrdinal,class GlobalOrdinal,class Node>
00070 void
00071 BlockMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceLocalValue(LocalOrdinal localBlockRow, LocalOrdinal blockOffset, size_t vectorIndex, const Scalar &value)
00072 {
00073   LocalOrdinal pointIndex = blockMap_->getFirstLocalPointInLocalBlock(localBlockRow);
00074 
00075   replaceLocalValue(pointIndex+blockOffset, vectorIndex, value);
00076 }
00077 
00078 template<class Scalar,class LocalOrdinal,class GlobalOrdinal,class Node>
00079 void
00080 BlockMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoGlobalValue(GlobalOrdinal globalBlockRow, LocalOrdinal blockOffset, size_t vectorIndex, const Scalar &value)
00081 {
00082   LocalOrdinal pointIndex = getLocalPointIndex(globalBlockRow, blockOffset);
00083 
00084   sumIntoLocalValue(pointIndex, vectorIndex, value);
00085 }
00086 
00087 template<class Scalar,class LocalOrdinal,class GlobalOrdinal,class Node>
00088 void
00089 BlockMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoLocalValue(LocalOrdinal localBlockRow, LocalOrdinal blockOffset, size_t vectorIndex, const Scalar &value)
00090 {
00091   LocalOrdinal pointIndex = blockMap_->getFirstLocalPointInLocalBlock(localBlockRow);
00092 
00093   sumIntoLocalValue(pointIndex+blockOffset, vectorIndex, value);
00094 }
00095 
00096 //
00097 // Explicit instantiation macro
00098 //
00099 // Must be expanded from within the Tpetra namespace!
00100 //
00101 
00102 #define TPETRA_BLOCKMULTIVECTOR_INSTANT(SCALAR,LO,GO,NODE) \
00103   \
00104   template class BlockMultiVector< SCALAR , LO , GO , NODE >;
00105 
00106 }//namespace Tpetra
00107 
00108 #endif
00109 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:21:40 2011 for Tpetra Matrix/Vector Services by  doxygen 1.6.3