Epetra Package Browser (Single Doxygen Collection) Development
Epetra_FEVbrMatrix.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2001 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_FEVBRMATRIX_H
00045 #define EPETRA_FEVBRMATRIX_H
00046 
00047 #include <Epetra_VbrMatrix.h>
00048 #include <Epetra_SerialDenseMatrix.h>
00049 
00057 class EPETRA_LIB_DLL_EXPORT Epetra_FEVbrMatrix: public Epetra_VbrMatrix {
00058  public:
00059 
00061 
00062 
00063 
00075   Epetra_FEVbrMatrix(Epetra_DataAccess CV,
00076          const Epetra_BlockMap& RowMap,
00077          int *NumBlockEntriesPerRow,
00078          bool ignoreNonLocalEntries=false);
00079   
00081 
00094   Epetra_FEVbrMatrix(Epetra_DataAccess CV,
00095          const Epetra_BlockMap& RowMap,
00096          int NumBlockEntriesPerRow,
00097          bool ignoreNonLocalEntries=false);
00098 
00100 
00115   Epetra_FEVbrMatrix(Epetra_DataAccess CV,
00116          const Epetra_BlockMap& RowMap,
00117          const Epetra_BlockMap& ColMap,
00118          int *NumBlockEntriesPerRow,
00119          bool ignoreNonLocalEntries=false);
00120   
00122 
00138   Epetra_FEVbrMatrix(Epetra_DataAccess CV,
00139          const Epetra_BlockMap& RowMap,
00140          const Epetra_BlockMap& ColMap,
00141          int NumBlockEntriesPerRow,
00142          bool ignoreNonLocalEntries=false);
00143 
00146   Epetra_FEVbrMatrix(Epetra_DataAccess CV,
00147          const Epetra_CrsGraph& Graph,
00148          bool ignoreNonLocalEntries=false);
00149 
00151   Epetra_FEVbrMatrix(const Epetra_FEVbrMatrix& src);
00152 
00154   virtual ~Epetra_FEVbrMatrix();
00156   
00158 
00159 
00160   Epetra_FEVbrMatrix& operator=(const Epetra_FEVbrMatrix& src);
00161 
00163 
00169     int PutScalar(double ScalarConstant);
00170 
00172 
00182     int BeginInsertGlobalValues(int BlockRow, int NumBlockEntries, int * BlockIndices);
00183 
00185 
00195     int BeginReplaceGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
00196 
00198 
00208     int BeginSumIntoGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
00209 
00210     //Let the compiler know we intend to overload the base-class function
00211     //SubmitBlockEntry rather than hide it.
00212     using Epetra_VbrMatrix::SubmitBlockEntry;
00213 
00215     /* Submit a block entry that will recorded in the block row that was initiated by one of the
00216        Begin routines listed above.  Once a one of the following routines: BeginInsertGlobalValues(),
00217        BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
00218        BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values 
00219        corresponding to the block indices passed in to the Begin routine.  If the Epetra_VbrMatrix constuctor
00220        was called in Copy mode, the values will be copied.  However, no copying will be done until the EndSubmitEntries()
00221        function is call to complete submission of the current block row.  If the constructor was called in View mode, all
00222        block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
00223        that was passed in by the user.
00224 
00225        For performance reasons, SubmitBlockEntry() does minimal processing of data.  Any processing that can be
00226        delayed is performed in EndSubmitEntries().
00227 
00228     \param In
00229            Values - The starting address of the values.
00230     \param In
00231            LDA - The stride between successive columns of Values.
00232     \param In
00233            NumRows - The number of rows passed in.
00234     \param In
00235            NumCols - The number of columns passed in.
00236 
00237     \return Integer error code, set to 0 if successful.
00238     */
00239     int SubmitBlockEntry(double *Values, int LDA, int NumRows, int NumCols);
00240 
00242 
00247     int EndSubmitEntries();
00248 
00249     int GlobalAssemble(bool callFillComplete=true);
00250 
00251  private:
00252     int SetupForNonlocalSubmits(int BlockRow,
00253         int NumBlockEntries,
00254         int * BlockIndices, 
00255         bool IndicesAreLocal,
00256         Epetra_CombineMode SubmitMode);
00257 
00258     int InputNonlocalBlockEntry(double *Values, int LDA,
00259         int NumRows, int NumCols);
00260 
00261     int InsertNonlocalRow(int row, int offset, int numCols);
00262 
00263     void destroyNonlocalData();
00264 
00265     bool ignoreNonLocalEntries_;
00266 
00267     int numNonlocalBlockRows_;
00268     int* nonlocalBlockRows_;
00269     int* nonlocalBlockRowLengths_;
00270     int* nonlocalBlockRowAllocLengths_;
00271     int** nonlocalBlockCols_;
00272 
00273     //Triple-pointers are gross, but we need one here. We want a 2-D table of
00274     //pointer-to-matrix objects. If we only use a double-pointer, it would be
00275     //too hard to change the lengths of the rows of the table.
00276 
00277     Epetra_SerialDenseMatrix*** nonlocalCoefs_;
00278 
00279     //Following the approach Mike uses in Epetra_VbrMatrix, we need some state
00280     //variables to keep track of block-entry submits.
00281     int curRowOffset_;
00282     int curColOffset_;
00283     int curNumCols_;
00284     int* curCols_;
00285     int curMode_;
00286 };
00287 
00288 #endif /* EPETRA_FEVBRMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines