From 68dcb61b28a90feb916b3b337b11912c300deb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Fri, 27 Nov 2015 16:17:36 +0100 Subject: [PATCH] Enabled the TFQMR linear solver. --- src/solvers/linear/krylov/CMakeLists.txt | 12 +++++++----- src/solvers/tnlBuildConfigTags.h | 1 + src/solvers/tnlSolverConfig_impl.h | 4 ++++ src/solvers/tnlSolverStarter_impl.h | 25 ++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/solvers/linear/krylov/CMakeLists.txt b/src/solvers/linear/krylov/CMakeLists.txt index a0e43b2e70..0bbe87701d 100644 --- a/src/solvers/linear/krylov/CMakeLists.txt +++ b/src/solvers/linear/krylov/CMakeLists.txt @@ -2,11 +2,13 @@ SET( headers tnlCGSolver.h tnlCGSolver_impl.h tnlBICGStabSolver.h tnlBICGStabSolver_impl.h - tnlGMRESSolver.h - tnlGMRESSolver_impl.h ) + tnlGMRESSolver.h + tnlGMRESSolver_impl.h + tnlTFQMRSolver.h + tnlTFQMRSolver_impl.h ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/solvers/linear/krylov ) -set( common_SOURCES ${CURRENT_DIR}/tnlGMRESSolver_impl.cpp ) +set( common_SOURCES ${CURRENT_DIR}/tnlGMRESSolver_impl.cpp ) set( tnl_solvers_linear_krylov_SOURCES ${common_SOURCES} PARENT_SCOPE ) @@ -15,6 +17,6 @@ if( BUILD_CUDA) set( tnl_solvers_linear_krylov_CUDA__SOURCES ${common_SOURCES} PARENT_SCOPE ) -endif() - +endif() + INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/solvers/linear/krylov ) diff --git a/src/solvers/tnlBuildConfigTags.h b/src/solvers/tnlBuildConfigTags.h index f19daad01d..1ee3d8a7c2 100644 --- a/src/solvers/tnlBuildConfigTags.h +++ b/src/solvers/tnlBuildConfigTags.h @@ -92,6 +92,7 @@ class tnlSemiImplicitSORSolverTag{}; class tnlSemiImplicitCGSolverTag{}; class tnlSemiImplicitBICGStabSolverTag{}; class tnlSemiImplicitGMRESSolverTag{}; +class tnlSemiImplicitTFQMRSolverTag{}; template< typename MeshConfig, typename SemiImplicitSolver > struct tnlMeshConfigSemiImplicitSolver{ enum { enabled = true }; }; diff --git a/src/solvers/tnlSolverConfig_impl.h b/src/solvers/tnlSolverConfig_impl.h index 728de597cd..323cfefbe1 100644 --- a/src/solvers/tnlSolverConfig_impl.h +++ b/src/solvers/tnlSolverConfig_impl.h @@ -114,6 +114,8 @@ bool tnlSolverConfig< MeshConfig, ProblemConfig >::configSetup( tnlConfigDescrip config.addEntryEnum( "bicgstab" ); if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitGMRESSolverTag >::enabled ) config.addEntryEnum( "gmres" ); + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitTFQMRSolverTag >::enabled ) + config.addEntryEnum( "tfqmr" ); if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitSORSolverTag >::enabled ) config.addEntryEnum( "sor" ); } @@ -143,6 +145,8 @@ bool tnlSolverConfig< MeshConfig, ProblemConfig >::configSetup( tnlConfigDescrip tnlBICGStabSolver< MatrixType >::configSetup( config ); if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitGMRESSolverTag >::enabled ) tnlGMRESSolver< MatrixType >::configSetup( config ); + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitTFQMRSolverTag >::enabled ) + tnlTFQMRSolver< MatrixType >::configSetup( config ); if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitSORSolverTag >::enabled ) tnlSORSolver< MatrixType >::configSetup( config ); } diff --git a/src/solvers/tnlSolverStarter_impl.h b/src/solvers/tnlSolverStarter_impl.h index 7a2728e1aa..e7ac161313 100644 --- a/src/solvers/tnlSolverStarter_impl.h +++ b/src/solvers/tnlSolverStarter_impl.h @@ -27,6 +27,7 @@ #include <solvers/linear/krylov/tnlCGSolver.h> #include <solvers/linear/krylov/tnlBICGStabSolver.h> #include <solvers/linear/krylov/tnlGMRESSolver.h> +#include <solvers/linear/krylov/tnlTFQMRSolver.h> #include <solvers/pde/tnlExplicitTimeStepper.h> #include <solvers/pde/tnlSemiImplicitTimeStepper.h> #include <solvers/pde/tnlPDESolver.h> @@ -187,9 +188,10 @@ class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDisc if( discreteSolver != "sor" && discreteSolver != "cg" && discreteSolver != "bicgstab" && - discreteSolver != "gmres" ) + discreteSolver != "gmres" && + discreteSolver != "tfqmr" ) { - cerr << "Unknown explicit discrete solver " << discreteSolver << ". It can be only: sor, cg, bicgstab or gmres." << endl; + cerr << "Unknown explicit discrete solver " << discreteSolver << ". It can be only: sor, cg, bicgstab, gmres or tfqmr." << endl; return false; } @@ -201,6 +203,8 @@ class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDisc return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitBICGStabSolverTag, MeshConfig >::run( problem, parameters ); if( discreteSolver == "gmres" ) return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSolverTag, MeshConfig >::run( problem, parameters ); + if( discreteSolver == "tfqmr" ) + return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitTFQMRSolverTag, MeshConfig >::run( problem, parameters ); return false; } }; @@ -356,6 +360,23 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSol } }; +template< typename Problem, + typename MeshConfig > +class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitTFQMRSolverTag, MeshConfig, true > +{ + public: + static bool run( Problem& problem, + const tnlParameterContainer& parameters ) + { + typedef typename Problem::MatrixType MatrixType; + typedef tnlTFQMRSolver< MatrixType > LinearSystemSolver; + typedef tnlSemiImplicitTimeStepper< Problem, LinearSystemSolver > TimeStepper; + return tnlSolverStarterSemiImplicitTimeStepperSetter< Problem, + TimeStepper, + MeshConfig >::run( problem, parameters ); + } +}; + /**** * Setting the explicit time stepper */ -- GitLab