Skip to content

Commit

Permalink
remove tests used for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Meyer Andersen committed Dec 20, 2023
1 parent f3f49d8 commit 4e9f09e
Showing 1 changed file with 0 additions and 109 deletions.
109 changes: 0 additions & 109 deletions tests/cuistl/test_cuSparse_matrix_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,112 +180,3 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(FlattenAndInvertDiagonalWith2By2Blocks, T, Numeric
BOOST_CHECK_CLOSE(expectedInvDiag[i], computedInvDiag[i], 1e-7);
}
}

BOOST_AUTO_TEST_CASE_TEMPLATE(testMvHelperFunction, T, NumericTypes)
{
size_t N = 3;
std::vector<T> A(N*N), b(N), c(N);
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++){
A[i*N + j] = i*N + j;
}
b[i] = i;
c[i] = N - i;
}

bool setEqual = true;

for (size_t i = 0; i < N; ++i) {
if (setEqual){
c[i] = 0;
}

for (size_t j = 0; j < N; ++j) {
if (setEqual){
c[i] += A[i * N + j] * b[j];
}
else if (!setEqual){
c[i] -= A[i * N + j] * b[j];
}
}
}

std::vector<T> expected_ans = {5.0, 14.0, 23.0};
for (int i = 0; i < N; i++){

BOOST_CHECK_CLOSE(c[i], expected_ans[i], 1e-7);
}

setEqual = false;
expected_ans = {0.0, 0.0, 0.0};

for (size_t i = 0; i < N; ++i) {
if (setEqual){
c[i] = 0;
}

for (size_t j = 0; j < N; ++j) {
if (setEqual){
c[i] += A[i * N + j] * b[j];
}
else if (!setEqual){
c[i] -= A[i * N + j] * b[j];
}
}
}

for (int i = 0; i < N; i++){

BOOST_CHECK_CLOSE(c[i], expected_ans[i], 1e-7);
}
}

BOOST_AUTO_TEST_CASE_TEMPLATE(moveToReorderedMatrix, T, NumericTypes)
{
const size_t blocksize = 2;
const size_t N = 2;
const int nonZeroes = 3;
using M = Dune::FieldMatrix<T, blocksize, blocksize>;
using SpMatrix = Dune::BCRSMatrix<M>;

SpMatrix A(N, N, nonZeroes, SpMatrix::row_wise);
for (auto row = A.createbegin(); row != A.createend(); ++row) {
row.insert(row.index());
if (row.index() == 0) {
row.insert(row.index() + 1);
}
}
SpMatrix B(N, N, nonZeroes, SpMatrix::row_wise);
for (auto row = B.createbegin(); row != B.createend(); ++row) {
row.insert(row.index());
if (row.index() == 1) {
row.insert(row.index() - 1);
}
}
A[0][0][0][0] = 1.0;
A[0][1][0][1] = 2.0;
A[1][1][1][0] = 3.0;
B[0][0][0][0] = -1.0;
B[1][0][0][0] = -1.0;
B[1][1][0][0] = -1.0;

Opm::cuistl::CuSparseMatrix<T> mA = Opm::cuistl::CuSparseMatrix<T>::fromMatrix(A);
Opm::cuistl::CuSparseMatrix<T> mB = Opm::cuistl::CuSparseMatrix<T>::fromMatrix(B);

Opm::cuistl::CuVector<int> naturalToReorder({1, 0});

Opm::cuistl::detail::moveMatDataToReordered2<T, 2>(mA.getNonZeroValues().data(), mA.getRowIndices().data(), mA.getColumnIndices().data(), mB.getNonZeroValues().data(), mB.getRowIndices().data(), mB.getColumnIndices().data(), naturalToReorder.data(), N, nonZeroes);

std::vector<T> orig(mA.getNonZeroValues().asStdVector());
std::vector<T> res(mB.getNonZeroValues().asStdVector());

printf("=======\n");
for (auto e : orig){
printf("%lf ", e);
}
printf("\n");
for (auto e : res){
printf("%lf ", e);
}
printf("=======\n");
}

0 comments on commit 4e9f09e

Please sign in to comment.