-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for deal solvers with TpetraWrappers
- Loading branch information
Showing
12 changed files
with
553 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,86 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2004 - 2024 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. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
// test the CG solver using the Trilinos matrix and vector classes | ||
|
||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/precondition.h> | ||
#include <deal.II/lac/solver_bicgstab.h> | ||
#include <deal.II/lac/solver_cg.h> | ||
#include <deal.II/lac/solver_control.h> | ||
#include <deal.II/lac/solver_gmres.h> | ||
#include <deal.II/lac/solver_qmrs.h> | ||
#include <deal.II/lac/solver_richardson.h> | ||
#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h> | ||
#include <deal.II/lac/vector_memory.h> | ||
|
||
#include <iostream> | ||
#include <typeinfo> | ||
|
||
#include "../tests.h" | ||
|
||
#include "../testmatrix.h" | ||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
deallog << std::setprecision(4); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
{ | ||
SolverControl control(200, 1.e-3); | ||
|
||
const unsigned int size = 32; | ||
unsigned int dim = (size - 1) * (size - 1); | ||
|
||
deallog << "Size " << size << " Unknowns " << dim << std::endl; | ||
|
||
// Make matrix | ||
FDMatrix testproblem(size, size); | ||
DynamicSparsityPattern csp(dim, dim); | ||
testproblem.five_point_structure(csp); | ||
LinearAlgebra::TpetraWrappers::SparseMatrix<double> A; | ||
A.reinit(csp); | ||
testproblem.five_point(A); | ||
|
||
LinearAlgebra::TpetraWrappers::Vector<double> f; | ||
f.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
LinearAlgebra::TpetraWrappers::Vector<double> u; | ||
u.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
f.trilinos_rcp()->putScalar(1.0); | ||
A.compress(VectorOperation::insert); | ||
f.compress(VectorOperation::insert); | ||
u.compress(VectorOperation::insert); | ||
|
||
GrowingVectorMemory<LinearAlgebra::TpetraWrappers::Vector<double>> mem; | ||
SolverCG<LinearAlgebra::TpetraWrappers::Vector<double>> solver(control, mem); | ||
PreconditionIdentity preconditioner; | ||
|
||
deallog << "Solver type: " << typeid(solver).name() << std::endl; | ||
|
||
check_solver_within_range(solver.solve(A, u, f, preconditioner), | ||
control.last_step(), | ||
42, | ||
44); | ||
} | ||
} |
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,4 @@ | ||
|
||
DEAL::Size 32 Unknowns 961 | ||
DEAL::Solver type: N6dealii8SolverCGINS_13LinearAlgebra14TpetraWrappers6VectorIdNS_11MemorySpace4HostEEEEE | ||
DEAL::Solver stopped within 42 - 44 iterations |
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 - 2024 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. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
// test the BiCGStab solver using the Trilinos matrix and vector classes | ||
|
||
|
||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/precondition.h> | ||
#include <deal.II/lac/solver_bicgstab.h> | ||
#include <deal.II/lac/solver_cg.h> | ||
#include <deal.II/lac/solver_control.h> | ||
#include <deal.II/lac/solver_gmres.h> | ||
#include <deal.II/lac/solver_qmrs.h> | ||
#include <deal.II/lac/solver_richardson.h> | ||
#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h> | ||
#include <deal.II/lac/vector_memory.h> | ||
|
||
#include <iostream> | ||
#include <typeinfo> | ||
|
||
#include "../tests.h" | ||
|
||
#include "../testmatrix.h" | ||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
deallog << std::setprecision(4); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
{ | ||
SolverControl control(200, 1.3e-10); | ||
|
||
const unsigned int size = 32; | ||
unsigned int dim = (size - 1) * (size - 1); | ||
|
||
deallog << "Size " << size << " Unknowns " << dim << std::endl; | ||
|
||
// Make matrix | ||
FDMatrix testproblem(size, size); | ||
DynamicSparsityPattern csp(dim, dim); | ||
testproblem.five_point_structure(csp); | ||
LinearAlgebra::TpetraWrappers::SparseMatrix<double> A; | ||
A.reinit(csp); | ||
testproblem.five_point(A); | ||
|
||
LinearAlgebra::TpetraWrappers::Vector<double> f; | ||
f.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
LinearAlgebra::TpetraWrappers::Vector<double> u; | ||
u.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
f.trilinos_rcp()->putScalar(1.0); | ||
A.compress(VectorOperation::insert); | ||
f.compress(VectorOperation::insert); | ||
u.compress(VectorOperation::insert); | ||
|
||
GrowingVectorMemory<LinearAlgebra::TpetraWrappers::Vector<double>> mem; | ||
SolverBicgstab<LinearAlgebra::TpetraWrappers::Vector<double>> solver( | ||
control, mem); | ||
PreconditionIdentity preconditioner; | ||
|
||
deallog << "Solver type: " << typeid(solver).name() << std::endl; | ||
|
||
check_solver_within_range(solver.solve(A, u, f, preconditioner), | ||
control.last_step(), | ||
49, | ||
51); | ||
} | ||
} |
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,4 @@ | ||
|
||
DEAL::Size 32 Unknowns 961 | ||
DEAL::Solver type: N6dealii14SolverBicgstabINS_13LinearAlgebra14TpetraWrappers6VectorIdNS_11MemorySpace4HostEEEEE | ||
DEAL::Solver stopped within 49 - 51 iterations |
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,90 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2004 - 2024 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. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
// test the GMRES solver using the Trilinos matrix and vector classes | ||
|
||
|
||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/precondition.h> | ||
#include <deal.II/lac/solver.h> | ||
#include <deal.II/lac/solver_bicgstab.h> | ||
#include <deal.II/lac/solver_cg.h> | ||
#include <deal.II/lac/solver_control.h> | ||
#include <deal.II/lac/solver_gmres.h> | ||
#include <deal.II/lac/solver_qmrs.h> | ||
#include <deal.II/lac/solver_richardson.h> | ||
#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h> | ||
#include <deal.II/lac/trilinos_vector.h> | ||
#include <deal.II/lac/vector_memory.h> | ||
|
||
#include <iostream> | ||
#include <typeinfo> | ||
|
||
#include "../tests.h" | ||
|
||
#include "../testmatrix.h" | ||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
deallog << std::setprecision(2); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
{ | ||
SolverControl control(2000, 1.e-3); | ||
|
||
const unsigned int size = 32; | ||
unsigned int dim = (size - 1) * (size - 1); | ||
|
||
deallog << "Size " << size << " Unknowns " << dim << std::endl; | ||
|
||
// Make matrix | ||
FDMatrix testproblem(size, size); | ||
DynamicSparsityPattern csp(dim, dim); | ||
testproblem.five_point_structure(csp); | ||
LinearAlgebra::TpetraWrappers::SparseMatrix<double> A; | ||
A.reinit(csp); | ||
testproblem.five_point(A); | ||
|
||
LinearAlgebra::TpetraWrappers::Vector<double> f; | ||
f.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
LinearAlgebra::TpetraWrappers::Vector<double> u; | ||
u.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
f.trilinos_rcp()->putScalar(1.0); | ||
A.compress(VectorOperation::insert); | ||
f.compress(VectorOperation::insert); | ||
u.compress(VectorOperation::insert); | ||
|
||
GrowingVectorMemory<LinearAlgebra::TpetraWrappers::Vector<double>> mem; | ||
SolverGMRES<LinearAlgebra::TpetraWrappers::Vector<double>> solver(control, | ||
mem); | ||
PreconditionIdentity preconditioner; | ||
|
||
deallog << "Solver type: " << typeid(solver).name() << std::endl; | ||
|
||
check_solver_within_range(solver.solve(A, u, f, preconditioner), | ||
control.last_step(), | ||
74, | ||
76); | ||
} | ||
} |
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,4 @@ | ||
|
||
DEAL::Size 32 Unknowns 961 | ||
DEAL::Solver type: N6dealii11SolverGMRESINS_13LinearAlgebra14TpetraWrappers6VectorIdNS_11MemorySpace4HostEEEEE | ||
DEAL::Solver stopped within 74 - 76 iterations |
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,89 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2004 - 2024 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. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
// test the MINRES solver using the Trilinos matrix and vector classes | ||
|
||
|
||
#include <deal.II/base/utilities.h> | ||
|
||
#include <deal.II/lac/precondition.h> | ||
#include <deal.II/lac/solver_bicgstab.h> | ||
#include <deal.II/lac/solver_cg.h> | ||
#include <deal.II/lac/solver_control.h> | ||
#include <deal.II/lac/solver_gmres.h> | ||
#include <deal.II/lac/solver_minres.h> | ||
#include <deal.II/lac/solver_qmrs.h> | ||
#include <deal.II/lac/solver_richardson.h> | ||
#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h> | ||
#include <deal.II/lac/trilinos_vector.h> | ||
#include <deal.II/lac/vector_memory.h> | ||
|
||
#include <iostream> | ||
#include <typeinfo> | ||
|
||
#include "../tests.h" | ||
|
||
#include "../testmatrix.h" | ||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
initlog(); | ||
deallog << std::setprecision(4); | ||
|
||
Utilities::MPI::MPI_InitFinalize mpi_initialization( | ||
argc, argv, testing_max_num_threads()); | ||
|
||
|
||
{ | ||
SolverControl control(100, 1.e-3); | ||
|
||
const unsigned int size = 32; | ||
unsigned int dim = (size - 1) * (size - 1); | ||
|
||
deallog << "Size " << size << " Unknowns " << dim << std::endl; | ||
|
||
// Make matrix | ||
FDMatrix testproblem(size, size); | ||
DynamicSparsityPattern csp(dim, dim); | ||
testproblem.five_point_structure(csp); | ||
LinearAlgebra::TpetraWrappers::SparseMatrix<double> A; | ||
A.reinit(csp); | ||
testproblem.five_point(A); | ||
|
||
LinearAlgebra::TpetraWrappers::Vector<double> f; | ||
f.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
LinearAlgebra::TpetraWrappers::Vector<double> u; | ||
u.reinit(complete_index_set(dim), MPI_COMM_WORLD); | ||
f.trilinos_rcp()->putScalar(1.0); | ||
A.compress(VectorOperation::insert); | ||
f.compress(VectorOperation::insert); | ||
u.compress(VectorOperation::insert); | ||
|
||
GrowingVectorMemory<LinearAlgebra::TpetraWrappers::Vector<double>> mem; | ||
SolverMinRes<LinearAlgebra::TpetraWrappers::Vector<double>> solver(control, | ||
mem); | ||
PreconditionIdentity preconditioner; | ||
|
||
deallog << "Solver type: " << typeid(solver).name() << std::endl; | ||
|
||
check_solver_within_range(solver.solve(A, u, f, preconditioner), | ||
control.last_step(), | ||
0, | ||
42); | ||
} | ||
} |
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,4 @@ | ||
|
||
DEAL::Size 32 Unknowns 961 | ||
DEAL::Solver type: N6dealii12SolverMinResINS_13LinearAlgebra14TpetraWrappers6VectorIdNS_11MemorySpace4HostEEEEE | ||
DEAL::Solver stopped after 43 iterations |
Oops, something went wrong.