From 31a8b117d80f4cd92c3a36d8574698b16c276879 Mon Sep 17 00:00:00 2001 From: Norihiro Watanabe <norihiro.watanabe@ufz.de> Date: Mon, 15 Jul 2013 14:52:49 +0200 Subject: [PATCH] add tests for Lis vector, matrix and linear solver --- Tests/MathLib/TestGlobalMatrixInterface.cpp | 11 ++++++++++- Tests/MathLib/TestGlobalVectorInterface.cpp | 9 +++++++++ Tests/MathLib/TestLinearSolver.cpp | 22 ++++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Tests/MathLib/TestGlobalMatrixInterface.cpp b/Tests/MathLib/TestGlobalMatrixInterface.cpp index 8713d23b36e..4a7c7805733 100644 --- a/Tests/MathLib/TestGlobalMatrixInterface.cpp +++ b/Tests/MathLib/TestGlobalMatrixInterface.cpp @@ -17,6 +17,9 @@ #include "MathLib/LinAlg/Dense/DenseMatrix.h" #include "MathLib/LinAlg/Dense/GlobalDenseMatrix.h" #include "MathLib/LinAlg/FinalizeMatrixAssembly.h" +#ifdef USE_LIS +#include "MathLib/LinAlg/Lis/LisMatrix.h" +#endif namespace { @@ -50,4 +53,10 @@ TEST(Math, CheckInterface_GlobalDenseMatrix) checkGlobalMatrixInterface(m); } - +#ifdef USE_LIS +TEST(Math, CheckInterface_LisMatrix) +{ + MathLib::LisMatrix m(10); + checkGlobalMatrixInterface(m); +} +#endif diff --git a/Tests/MathLib/TestGlobalVectorInterface.cpp b/Tests/MathLib/TestGlobalVectorInterface.cpp index 2a371aae06e..2c494bb447d 100644 --- a/Tests/MathLib/TestGlobalVectorInterface.cpp +++ b/Tests/MathLib/TestGlobalVectorInterface.cpp @@ -15,6 +15,9 @@ #include <gtest/gtest.h> #include "MathLib/LinAlg/Dense/DenseVector.h" +#ifdef USE_LIS +#include "MathLib/LinAlg/Lis/LisVector.h" +#endif namespace { @@ -64,4 +67,10 @@ TEST(Math, CheckInterface_DenseVector) checkGlobalVectorInterface<MathLib::DenseVector<double> >(); } +#ifdef USE_LIS +TEST(Math, CheckInterface_LisVector) +{ + checkGlobalVectorInterface<MathLib::LisVector >(); +} +#endif diff --git a/Tests/MathLib/TestLinearSolver.cpp b/Tests/MathLib/TestLinearSolver.cpp index 3e495c6af6f..d0754f8798b 100644 --- a/Tests/MathLib/TestLinearSolver.cpp +++ b/Tests/MathLib/TestLinearSolver.cpp @@ -21,6 +21,10 @@ #include "MathLib/LinAlg/Dense/DenseTools.h" #include "MathLib/LinAlg/FinalizeMatrixAssembly.h" #include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" +#ifdef USE_LIS +#include "MathLib/LinAlg/Lis/LisLinearSolver.h" +#include "MathLib/LinAlg/Lis/LisTools.h" +#endif #include "../TestTools.h" @@ -72,7 +76,7 @@ struct Example1 ~Example1() { - delete [] exH; + delete [] exH; } }; @@ -121,4 +125,20 @@ TEST(MathLib, CheckInterface_GaussAlgorithm) checkLinearSolverInterface<MathLib::GlobalDenseMatrix<double>, MathLib::DenseVector<double>, LinearSolverType>(A, t_root); } +#ifdef USE_LIS +TEST(Math, CheckInterface_Lis) +{ + // set solver options using Boost property tree + boost::property_tree::ptree t_root; + boost::property_tree::ptree t_solver; + t_solver.put("solver_type", "CG"); + t_solver.put("precon_type", "NONE"); + t_solver.put("error_tolerance", 1e-15); + t_solver.put("max_iteration_step", 1000); + t_root.put_child("LinearSolver", t_solver); + + MathLib::LisMatrix A(Example1::dim_eqs); + checkLinearSolverInterface<MathLib::LisMatrix, MathLib::LisVector, MathLib::LisLinearSolver>(A, t_root); +} +#endif -- GitLab