Epetra Package Browser (Single Doxygen Collection) Development
Epetra_FECrsMatrix.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2011 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_FECRSMATRIX_H
00045 #define EPETRA_FECRSMATRIX_H
00046 
00047 #include <Epetra_CrsMatrix.h>
00048 #include <Epetra_CombineMode.h>
00049 
00050 #include <vector>
00051 
00052 class Epetra_Map;
00053 class Epetra_IntSerialDenseVector;
00054 class Epetra_SerialDenseMatrix;
00055 class Epetra_FECrsGraph;
00056 
00114 class EPETRA_LIB_DLL_EXPORT Epetra_FECrsMatrix : public Epetra_CrsMatrix {
00115   public:
00117    Epetra_FECrsMatrix(Epetra_DataAccess CV,
00118           const Epetra_Map& RowMap,
00119           int* NumEntriesPerRow,
00120           bool ignoreNonLocalEntries=false);
00121 
00123    Epetra_FECrsMatrix(Epetra_DataAccess CV,
00124           const Epetra_Map& RowMap,
00125           int NumEntriesPerRow,
00126           bool ignoreNonLocalEntries=false);
00127 
00129    Epetra_FECrsMatrix(Epetra_DataAccess CV,
00130           const Epetra_Map& RowMap,
00131           const Epetra_Map& ColMap,
00132           int* NumEntriesPerRow,
00133           bool ignoreNonLocalEntries=false);
00134 
00136    Epetra_FECrsMatrix(Epetra_DataAccess CV,
00137           const Epetra_Map& RowMap,
00138           const Epetra_Map& ColMap,
00139           int NumEntriesPerRow,
00140           bool ignoreNonLocalEntries=false);
00141 
00143    Epetra_FECrsMatrix(Epetra_DataAccess CV,
00144           const Epetra_CrsGraph& Graph,
00145           bool ignoreNonLocalEntries=false);
00146 
00148    Epetra_FECrsMatrix(Epetra_DataAccess CV,
00149          const Epetra_FECrsGraph& Graph,
00150          bool ignoreNonLocalEntries=false);
00151 
00153    Epetra_FECrsMatrix(const Epetra_FECrsMatrix& src);
00154 
00156    virtual ~Epetra_FECrsMatrix();
00157 
00159    Epetra_FECrsMatrix& operator=(const Epetra_FECrsMatrix& src);
00160 
00161    enum { ROW_MAJOR = 0, COLUMN_MAJOR = 3 };
00162 
00163    using Epetra_CrsMatrix::SumIntoGlobalValues;
00164    using Epetra_CrsMatrix::InsertGlobalValues;
00165    using Epetra_CrsMatrix::ReplaceGlobalValues;
00166 
00168    int SumIntoGlobalValues(int GlobalRow, int NumEntries,
00169                            const double* Values, const int* Indices);
00170 
00172    int InsertGlobalValues(int GlobalRow, int NumEntries,
00173                            const double* Values, const int* Indices);
00174 
00176    int InsertGlobalValues(int GlobalRow, int NumEntries,
00177                            double* Values, int* Indices);
00178 
00180    int ReplaceGlobalValues(int GlobalRow, int NumEntries,
00181                            const double* Values, const int* Indices);
00182 
00198    int SumIntoGlobalValues(int numIndices, const int* indices,
00199                            const double* values,
00200                            int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00201 
00218    int SumIntoGlobalValues(int numRows, const int* rows,
00219                            int numCols, const int* cols,
00220                            const double* values,
00221                            int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00222 
00237    int SumIntoGlobalValues(int numIndices, const int* indices,
00238                            const double* const* values,
00239                            int format=Epetra_FECrsMatrix::ROW_MAJOR);
00240 
00256    int SumIntoGlobalValues(int numRows, const int* rows,
00257                      int numCols, const int* cols,
00258                            const double* const* values,
00259                            int format=Epetra_FECrsMatrix::ROW_MAJOR);
00260 
00275    int InsertGlobalValues(int numIndices, const int* indices,
00276                            const double* values,
00277                            int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00278 
00294    int InsertGlobalValues(int numRows, const int* rows,
00295                            int numCols, const int* cols,
00296                            const double* values,
00297                            int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00298 
00312    int InsertGlobalValues(int numIndices, const int* indices,
00313                            const double* const* values,
00314                            int format=Epetra_FECrsMatrix::ROW_MAJOR);
00315 
00330    int InsertGlobalValues(int numRows, const int* rows,
00331                      int numCols, const int* cols,
00332                            const double* const* values,
00333                            int format=Epetra_FECrsMatrix::ROW_MAJOR);
00334 
00350    int ReplaceGlobalValues(int numIndices, const int* indices,
00351                            const double* values,
00352                            int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00353 
00371    int ReplaceGlobalValues(int numRows, const int* rows,
00372                            int numCols, const int* cols,
00373                            const double* values,
00374                            int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00375 
00390    int ReplaceGlobalValues(int numIndices, const int* indices,
00391                            const double* const* values,
00392                            int format=Epetra_FECrsMatrix::ROW_MAJOR);
00393 
00409    int ReplaceGlobalValues(int numRows, const int* rows,
00410                            int numCols, const int* cols,
00411                            const double* const* values,
00412                            int format=Epetra_FECrsMatrix::ROW_MAJOR);
00413 
00424    int SumIntoGlobalValues(const Epetra_IntSerialDenseVector& indices,
00425          const Epetra_SerialDenseMatrix& values,
00426          int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00427 
00442    int SumIntoGlobalValues(const Epetra_IntSerialDenseVector& rows,
00443          const Epetra_IntSerialDenseVector& cols,
00444          const Epetra_SerialDenseMatrix& values,
00445          int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00446 
00457    int InsertGlobalValues(const Epetra_IntSerialDenseVector& indices,
00458          const Epetra_SerialDenseMatrix& values,
00459          int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00460 
00475    int InsertGlobalValues(const Epetra_IntSerialDenseVector& rows,
00476          const Epetra_IntSerialDenseVector& cols,
00477          const Epetra_SerialDenseMatrix& values,
00478          int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00479 
00491    int ReplaceGlobalValues(const Epetra_IntSerialDenseVector& indices,
00492          const Epetra_SerialDenseMatrix& values,
00493          int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00494 
00509    int ReplaceGlobalValues(const Epetra_IntSerialDenseVector& rows,
00510          const Epetra_IntSerialDenseVector& cols,
00511          const Epetra_SerialDenseMatrix& values,
00512          int format=Epetra_FECrsMatrix::COLUMN_MAJOR);
00513 
00535    int GlobalAssemble(bool callFillComplete=true, Epetra_CombineMode combineMode=Add);
00536 
00562    int GlobalAssemble(const Epetra_Map& domain_map,
00563                       const Epetra_Map& range_map,
00564                       bool callFillComplete=true,
00565                       Epetra_CombineMode combineMode=Add);
00566 
00570    void setIgnoreNonLocalEntries(bool flag) {
00571      ignoreNonLocalEntries_ = flag;
00572    }
00573 
00574   private:
00575    void DeleteMemory();
00576 
00577    enum {SUMINTO = 0, REPLACE = 1, INSERT = 2};
00578 
00579    int InputGlobalValues(int numRows, const int* rows,
00580                          int numCols, const int* cols,
00581                          const double* const* values,
00582                          int format,
00583                          int mode);
00584 
00585    int InputGlobalValues(int numRows, const int* rows,
00586                          int numCols, const int* cols,
00587                          const double* values,
00588                          int format,
00589                          int mode);
00590 
00591    int InputNonlocalGlobalValues(int row,
00592          int numCols, const int* cols,
00593          const double* values,
00594          int mode);
00595 
00596   int InputGlobalValues_RowMajor(
00597             int numRows, const int* rows,
00598             int numCols, const int* cols,
00599             const double* values,
00600             int mode);
00601 
00602    int InsertNonlocalRow(int row, std::vector<int>::iterator offset);
00603 
00604    int InputNonlocalValue(int rowoffset,
00605         int col, double value,
00606         int mode);
00607 
00608    int myFirstRow_;
00609    int myNumRows_;
00610 
00611    bool ignoreNonLocalEntries_;
00612 
00613    std::vector<int> nonlocalRows_;
00614    std::vector<std::vector<int> > nonlocalCols_;
00615    std::vector<std::vector<double> > nonlocalCoefs_;
00616 
00617    //IMPORTANT NOTE: The use of class-member work-data arrays is
00618    //**NOT** thread-safe.
00619    std::vector<double> workData_;
00620    std::vector<const double*> workData2d_;
00621    int workDataLength_;
00622 
00623    bool useNonlocalMatrix_;
00624    Epetra_CrsMatrix* nonlocalMatrix_;
00625 };//class Epetra_FECrsMatrix
00626 
00627 #endif /* EPETRA_FECRSMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines