From 7cd842c7201e1e632d652c6476471f9b35d0cbac Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Sun, 24 Feb 2013 11:42:22 +0100 Subject: [PATCH] Fixing GMRES solver to work with different Vector types. --- examples/simple-solver/main.cpp | 8 ++++++++ src/implementation/config/tnlBasicTypesSetter_impl.h | 5 ++++- .../solvers/linear/krylov/tnlGMRESSolver_impl.h | 3 ++- src/solvers/linear/krylov/tnlGMRESSolver.h | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/simple-solver/main.cpp b/examples/simple-solver/main.cpp index ff58abf960..9d3e4ce207 100644 --- a/examples/simple-solver/main.cpp +++ b/examples/simple-solver/main.cpp @@ -20,9 +20,17 @@ #include <config/tnlBasicTypesSetter.h> #include <solvers/tnlProblemSolver.h> +#include <core/tnlHost.h> +#include <config/tnlParameterContainer.h> + int main( int argc, char* argv[] ) { typedef simpleProblemTypesSetter ProblemSetter; + + tnlParameterContainer parameters; + ProblemSetter problemSetter; + problemSetter. run< double, tnlHost, int >( parameters ); + typedef tnlBasicTypesSetter< ProblemSetter > BasicTypesSetter; tnlProblemSolver< BasicTypesSetter > problemSolver; if( ! problemSolver. run( CONFIG_FILE, argc, argv ) ) diff --git a/src/implementation/config/tnlBasicTypesSetter_impl.h b/src/implementation/config/tnlBasicTypesSetter_impl.h index 68e79c6a6b..d1252aa61f 100644 --- a/src/implementation/config/tnlBasicTypesSetter_impl.h +++ b/src/implementation/config/tnlBasicTypesSetter_impl.h @@ -111,11 +111,14 @@ bool tnlBasicTypesSetter< ProblemTypesSetter > :: setDeviceType( const tnlParame return false; } ProblemTypesSetter problemTypesSetter; + /*const tnlString& device2 = parameters. GetParameter< tnlString >( "device" ); + problemTypesSetter. run< double, tnlHost, int >( parameters ); + problemTypesSetter. run< RealType, tnlHost, IndexType >( parameters ); if( device == "host" ) return problemTypesSetter. run< RealType, tnlHost, IndexType >( parameters ); if( device == "cuda" ) return problemTypesSetter. run( parameters ); - cerr << "The device '" << device << "' is not defined. " << endl; + cerr << "The device '" << device << "' is not defined. " << endl;*/ return false; } diff --git a/src/implementation/solvers/linear/krylov/tnlGMRESSolver_impl.h b/src/implementation/solvers/linear/krylov/tnlGMRESSolver_impl.h index ddc12d4359..d3033cd9cb 100644 --- a/src/implementation/solvers/linear/krylov/tnlGMRESSolver_impl.h +++ b/src/implementation/solvers/linear/krylov/tnlGMRESSolver_impl.h @@ -272,12 +272,13 @@ tnlGMRESSolver< Matrix, Preconditioner > :: ~tnlGMRESSolver() template< typename Matrix, typename Preconditioner > + template< typename Vector > void tnlGMRESSolver< Matrix, Preconditioner > :: update( IndexType k, IndexType m, const tnlVector< RealType, tnlHost, IndexType >& H, const tnlVector< RealType, tnlHost, IndexType >& s, tnlVector< RealType, DeviceType, IndexType >& v, - tnlVector< RealType, DeviceType, IndexType >& x ) + Vector& x ) { //dbgFunctionName( "tnlGMRESSolver", "Update" ); tnlVector< RealType, tnlHost, IndexType > y( "tnlGMRESSolver::update:y" ); diff --git a/src/solvers/linear/krylov/tnlGMRESSolver.h b/src/solvers/linear/krylov/tnlGMRESSolver.h index a9ac9195d6..1a1b07cc1c 100644 --- a/src/solvers/linear/krylov/tnlGMRESSolver.h +++ b/src/solvers/linear/krylov/tnlGMRESSolver.h @@ -59,12 +59,13 @@ class tnlGMRESSolver : public tnlObject, protected: + template< typename Vector > void update( IndexType k, IndexType m, const tnlVector< RealType, tnlHost, IndexType >& H, const tnlVector< RealType, tnlHost, IndexType >& s, tnlVector< RealType, DeviceType, IndexType >& v, - tnlVector< RealType, DeviceType, IndexType >& x ); + Vector& x ); void generatePlaneRotation( RealType &dx, RealType &dy, -- GitLab