00001 /* @HEADER@ */ 00002 /* *********************************************************************** 00003 // 00004 // TSFExtended: Trilinos Solver Framework Extended 00005 // Copyright (2004) 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 TSFLOADABLEBLOCKOPERATOR_DECL_HPP 00030 #define TSFLOADABLEBLOCKOPERATOR_DECL_HPP 00031 00032 #include "SundanceDefs.hpp" 00033 #include "Teuchos_RCP.hpp" 00034 #include "TSFSimpleBlockOpDecl.hpp" 00035 #include "TSFLoadableMatrix.hpp" 00036 00037 namespace TSFExtended 00038 { 00039 using namespace Teuchos; 00040 /** 00041 * Class LoadableBlockOperator provides a LoadableMatrix interface 00042 * for a physically-partitioned block 2x2 matrix, making it appear 00043 * to the fill routine as if the block matrix is a single matrix. This 00044 * is intended for filling systems where the internal and BC equations 00045 * and unknowns are stored in physically separate blocks. 00046 */ 00047 template <class Scalar> 00048 class LoadableBlockOperator 00049 : public SimpleBlockOp<Scalar>, 00050 public LoadableMatrix<Scalar> 00051 { 00052 public: 00053 /** */ 00054 LoadableBlockOperator( 00055 const VectorSpace<Scalar>& domain, 00056 int lowestLocalCol, 00057 const RCP<Array<int> >& isBCCol, 00058 const RCP<std::set<int> >& remoteBCCols, 00059 const VectorSpace<Scalar>& range, 00060 int lowestLocalRow, 00061 const RCP<Array<int> >& isBCRow); 00062 00063 /** Virtual dtor */ 00064 virtual ~LoadableBlockOperator(){;} 00065 00066 /** Insert a set of elements in a row, adding to any previously 00067 * existing values. The nonzero structure of the matrix must have 00068 * been determined at construction time. 00069 * 00070 * @param globalRowIndex the global index of the row to which these 00071 * elements belong. 00072 * @param nElemsToInsert the number of elements being inserted in this 00073 * step 00074 * @param globalColumnIndices array of column indices. Must 00075 * be nElemsToInsert in length. 00076 * @param elements array of element values. Must be nElemsToInsert in 00077 * length 00078 */ 00079 virtual void addToRow(int globalRowIndex, 00080 int nElemsToInsert, 00081 const int* globalColumnIndices, 00082 const Scalar* elementValues) ; 00083 00084 /** Set all elements to zero, preserving the existing structure */ 00085 virtual void zero() ; 00086 00087 00088 private: 00089 00090 00091 /** Cast a block to LoadableMatrix, with safety checks */ 00092 RCP<LoadableMatrix<Scalar> > loadableBlock(int i, int j); 00093 00094 RCP<Array<int> > isBCCol_; 00095 RCP<Array<int> > isBCRow_; 00096 RCP<std::set<int> > remoteBCCols_; 00097 int lowestLocalRow_; 00098 int lowestLocalCol_; 00099 int highestLocalRow_; 00100 int highestLocalCol_; 00101 }; 00102 } 00103 00104 #endif