Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_FECrsMatrix.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_FECRSMATRIX_H
45 #define EPETRA_FECRSMATRIX_H
46 
47 #include <Epetra_ConfigDefs.h>
48 #include <Epetra_CrsMatrix.h>
49 #include <Epetra_CombineMode.h>
50 
51 #include <vector>
52 
53 class Epetra_Map;
55 
56 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
58 #endif
59 
61 class Epetra_FECrsGraph;
62 
120 class EPETRA_LIB_DLL_EXPORT Epetra_FECrsMatrix : public Epetra_CrsMatrix {
121  public:
124  const Epetra_Map& RowMap,
125  int* NumEntriesPerRow,
126  bool ignoreNonLocalEntries=false);
127 
130  const Epetra_Map& RowMap,
131  int NumEntriesPerRow,
132  bool ignoreNonLocalEntries=false);
133 
136  const Epetra_Map& RowMap,
137  const Epetra_Map& ColMap,
138  int* NumEntriesPerRow,
139  bool ignoreNonLocalEntries=false);
140 
143  const Epetra_Map& RowMap,
144  const Epetra_Map& ColMap,
145  int NumEntriesPerRow,
146  bool ignoreNonLocalEntries=false);
147 
150  const Epetra_CrsGraph& Graph,
151  bool ignoreNonLocalEntries=false);
152 
155  const Epetra_FECrsGraph& Graph,
156  bool ignoreNonLocalEntries=false);
157 
160 
162  virtual ~Epetra_FECrsMatrix();
163 
166 
167  enum { ROW_MAJOR = 0, COLUMN_MAJOR = 3 };
168 
169 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
173 #endif
174 
176 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
177  int SumIntoGlobalValues(int GlobalRow, int NumEntries,
178  const double* Values, const int* Indices);
179 #endif
180 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
181  int SumIntoGlobalValues(long long GlobalRow, int NumEntries,
182  const double* Values, const long long* Indices);
183 #endif
184 
186 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
187  int InsertGlobalValues(int GlobalRow, int NumEntries,
188  const double* Values, const int* Indices);
189 #endif
190 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
191  int InsertGlobalValues(long long GlobalRow, int NumEntries,
192  const double* Values, const long long* Indices);
193 #endif
194 
196 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
197  int InsertGlobalValues(int GlobalRow, int NumEntries,
198  double* Values, int* Indices);
199 #endif
200 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
201  int InsertGlobalValues(long long GlobalRow, int NumEntries,
202  double* Values, long long* Indices);
203 #endif
204 
206 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
207  int ReplaceGlobalValues(int GlobalRow, int NumEntries,
208  const double* Values, const int* Indices);
209 #endif
210 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
211  int ReplaceGlobalValues(long long GlobalRow, int NumEntries,
212  const double* Values, const long long* Indices);
213 #endif
214 
230 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
231  int SumIntoGlobalValues(int numIndices, const int* indices,
232  const double* values,
234 #endif
235 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
236  int SumIntoGlobalValues(int numIndices, const long long* indices,
237  const double* values,
239 #endif
240 
257 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
258  int SumIntoGlobalValues(int numRows, const int* rows,
259  int numCols, const int* cols,
260  const double* values,
262 #endif
263 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
264  int SumIntoGlobalValues(int numRows, const long long* rows,
265  int numCols, const long long* cols,
266  const double* values,
268 #endif
269 
284 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
285  int SumIntoGlobalValues(int numIndices, const int* indices,
286  const double* const* values,
287  int format=Epetra_FECrsMatrix::ROW_MAJOR);
288 #endif
289 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
290  int SumIntoGlobalValues(int numIndices, const long long* indices,
291  const double* const* values,
292  int format=Epetra_FECrsMatrix::ROW_MAJOR);
293 #endif
294 
310 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
311  int SumIntoGlobalValues(int numRows, const int* rows,
312  int numCols, const int* cols,
313  const double* const* values,
314  int format=Epetra_FECrsMatrix::ROW_MAJOR);
315 #endif
316 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
317  int SumIntoGlobalValues(int numRows, const long long* rows,
318  int numCols, const long long* cols,
319  const double* const* values,
320  int format=Epetra_FECrsMatrix::ROW_MAJOR);
321 #endif
322 
337 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
338  int InsertGlobalValues(int numIndices, const int* indices,
339  const double* values,
341 #endif
342 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
343  int InsertGlobalValues(int numIndices, const long long* indices,
344  const double* values,
346 #endif
347 
363 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
364  int InsertGlobalValues(int numRows, const int* rows,
365  int numCols, const int* cols,
366  const double* values,
368 #endif
369 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
370  int InsertGlobalValues(int numRows, const long long* rows,
371  int numCols, const long long* cols,
372  const double* values,
374 #endif
375 
389 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
390  int InsertGlobalValues(int numIndices, const int* indices,
391  const double* const* values,
392  int format=Epetra_FECrsMatrix::ROW_MAJOR);
393 #endif
394 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
395  int InsertGlobalValues(int numIndices, const long long* indices,
396  const double* const* values,
397  int format=Epetra_FECrsMatrix::ROW_MAJOR);
398 #endif
399 
414 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
415  int InsertGlobalValues(int numRows, const int* rows,
416  int numCols, const int* cols,
417  const double* const* values,
418  int format=Epetra_FECrsMatrix::ROW_MAJOR);
419 #endif
420 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
421  int InsertGlobalValues(int numRows, const long long* rows,
422  int numCols, const long long* cols,
423  const double* const* values,
424  int format=Epetra_FECrsMatrix::ROW_MAJOR);
425 #endif
426 
442 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
443  int ReplaceGlobalValues(int numIndices, const int* indices,
444  const double* values,
446 #endif
447 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
448  int ReplaceGlobalValues(int numIndices, const long long* indices,
449  const double* values,
451 #endif
452 
470 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
471  int ReplaceGlobalValues(int numRows, const int* rows,
472  int numCols, const int* cols,
473  const double* values,
475 #endif
476 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
477  int ReplaceGlobalValues(int numRows, const long long* rows,
478  int numCols, const long long* cols,
479  const double* values,
481 #endif
482 
497 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
498  int ReplaceGlobalValues(int numIndices, const int* indices,
499  const double* const* values,
500  int format=Epetra_FECrsMatrix::ROW_MAJOR);
501 #endif
502 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
503  int ReplaceGlobalValues(int numIndices, const long long* indices,
504  const double* const* values,
505  int format=Epetra_FECrsMatrix::ROW_MAJOR);
506 #endif
507 
523 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
524  int ReplaceGlobalValues(int numRows, const int* rows,
525  int numCols, const int* cols,
526  const double* const* values,
527  int format=Epetra_FECrsMatrix::ROW_MAJOR);
528 #endif
529 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
530  int ReplaceGlobalValues(int numRows, const long long* rows,
531  int numCols, const long long* cols,
532  const double* const* values,
533  int format=Epetra_FECrsMatrix::ROW_MAJOR);
534 #endif
535 
546 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
548  const Epetra_SerialDenseMatrix& values,
550 #endif
551 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
553  const Epetra_SerialDenseMatrix& values,
555 #endif
556 
571 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
573  const Epetra_IntSerialDenseVector& cols,
574  const Epetra_SerialDenseMatrix& values,
576 #endif
577 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
580  const Epetra_SerialDenseMatrix& values,
582 #endif
583 
594 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
596  const Epetra_SerialDenseMatrix& values,
598 #endif
599 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
601  const Epetra_SerialDenseMatrix& values,
603 #endif
604 
619 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
621  const Epetra_IntSerialDenseVector& cols,
622  const Epetra_SerialDenseMatrix& values,
624 #endif
625 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
628  const Epetra_SerialDenseMatrix& values,
630 #endif
631 
643 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
645  const Epetra_SerialDenseMatrix& values,
647 #endif
648 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
650  const Epetra_SerialDenseMatrix& values,
652 #endif
653 
668 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
670  const Epetra_IntSerialDenseVector& cols,
671  const Epetra_SerialDenseMatrix& values,
673 #endif
674 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
677  const Epetra_SerialDenseMatrix& values,
679 #endif
680 
702  int GlobalAssemble(bool callFillComplete=true,
703  Epetra_CombineMode combineMode=Add,
704  bool save_off_and_reuse_map_exporter=false);
705 
731  int GlobalAssemble(const Epetra_Map& domain_map,
732  const Epetra_Map& range_map,
733  bool callFillComplete=true,
734  Epetra_CombineMode combineMode=Add,
735  bool save_off_and_reuse_map_exporter=false);
736 
740  void setIgnoreNonLocalEntries(bool flag) {
741  ignoreNonLocalEntries_ = flag;
742  }
743 
744  private:
745  void DeleteMemory();
746 
747  enum {SUMINTO = 0, REPLACE = 1, INSERT = 2};
748 
749  template<typename int_type>
750  int InputGlobalValues(int numRows, const int_type* rows,
751  int numCols, const int_type* cols,
752  const double* const* values,
753  int format,
754  int mode);
755 
756  template<typename int_type>
757  int InputGlobalValues(int numRows, const int_type* rows,
758  int numCols, const int_type* cols,
759  const double* values,
760  int format,
761  int mode);
762 
763  template<typename int_type>
764  int InputNonlocalGlobalValues(int_type row,
765  int numCols, const int_type* cols,
766  const double* values,
767  int mode);
768 
769  template<typename int_type>
770  int InputGlobalValues_RowMajor(
771  int numRows, const int_type* rows,
772  int numCols, const int_type* cols,
773  const double* values,
774  int mode);
775 
776  template<typename int_type>
777  int InsertNonlocalRow(int_type row, typename std::vector<int_type>::iterator offset);
778 
779  template<typename int_type>
780  int InputNonlocalValue(int rowoffset,
781  int_type col, double value,
782  int mode);
783 
784  long long myFirstRow_;
786 
788 
789 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
790  std::vector<int> nonlocalRows_int_;
791  std::vector<std::vector<int> > nonlocalCols_int_;
792 #endif
793 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
794  std::vector<long long> nonlocalRows_LL_;
795  std::vector<std::vector<long long> > nonlocalCols_LL_;
796 #endif
797 
798  template<typename int_type> std::vector<int_type>& nonlocalRows();
799  template<typename int_type> std::vector<std::vector<int_type> >& nonlocalCols();
800 
801  std::vector<std::vector<double> > nonlocalCoefs_;
802 
803  //IMPORTANT NOTE: The use of class-member work-data arrays is
804  //**NOT** thread-safe.
805  std::vector<double> workData_;
806  std::vector<const double*> workData2d_;
808 
811 
816 
817  template<typename int_type>
818  int SumIntoGlobalValues(int_type GlobalRow, int NumEntries, const double* values, const int_type* Indices);
819 
820  template<typename int_type>
821  int GlobalAssemble(const Epetra_Map& domain_map,
822  const Epetra_Map& range_map,
823  bool callFillComplete=true,
824  Epetra_CombineMode combineMode=Add,
825  bool save_off_and_reuse_map_exporter=false);
826 
827 };//class Epetra_FECrsMatrix
828 
829 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
830 template<> inline std::vector<int>& Epetra_FECrsMatrix::nonlocalRows<int>()
831 {
832  return nonlocalRows_int_;
833 }
834 #endif
835 
836 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
837 template<> inline std::vector<long long>& Epetra_FECrsMatrix::nonlocalRows<long long>()
838 {
839  return nonlocalRows_LL_;
840 }
841 #endif
842 
843 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
844 template<> inline std::vector<std::vector<int> >& Epetra_FECrsMatrix::nonlocalCols<int>()
845 {
846  return nonlocalCols_int_;
847 }
848 #endif
849 
850 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
851 template<> inline std::vector<std::vector<long long> >& Epetra_FECrsMatrix::nonlocalCols<long long>()
852 {
853  return nonlocalCols_LL_;
854 }
855 #endif
856 
857 
858 #endif /* EPETRA_FECRSMATRIX_H */
std::vector< const double * > workData2d_
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
Epetra_CrsMatrix * tempMat_
std::vector< std::vector< int > > nonlocalCols_int_
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given global row of the matrix.
Epetra Finite-Element CrsGraph.
virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Add this list of entries to existing values for a given global row of the matrix. ...
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:62
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
std::vector< int > nonlocalRows_int_
Epetra_Combine Mode enumerable type.
std::vector< long long > nonlocalRows_LL_
Epetra Finite-Element CrsMatrix.
Epetra_Export * exporter_
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
std::vector< std::vector< long long > > nonlocalCols_LL_
std::vector< std::vector< double > > nonlocalCoefs_
void setIgnoreNonLocalEntries(bool flag)
Set whether or not non-local data values should be ignored.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
Epetra_CrsMatrix & operator=(const Epetra_CrsMatrix &src)
Assignment operator.
Epetra_CombineMode
Epetra_DataAccess
std::vector< double > workData_
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Replace specified existing values with this list of entries for a given global row of the matrix...
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
Epetra_CrsMatrix * nonlocalMatrix_