56 int* NumEntriesPerRow,
57 bool ignoreNonLocalEntries)
62 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
66 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
87 bool ignoreNonLocalEntries)
92 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
96 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
117 int* NumEntriesPerRow,
118 bool ignoreNonLocalEntries)
123 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
127 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
148 int NumEntriesPerRow,
149 bool ignoreNonLocalEntries)
154 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
158 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
178 bool ignoreNonLocalEntries)
183 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
187 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
207 bool ignoreNonLocalEntries)
212 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
216 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
240 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
244 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
276 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
282 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
293 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
300 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
321 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
322 if (
RowMap().GlobalIndicesInt()) {
328 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
329 if (
RowMap().GlobalIndicesLongLong()) {
352 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
354 const double*
const* values,
362 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
364 const double*
const* values,
373 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
375 int numCols,
const int* cols,
376 const double*
const* values,
384 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
386 int numCols,
const long long* cols,
387 const double*
const* values,
396 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
398 const double* values,
406 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
408 const double* values,
417 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
419 int numCols,
const int* cols,
420 const double* values,
429 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
431 int numCols,
const long long* cols,
432 const double* values,
441 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
446 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
451 values.
A(), format) );
455 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
460 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
465 values.
A(), format) );
469 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
474 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
479 values.
A(), format) );
482 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
487 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
492 values.
A(), format) );
496 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
501 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
506 values.
A(), format) );
509 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
514 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
519 values.
A(), format) );
523 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
535 values.
A(), format) );
538 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
550 values.
A(), format) );
554 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
566 values.
A(), format) );
569 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
581 values.
A(), format) );
585 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
597 values.
A(), format) );
600 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
613 values.
A(), format) );
617 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
619 const double*
const* values,
627 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
630 const double*
const* values,
639 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
641 int numCols,
const int* cols,
642 const double*
const* values,
650 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
653 int numCols,
const long long* cols,
654 const double*
const* values,
663 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
665 const double* values,
673 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
676 const double* values,
685 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
687 int numCols,
const int* cols,
688 const double* values,
696 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
699 int numCols,
const long long* cols,
700 const double* values,
709 template<
typename int_type>
711 const double* values,
const int_type* Indices)
713 if (
Map().MyGID(GlobalRow))
718 NumEntries, values, Indices);
723 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
725 const double* values,
const int* Indices)
727 if(
RowMap().GlobalIndicesInt())
728 return SumIntoGlobalValues<int>(GlobalRow, NumEntries, values, Indices);
730 throw ReportError(
"Epetra_FECrsMatrix::SumIntoGlobalValues int version called for a matrix that is not int.", -1);
733 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
737 const double* values,
const long long* Indices)
739 if(
RowMap().GlobalIndicesLongLong())
740 return SumIntoGlobalValues<long long>(GlobalRow, NumEntries, values, Indices);
742 throw ReportError(
"Epetra_FECrsMatrix::SumIntoGlobalValues long long version called for a matrix that is not long long.", -1);
746 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
748 const double* values,
const int* Indices)
751 NumEntries, Indices, values,
755 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
758 const double* values,
const long long* Indices)
761 NumEntries, Indices, values,
766 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
768 double* values,
int* Indices)
771 NumEntries, Indices, values,
775 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
777 double* values,
long long* Indices)
780 NumEntries, Indices, values,
785 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
787 const double* values,
const int* Indices)
790 NumEntries, Indices, values,
794 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
796 const double* values,
const long long* Indices)
799 NumEntries, Indices, values,
804 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
806 const double*
const* values,
814 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
816 const double*
const* values,
825 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
827 int numCols,
const int* cols,
828 const double*
const* values,
836 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
838 int numCols,
const long long* cols,
839 const double*
const* values,
848 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
850 const double* values,
858 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
860 const double* values,
869 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
871 int numCols,
const int* cols,
872 const double* values,
880 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
882 int numCols,
const long long* cols,
883 const double* values,
893 bool save_off_and_reuse_map_exporter)
899 template<
typename int_type>
902 bool callFillComplete,
904 bool save_off_and_reuse_map_exporter)
907 if (callFillComplete) {
913 std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
914 std::vector<std::vector<int_type> >& nonlocalCols_var = nonlocalCols<int_type>();
936 if (callFillComplete) {
939 if (!save_off_and_reuse_map_exporter) {
949 bool first_time=!save_off_and_reuse_map_exporter;
952 std::vector<int_type> cols;
954 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
955 for(
size_t j=0; j<nonlocalCols_var[i].size(); ++j) {
956 int_type col = nonlocalCols_var[i][j];
957 typename std::vector<int_type>::iterator it =
958 std::lower_bound(cols.begin(), cols.end(), col);
959 if (it == cols.end() || *it != col) {
960 cols.insert(it, col);
973 std::vector<int> nonlocalRowLengths(nonlocalRows_var.size());
974 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
975 nonlocalRowLengths[i] = (int) nonlocalCols_var[i].size();
979 if ( first_time &&
tempMat_ == NULL )
984 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
987 (
int) nonlocalCols_var[i].size(),
992 (
int) nonlocalCols_var[i].size(),
998 if (!save_off_and_reuse_map_exporter) {
1024 if(callFillComplete) {
1030 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
1031 nonlocalCols_var[i].resize(0);
1036 if (!save_off_and_reuse_map_exporter) {
1048 bool callFillComplete,
1050 bool save_off_and_reuse_map_exporter)
1053 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: cannot be called with different indices types for domainMap and rangeMap", -1);
1056 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: cannot be called with different indices types for row map and incoming rangeMap", -1);
1059 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1060 return GlobalAssemble<int>(domain_map, range_map, callFillComplete, combineMode, save_off_and_reuse_map_exporter);
1062 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: ERROR, GlobalIndicesInt but no API for it.",-1);
1065 if(
RowMap().GlobalIndicesLongLong())
1066 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1067 return GlobalAssemble<long long>(domain_map, range_map, callFillComplete, combineMode, save_off_and_reuse_map_exporter);
1069 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: ERROR, GlobalIndicesLongLong but no API for it.",-1);
1072 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: Internal error, unable to determine global index type of maps", -1);
1076 template<
typename int_type>
1078 int numRows,
const int_type* rows,
1079 int numCols,
const int_type* cols,
1080 const double* values,
1083 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1084 throw ReportError(
"Epetra_FECrsMatrix::InputGlobalValues_RowMajor mismatch between argument types (int/long long) and map type.", -1);
1089 for(
int i=0; i<numRows; ++i) {
1090 double* valuesptr = (
double*)values + i*numCols;
1092 int local_row_id =
Map().
LID(rows[i]);
1093 if (local_row_id >= 0) {
1097 valuesptr, (int_type*)cols);
1098 if (err<0)
return(err);
1099 if (err>0) returncode = err;
1103 valuesptr, (int_type*)cols);
1104 if (err<0)
return(err);
1105 if (err>0) returncode = err;
1109 valuesptr, (int_type*)cols);
1110 if (err<0)
return(err);
1111 if (err>0) returncode = err;
1114 std::cerr <<
"Epetra_FECrsMatrix: internal error, bad input mode."<< std::endl;
1119 #ifdef EPETRA_HAVE_OMP
1120 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1126 if (err<0)
return(err);
1127 if (err>0) returncode = err;
1128 #ifdef EPETRA_HAVE_OMP
1129 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1140 template<
typename int_type>
1142 int numCols,
const int_type* cols,
1143 const double*
const* values,
1144 int format,
int mode)
1146 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1147 throw ReportError(
"Epetra_FECrsMatrix::InputGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1151 std::cerr <<
"Epetra_FECrsMatrix: unrecognized format specifier."<< std::endl;
1161 for(
int i=0; i<numRows; ++i) {
1165 if (returncode < 0)
return returncode;
1178 for(
int j=0; j<numCols; ++j) {
1179 valuesptr[j] = values[j][i];
1183 if (returncode < 0)
return returncode;
1190 template<
typename int_type>
1192 int numCols,
const int_type* cols,
1193 const double* values,
1194 int format,
int mode)
1196 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1197 throw ReportError(
"Epetra_FECrsMatrix::InputGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1206 for(
int i=0; i<numRows; ++i) {
1209 for(
int j=0; j<numCols; ++j) {
1213 if (err < 0)
return err;
1221 template<
typename int_type>
1223 int numCols,
const int_type* cols,
1224 const double* values,
1227 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1228 throw ReportError(
"Epetra_FECrsMatrix::InputNonlocalGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1232 int err, returncode = 0;
1233 double* valuesptr = (
double*)values;
1237 valuesptr, (int_type*)cols);
1238 if (err<0)
return(err);
1239 if (err>0) returncode = err;
1243 valuesptr, (int_type*)cols);
1244 if (err<0)
return(err);
1245 if (err>0) returncode = err;
1249 valuesptr, (int_type*)cols);
1250 if (err<0)
return(err);
1251 if (err>0) returncode = err;
1254 std::cerr <<
"Epetra_FECrsMatrix: internal error, bad input mode."<< std::endl;
1257 return (returncode);
1259 int ierr1 = 0, ierr2 = 0;
1260 #ifdef EPETRA_HAVE_OMP
1261 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1262 #pragma omp critical
1266 std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
1269 typename std::vector<int_type>::iterator it =
1270 std::lower_bound(nonlocalRows_var.begin(), nonlocalRows_var.end(), row);
1272 int rowoffset = (int) (it - nonlocalRows_var.begin());
1273 if (it == nonlocalRows_var.end() || *it != row) {
1277 for(
int i=0; i<numCols; ++i) {
1288 template<
typename int_type>
1291 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1292 throw ReportError(
"Epetra_FECrsMatrix::InsertNonlocalRow mismatch between argument types (int/long long) and map type.", -1);
1294 std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
1295 std::vector<std::vector<int_type> >& nonlocalCols_var = nonlocalCols<int_type>();
1297 int offset = (int) (iter - nonlocalRows_var.begin());
1298 nonlocalRows_var.insert(iter, row);
1299 typename std::vector<std::vector<int_type> >::iterator cols_iter = nonlocalCols_var.begin() + offset;
1300 nonlocalCols_var.insert(cols_iter, std::vector<int_type>());
1301 std::vector<std::vector<double> >::iterator coefs_iter =
nonlocalCoefs_.begin() + offset;
1308 template<
typename int_type>
1310 int_type col,
double value,
1313 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1314 throw ReportError(
"Epetra_FECrsMatrix::InputNonlocalValue mismatch between argument types (int/long long) and map type.", -1);
1316 std::vector<int_type>& colIndices = nonlocalCols<int_type>()[rowoffset];
1319 typename std::vector<int_type>::iterator it =
1320 std::lower_bound(colIndices.begin(), colIndices.end(), col);
1322 if (it == colIndices.end() || *it != col) {
1323 int offset = (int) (it - colIndices.begin());
1324 colIndices.insert(it, col);
1325 std::vector<double>::iterator dit = coefs.begin()+offset;
1326 coefs.insert(dit, value);
1330 int coloffset = (int) (it - colIndices.begin());
1332 coefs[coloffset] += value;
1335 coefs[coloffset] = value;
long long MinMyGID64() const
Epetra_Map: A class for partitioning vectors and matrices.
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
bool ignoreNonLocalEntries_
int Length() const
Returns length of vector.
int InputGlobalValues_RowMajor(int numRows, const int_type *rows, int numCols, const int_type *cols, const double *values, int mode)
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
long long * Values()
Returns pointer to the values in vector.
long long IndexBase64() const
Epetra_CrsMatrix * tempMat_
long long NumGlobalElements64() const
std::vector< std::vector< int > > nonlocalCols_int_
int InsertNonlocalRow(int_type row, typename std::vector< int_type >::iterator offset)
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. ...
T * Epetra_Util_data_ptr(std::vector< T > &vec)
Function that returns either a pointer to the first entry in the vector or, if the vector is empty...
#define EPETRA_CHK_ERR(a)
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
int InputNonlocalGlobalValues(int_type row, int numCols, const int_type *cols, const double *values, int mode)
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
std::vector< int > nonlocalRows_int_
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
int Length() const
Returns length of vector.
int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::InsertGlobalValues method
std::vector< long long > nonlocalRows_LL_
int PutScalar(double ScalarConstant)
Initialize all values in the matrix with constant value.
double * A() const
Returns pointer to the this matrix.
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
int NumMyElements() const
Number of elements on the calling processor.
Epetra Finite-Element CrsMatrix.
Epetra_FECrsMatrix & operator=(const Epetra_FECrsMatrix &src)
Assignment operator.
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Exports an Epetra_DistObject using the Epetra_Import object.
void SetIndicesAreGlobal(bool Flag)
Epetra_Export * exporter_
int GlobalAssemble(bool callFillComplete=true, Epetra_CombineMode combineMode=Add, bool save_off_and_reuse_map_exporter=false)
Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was ...
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
int InputGlobalValues(int numRows, const int_type *rows, int numCols, const int_type *cols, const double *const *values, int format, int mode)
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
std::vector< std::vector< long long > > nonlocalCols_LL_
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
std::vector< std::vector< double > > nonlocalCoefs_
int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::SumIntoGlobalValues method
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
Epetra_CrsMatrix & operator=(const Epetra_CrsMatrix &src)
Assignment operator.
int InputNonlocalValue(int rowoffset, int_type col, double value, int mode)
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
int N() const
Returns column dimension of system.
const Epetra_CrsGraph & Graph() const
Returns a reference to the Epetra_CrsGraph object associated with this matrix.
Epetra_FECrsMatrix(Epetra_DataAccess CV, const Epetra_Map &RowMap, int *NumEntriesPerRow, bool ignoreNonLocalEntries=false)
Constructor.
int * Values()
Returns pointer to the values in vector.
const Epetra_BlockMap & Map() const
Map() method inherited from Epetra_DistObject.
std::vector< double > workData_
int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::ReplaceGlobalValues method
virtual ~Epetra_FECrsMatrix()
Destructor.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
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...
int M() const
Returns row dimension of system.
Epetra_CrsMatrix(Epetra_DataAccess CV, const Epetra_Map &RowMap, const int *NumEntriesPerRow, bool StaticProfile=false)
Epetra_CrsMatrix constructor with variable number of indices per row.
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
Epetra_CrsMatrix * nonlocalMatrix_
bool GlobalIndicesTypeMatch(const Epetra_BlockMap &other) const