Skip to content

Commit

Permalink
Teko: more generic fixes to handle case where GO=unsigned long.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikalash committed Dec 16, 2019
1 parent b8456c9 commit 8588901
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/teko/src/Teko_Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ RCP<Tpetra::CrsMatrix<ST,LO,GO,NT> > buildGraphLaplacian(int dim,ST * coords,con
// extract a copy of this row...put it in rowData, rowIndicies
stencil.getGlobalRowCopy(row,Teuchos::ArrayView<GO>(rowInd),Teuchos::ArrayView<ST>(rowData),rowSz);
// loop over elements of row
for(GO i=0;i<rowSz;i++) {
for(size_t i=0;i<rowSz;i++) {
GO col = rowInd[i];

// is this a 0 entry masquerading as some thing else?
Expand Down
6 changes: 3 additions & 3 deletions packages/teko/src/Tpetra/Teko_BlockingTpetra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ RCP<Tpetra::CrsMatrix<ST,LO,GO,NT> > buildSubBlock(int i,int j,const RCP<const T
// if global id is not owned by this column

GO gid = local2ContigGIDs.getData()[indices[localCol]];
if(gid==-1) continue; // in contiguous row
if(gid==Teuchos::OrdinalTraits<GO>::invalid()) continue; // in contiguous row
numOwnedCols++;
}
nEntriesPerRow[localRow] = numOwnedCols;
Expand All @@ -295,7 +295,7 @@ RCP<Tpetra::CrsMatrix<ST,LO,GO,NT> > buildSubBlock(int i,int j,const RCP<const T
// if global id is not owned by this column

GO gid = local2ContigGIDs.getData()[indices[localCol]];
if(gid==-1) continue; // in contiguous row
if(gid==Teuchos::OrdinalTraits<GO>::invalid()) continue; // in contiguous row

colIndices[numOwnedCols] = gid;
colValues[numOwnedCols] = values[localCol];
Expand Down Expand Up @@ -364,7 +364,7 @@ void rebuildSubBlock(int i,int j,const RCP<const Tpetra::CrsMatrix<ST,LO,GO,NT>

// if global id is not owned by this column
GO gid = local2ContigGIDs.getData()[indices[localCol]];
if(gid==-1) continue; // in contiguous row
if(gid==Teuchos::OrdinalTraits<GO>::invalid()) continue; // in contiguous row

colIndices[numOwnedCols] = gid;
colValues[numOwnedCols] = values[localCol];
Expand Down
9 changes: 5 additions & 4 deletions packages/teko/tests/src/Tpetra/tTpetraThyraConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ double compareTpetraMVToThyra(const Tpetra_MultiVector & eX,
int indexStart=-1,int indexEnd=-1); */
double compareTpetraMVToThyra(const Tpetra::MultiVector<ST,LO,GO,NT> & eX,
const Teuchos::RCP<const Thyra::MultiVectorBase<ST> > & tX,
int verbosity,std::ostream & os,int indexStart=-1,GO indexEnd=-1);
int verbosity,std::ostream & os,GO indexStart=Teuchos::OrdinalTraits<GO>::invalid(),
GO indexEnd=Teuchos::OrdinalTraits<GO>::invalid());

double compareTpetraMVToThyra(const Tpetra::MultiVector<ST,LO,GO,NT> & eX,
const Teuchos::RCP<const Thyra::MultiVectorBase<ST> > & tX,
int verbosity,std::ostream & os,int indexStart,GO indexEnd)
int verbosity,std::ostream & os,GO indexStart,GO indexEnd)
{
using Teuchos::outArg;
if(indexStart<0) {
if(indexStart==Teuchos::OrdinalTraits<GO>::invalid()) {
indexStart = 0;
indexEnd = eX.getGlobalLength();
}
Expand Down Expand Up @@ -151,7 +152,7 @@ double compareTpetraMVToThyra(const Tpetra::MultiVector<ST,LO,GO,NT> & eX,
GO gid = map.getGlobalElement(i);

// this is not in the range of vector elements we are interested in
if(gid<indexStart || gid>=indexEnd) continue;
if(gid<indexStart || gid>=indexEnd || gid==Teuchos::OrdinalTraits<GO>::invalid()) continue;

// these values should be equal
for(int j=0;j<vecs;j++) {
Expand Down
20 changes: 15 additions & 5 deletions packages/teko/tests/unit_tests/tDiagonallyScaledPreconditioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const RCP<Thyra::LinearOpBase<double> > buildSystem(const Epetra_Comm & comm,int
RCP<Epetra_CrsMatrix> mat = rcp(new Epetra_CrsMatrix(Copy,map,0));

double values[] = { -1.0, 2.0, -1.0};
int iTemp[] = {-1,0,1}, indices[3];
GO iTemp[] = {Teuchos::OrdinalTraits<GO>::invalid(),0,1};
int indices[3];
double * vPtr;
int * iPtr;

Expand All @@ -105,7 +106,12 @@ const RCP<Thyra::LinearOpBase<double> > buildSystem(const Epetra_Comm & comm,int
vPtr = values;
iPtr = indices;

indices[0] = gid+iTemp[0];
if (iTemp[0] == Teuchos::OrdinalTraits<GO>::invalid()) {
indices[0] = gid -1;
}
else {
indices[0] = gid+iTemp[0];
}
indices[1] = gid+iTemp[1];
indices[2] = gid+iTemp[2];

Expand All @@ -132,7 +138,7 @@ const RCP<Thyra::LinearOpBase<ST> > buildSystem(const Teuchos::RCP<const Teuchos
RCP<Tpetra::CrsMatrix<ST,LO,GO,NT> > mat = Tpetra::createCrsMatrix<ST,LO,GO,NT>(map,3);

ST values[] = { -1.0, 2.0, -1.0};
int iTemp[] = {-1,0,1};
GO iTemp[] = {Teuchos::OrdinalTraits<GO>::invalid(),0,1};
GO indices[3];
ST * vPtr;
GO * iPtr;
Expand All @@ -142,8 +148,12 @@ const RCP<Thyra::LinearOpBase<ST> > buildSystem(const Teuchos::RCP<const Teuchos

vPtr = values;
iPtr = indices;

indices[0] = gid+iTemp[0];
if (iTemp[0] == Teuchos::OrdinalTraits<GO>::invalid()) {
indices[0] = gid-1;
}
else {
indices[0] = gid+iTemp[0];
}
indices[1] = gid+iTemp[1];
indices[2] = gid+iTemp[2];

Expand Down

0 comments on commit 8588901

Please sign in to comment.