Skip to content
Snippets Groups Projects
Commit e53bf7d2 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Remove CG and BiCG tests from main

parent 6f77ee95
Branches
Tags
1 merge request!26Feature/linear systems
......@@ -24,10 +24,6 @@
#include <SynchronizerManager.hpp>
#include <BiCGStab.hpp>
#include <CRSMatrix.hpp>
#include <PCG.hpp>
#include <iostream>
#include <limits>
......@@ -37,81 +33,6 @@
int
main(int argc, char* argv[])
{
if (argc == 1) {
std::cout << "-- Testing linear algebra --\n";
Kokkos::initialize({4, -1, -1, true});
{
{ // PCG simple test
size_t matrix_size = 10;
SparseMatrixDescriptor D(matrix_size);
for (size_t i = 0; i < matrix_size; ++i) {
D(i, i) = 4;
if (i + 1 < matrix_size) {
D(i, i + 1) = -1;
D(i + 1, i) = -1;
}
}
CRSMatrix A{D};
Vector<double> x{10};
for (size_t i = 0; i < x.size(); ++i) {
x[i] = 2 * i + 1;
}
Vector<double> Ax = A * x;
Vector<double> u{x.size()};
u = 0;
PCG{Ax, A, A, u, 100, 1e-12};
std::cout << "== PCG report ==\n";
std::cout << "L2 Error = " << std::sqrt((x - u, x - u)) << '\n';
std::cout << "L2 Norm = " << std::sqrt((x, x)) << '\n';
std::cout << "L2 RelEr = " << std::sqrt((x - u, x - u)) / std::sqrt((x, x)) << '\n';
std::cout << "================\n";
}
{ // BiCGStab simple test
size_t matrix_size = 10;
SparseMatrixDescriptor D(matrix_size);
for (size_t i = 0; i < matrix_size; ++i) {
D(i, i) = 4;
if (i + 1 < matrix_size) {
D(i, i + 1) = -1;
D(i + 1, i) = -0.3;
}
}
CRSMatrix A{D};
Vector<double> x{10};
for (size_t i = 0; i < x.size(); ++i) {
x[i] = 2 * i + 1;
}
Vector<double> Ax = A * x;
Vector<double> u{x.size()};
u = 0;
BiCGStab{Ax, A, u, 100, 1e-12};
std::cout << "== BiCGStab report ==\n";
std::cout << "L2 Error = " << std::sqrt((x - u, x - u)) << '\n';
std::cout << "L2 Norm = " << std::sqrt((x, x)) << '\n';
std::cout << "L2 RelEr = " << std::sqrt((x - u, x - u)) / std::sqrt((x, x)) << '\n';
std::cout << "=====================\n";
}
}
Kokkos::finalize();
return 0;
}
std::string filename = initialize(argc, argv);
std::regex gmsh_regex("(.*).msh");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment