-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tpetra tests that are already working.
- Loading branch information
Showing
122 changed files
with
8,894 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2004 - 2018 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// The deal.II library is free software; you can use it, redistribute | ||
// it, and/or modify it under the terms of the GNU Lesser General | ||
// Public License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// The full text of the license can be found in the file LICENSE.md at | ||
// the top level directory of deal.II. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
|
||
// check LinearAlgebra::TpetraWrappers::SparseMatrix<double>::operator /= | ||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h> | ||
|
||
#include <iostream> | ||
|
||
#include "../tests.h" | ||
|
||
|
||
void | ||
test(LinearAlgebra::TpetraWrappers::SparseMatrix<double> &m) | ||
{ | ||
// first set a few entries | ||
for (unsigned int i = 0; i < m.m(); ++i) | ||
for (unsigned int j = 0; j < m.m(); ++j) | ||
if ((i + 2 * j + 1) % 3 == 0) | ||
m.set(i, j, i * j * .5 + .5); | ||
|
||
m.compress(VectorOperation::insert); | ||
|
||
// then divide everything by 4/3 and | ||
// make sure we retrieve the values we | ||
// expect | ||
m /= 4. / 3.; | ||
|
||
for (unsigned int i = 0; i < m.m(); ++i) | ||
for (unsigned int j = 0; j < m.m(); ++j) | ||
if ((i + 2 * j + 1) % 3 == 0) | ||
{ | ||
AssertThrow(m(i, j) == (i * j * .5 + .5) / 4 * 3, ExcInternalError()); | ||
AssertThrow(m.el(i, j) == (i * j * .5 + .5) / 4 * 3, | ||
ExcInternalError()); | ||
} | ||
else | ||
{ | ||
AssertThrow(m.el(i, j) == 0, ExcInternalError()); | ||
} | ||
|
||
deallog << "OK" << std::endl; | ||
} | ||
|
||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
try | ||
{ | ||
{ | ||
LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(5U, 5U, 3U); | ||
test(m); | ||
} | ||
} | ||
catch (const std::exception &exc) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Exception on processing: " << std::endl | ||
<< exc.what() << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
|
||
return 1; | ||
} | ||
catch (...) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Unknown exception!" << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
return 1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
DEAL::OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2004 - 2018 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// The deal.II library is free software; you can use it, redistribute | ||
// it, and/or modify it under the terms of the GNU Lesser General | ||
// Public License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// The full text of the license can be found in the file LICENSE.md at | ||
// the top level directory of deal.II. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
|
||
// check LinearAlgebra::TpetraWrappers::Vector<double>::size() | ||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/trilinos_tpetra_vector.h> | ||
|
||
#include <iostream> | ||
|
||
#include "../tests.h" | ||
|
||
|
||
void | ||
test(LinearAlgebra::TpetraWrappers::Vector<double> &v) | ||
{ | ||
// set only certain elements of the vector | ||
for (unsigned int i = 0; i < v.size(); i += 1 + i) | ||
v(i) = i; | ||
|
||
v.compress(VectorOperation::insert); | ||
|
||
AssertThrow(v.size() == 100, ExcInternalError()); | ||
|
||
deallog << "OK" << std::endl; | ||
} | ||
|
||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
try | ||
{ | ||
{ | ||
LinearAlgebra::TpetraWrappers::Vector<double> v; | ||
v.reinit(complete_index_set(100), MPI_COMM_WORLD); | ||
test(v); | ||
} | ||
} | ||
catch (const std::exception &exc) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Exception on processing: " << std::endl | ||
<< exc.what() << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
|
||
return 1; | ||
} | ||
catch (...) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Unknown exception!" << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
return 1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
DEAL::OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2004 - 2018 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// The deal.II library is free software; you can use it, redistribute | ||
// it, and/or modify it under the terms of the GNU Lesser General | ||
// Public License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// The full text of the license can be found in the file LICENSE.md at | ||
// the top level directory of deal.II. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
|
||
// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in set-mode | ||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/trilinos_tpetra_vector.h> | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include "../tests.h" | ||
|
||
|
||
void | ||
test(LinearAlgebra::TpetraWrappers::Vector<double> &v) | ||
{ | ||
// set only certain elements of the | ||
// vector. have a bit pattern of where we | ||
// actually wrote elements to | ||
std::vector<bool> pattern(v.size(), false); | ||
for (unsigned int i = 0; i < v.size(); i += 1 + i) | ||
{ | ||
v(i) = i; | ||
pattern[i] = true; | ||
} | ||
|
||
v.compress(VectorOperation::insert); | ||
|
||
// check that they are ok, and this time | ||
// all of them | ||
for (unsigned int i = 0; i < v.size(); ++i) | ||
AssertThrow((((pattern[i] == true) && (v(i) == i)) || | ||
((pattern[i] == false) && (v(i) == 0))), | ||
ExcInternalError()); | ||
|
||
deallog << "OK" << std::endl; | ||
} | ||
|
||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
try | ||
{ | ||
{ | ||
LinearAlgebra::TpetraWrappers::Vector<double> v; | ||
v.reinit(complete_index_set(100), MPI_COMM_WORLD); | ||
test(v); | ||
} | ||
} | ||
catch (const std::exception &exc) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Exception on processing: " << std::endl | ||
<< exc.what() << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
|
||
return 1; | ||
} | ||
catch (...) | ||
{ | ||
std::cerr << std::endl | ||
<< std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
std::cerr << "Unknown exception!" << std::endl | ||
<< "Aborting!" << std::endl | ||
<< "----------------------------------------------------" | ||
<< std::endl; | ||
return 1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
DEAL::OK |
Oops, something went wrong.