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
329 os <<
"[FECrsMatrix] Nonlocal matrix:\n";
336 os <<
"[FECrsMatrix] Nonlocal rows:\n";
347 for (
int iproc=0; iproc < NumProc; iproc++) {
349 if(
RowMap().GlobalIndicesInt()) {
351 for (
int i=0; i<nnr; ++i) {
354 for (
int j=0; j<ncols; ++j) {
356 os << MyPID ; os <<
" ";
358 os << Row ; os <<
" ";
368 for (
int i=0; i<nnr; ++i) {
371 for (
int j=0; j<ncols; ++j) {
373 os << MyPID ; os <<
" ";
375 os << Row ; os <<
" ";
395 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
396 if (
RowMap().GlobalIndicesInt()) {
402 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
403 if (
RowMap().GlobalIndicesLongLong()) {
426 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
428 const double*
const* values,
436 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
438 const double*
const* values,
447 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
449 int numCols,
const int* cols,
450 const double*
const* values,
458 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
460 int numCols,
const long long* cols,
461 const double*
const* values,
470 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
472 const double* values,
480 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
482 const double* values,
491 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
493 int numCols,
const int* cols,
494 const double* values,
503 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
505 int numCols,
const long long* cols,
506 const double* values,
515 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
520 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
525 values.
A(), format) );
529 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
534 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
539 values.
A(), format) );
543 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
548 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
553 values.
A(), format) );
556 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
561 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
566 values.
A(), format) );
570 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
575 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
580 values.
A(), format) );
583 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
588 if (indices.
Length() != values.
M() || indices.
Length() != values.
N()) {
593 values.
A(), format) );
597 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
609 values.
A(), format) );
612 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
624 values.
A(), format) );
628 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
640 values.
A(), format) );
643 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
655 values.
A(), format) );
659 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
671 values.
A(), format) );
674 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
687 values.
A(), format) );
691 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
693 const double*
const* values,
701 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
704 const double*
const* values,
713 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
715 int numCols,
const int* cols,
716 const double*
const* values,
724 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
727 int numCols,
const long long* cols,
728 const double*
const* values,
737 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
739 const double* values,
747 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
750 const double* values,
759 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
761 int numCols,
const int* cols,
762 const double* values,
770 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
773 int numCols,
const long long* cols,
774 const double* values,
783 template<
typename int_type>
785 const double* values,
const int_type* Indices)
787 if (
Map().MyGID(GlobalRow))
792 NumEntries, values, Indices);
797 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
799 const double* values,
const int* Indices)
801 if(
RowMap().GlobalIndicesInt())
802 return SumIntoGlobalValues<int>(GlobalRow, NumEntries, values, Indices);
804 throw ReportError(
"Epetra_FECrsMatrix::SumIntoGlobalValues int version called for a matrix that is not int.", -1);
807 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
811 const double* values,
const long long* Indices)
813 if(
RowMap().GlobalIndicesLongLong())
814 return SumIntoGlobalValues<long long>(GlobalRow, NumEntries, values, Indices);
816 throw ReportError(
"Epetra_FECrsMatrix::SumIntoGlobalValues long long version called for a matrix that is not long long.", -1);
820 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
822 const double* values,
const int* Indices)
825 NumEntries, Indices, values,
829 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
832 const double* values,
const long long* Indices)
835 NumEntries, Indices, values,
840 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
842 double* values,
int* Indices)
845 NumEntries, Indices, values,
849 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
851 double* values,
long long* Indices)
854 NumEntries, Indices, values,
859 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
861 const double* values,
const int* Indices)
864 NumEntries, Indices, values,
868 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
870 const double* values,
const long long* Indices)
873 NumEntries, Indices, values,
878 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
880 const double*
const* values,
888 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
890 const double*
const* values,
899 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
901 int numCols,
const int* cols,
902 const double*
const* values,
910 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
912 int numCols,
const long long* cols,
913 const double*
const* values,
922 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
924 const double* values,
932 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
934 const double* values,
943 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
945 int numCols,
const int* cols,
946 const double* values,
954 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
956 int numCols,
const long long* cols,
957 const double* values,
967 bool save_off_and_reuse_map_exporter)
973 template<
typename int_type>
976 bool callFillComplete,
978 bool save_off_and_reuse_map_exporter)
981 if (callFillComplete) {
987 std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
988 std::vector<std::vector<int_type> >& nonlocalCols_var = nonlocalCols<int_type>();
1010 if (callFillComplete) {
1013 if (!save_off_and_reuse_map_exporter) {
1023 bool first_time=!save_off_and_reuse_map_exporter;
1026 std::vector<int_type> cols;
1028 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
1029 for(
size_t j=0; j<nonlocalCols_var[i].size(); ++j) {
1030 int_type col = nonlocalCols_var[i][j];
1031 typename std::vector<int_type>::iterator it =
1032 std::lower_bound(cols.begin(), cols.end(), col);
1033 if (it == cols.end() || *it != col) {
1034 cols.insert(it, col);
1047 std::vector<int> nonlocalRowLengths(nonlocalRows_var.size());
1048 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
1049 nonlocalRowLengths[i] = (int) nonlocalCols_var[i].size();
1053 if ( first_time &&
tempMat_ == NULL )
1058 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
1061 (
int) nonlocalCols_var[i].size(),
1066 (
int) nonlocalCols_var[i].size(),
1072 if (!save_off_and_reuse_map_exporter) {
1099 if(callFillComplete) {
1107 for(
size_t i=0; i<nonlocalRows_var.size(); ++i) {
1108 nonlocalCols_var[i].resize(0);
1113 if (!save_off_and_reuse_map_exporter) {
1125 bool callFillComplete,
1127 bool save_off_and_reuse_map_exporter)
1130 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: cannot be called with different indices types for domainMap and rangeMap", -1);
1133 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: cannot be called with different indices types for row map and incoming rangeMap", -1);
1136 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1137 return GlobalAssemble<int>(domain_map, range_map, callFillComplete, combineMode, save_off_and_reuse_map_exporter);
1139 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: ERROR, GlobalIndicesInt but no API for it.",-1);
1142 if(
RowMap().GlobalIndicesLongLong())
1143 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1144 return GlobalAssemble<long long>(domain_map, range_map, callFillComplete, combineMode, save_off_and_reuse_map_exporter);
1146 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: ERROR, GlobalIndicesLongLong but no API for it.",-1);
1149 throw ReportError(
"Epetra_FECrsMatrix::GlobalAssemble: Internal error, unable to determine global index type of maps", -1);
1153 template<
typename int_type>
1155 int numRows,
const int_type* rows,
1156 int numCols,
const int_type* cols,
1157 const double* values,
1160 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1161 throw ReportError(
"Epetra_FECrsMatrix::InputGlobalValues_RowMajor mismatch between argument types (int/long long) and map type.", -1);
1166 for(
int i=0; i<numRows; ++i) {
1167 double* valuesptr = (
double*)values + i*numCols;
1169 int local_row_id =
Map().
LID(rows[i]);
1170 if (local_row_id >= 0) {
1174 valuesptr, (int_type*)cols);
1175 if (err<0)
return(err);
1176 if (err>0) returncode = err;
1180 valuesptr, (int_type*)cols);
1181 if (err<0)
return(err);
1182 if (err>0) returncode = err;
1186 valuesptr, (int_type*)cols);
1187 if (err<0)
return(err);
1188 if (err>0) returncode = err;
1191 std::cerr <<
"Epetra_FECrsMatrix: internal error, bad input mode."<< std::endl;
1196 #ifdef EPETRA_HAVE_OMP
1197 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1203 if (err<0)
return(err);
1204 if (err>0) returncode = err;
1205 #ifdef EPETRA_HAVE_OMP
1206 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1217 template<
typename int_type>
1219 int numCols,
const int_type* cols,
1220 const double*
const* values,
1221 int format,
int mode)
1223 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1224 throw ReportError(
"Epetra_FECrsMatrix::InputGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1228 std::cerr <<
"Epetra_FECrsMatrix: unrecognized format specifier."<< std::endl;
1238 for(
int i=0; i<numRows; ++i) {
1242 if (returncode < 0)
return returncode;
1255 for(
int j=0; j<numCols; ++j) {
1256 valuesptr[j] = values[j][i];
1260 if (returncode < 0)
return returncode;
1267 template<
typename int_type>
1269 int numCols,
const int_type* cols,
1270 const double* values,
1271 int format,
int mode)
1273 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1274 throw ReportError(
"Epetra_FECrsMatrix::InputGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1283 for(
int i=0; i<numRows; ++i) {
1286 for(
int j=0; j<numCols; ++j) {
1290 if (err < 0)
return err;
1298 template<
typename int_type>
1300 int numCols,
const int_type* cols,
1301 const double* values,
1304 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1305 throw ReportError(
"Epetra_FECrsMatrix::InputNonlocalGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1309 int err, returncode = 0;
1310 double* valuesptr = (
double*)values;
1314 valuesptr, (int_type*)cols);
1315 if (err<0)
return(err);
1316 if (err>0) returncode = err;
1320 valuesptr, (int_type*)cols);
1321 if (err<0)
return(err);
1322 if (err>0) returncode = err;
1326 valuesptr, (int_type*)cols);
1327 if (err<0)
return(err);
1328 if (err>0) returncode = err;
1331 std::cerr <<
"Epetra_FECrsMatrix: internal error, bad input mode."<< std::endl;
1334 return (returncode);
1336 int ierr1 = 0, ierr2 = 0;
1337 #ifdef EPETRA_HAVE_OMP
1338 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1339 #pragma omp critical
1343 std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
1346 typename std::vector<int_type>::iterator it =
1347 std::lower_bound(nonlocalRows_var.begin(), nonlocalRows_var.end(), row);
1349 int rowoffset = (int) (it - nonlocalRows_var.begin());
1350 if (it == nonlocalRows_var.end() || *it != row) {
1354 for(
int i=0; i<numCols; ++i) {
1365 template<
typename int_type>
1368 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1369 throw ReportError(
"Epetra_FECrsMatrix::InsertNonlocalRow mismatch between argument types (int/long long) and map type.", -1);
1371 std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
1372 std::vector<std::vector<int_type> >& nonlocalCols_var = nonlocalCols<int_type>();
1374 int offset = (int) (iter - nonlocalRows_var.begin());
1375 nonlocalRows_var.insert(iter, row);
1376 typename std::vector<std::vector<int_type> >::iterator cols_iter = nonlocalCols_var.begin() + offset;
1377 nonlocalCols_var.insert(cols_iter, std::vector<int_type>());
1378 std::vector<std::vector<double> >::iterator coefs_iter =
nonlocalCoefs_.begin() + offset;
1385 template<
typename int_type>
1387 int_type col,
double value,
1390 if(!
RowMap().
template GlobalIndicesIsType<int_type>())
1391 throw ReportError(
"Epetra_FECrsMatrix::InputNonlocalValue mismatch between argument types (int/long long) and map type.", -1);
1393 std::vector<int_type>& colIndices = nonlocalCols<int_type>()[rowoffset];
1396 typename std::vector<int_type>::iterator it =
1397 std::lower_bound(colIndices.begin(), colIndices.end(), col);
1399 if (it == colIndices.end() || *it != col) {
1400 int offset = (int) (it - colIndices.begin());
1401 colIndices.insert(it, col);
1402 std::vector<double>::iterator dit = coefs.begin()+offset;
1403 coefs.insert(dit, value);
1407 int coloffset = (int) (it - colIndices.begin());
1409 coefs[coloffset] += value;
1412 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...
virtual void Barrier() const =0
Epetra_Comm Barrier function.
std::vector< int > nonlocalRows_int_
virtual int MyPID() const =0
Return my process ID.
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.
void Print(std::ostream &os) const
Print method.
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)
virtual void Print(std::ostream &os) const
Print method.
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
virtual int NumProc() const =0
Returns total number of processes.
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