Skip to content
Snippets Groups Projects
Commit 5a1c176a authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed bug in setting preconditioners

parent d1678765
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@
#include <cstring>
#define TNL_DEBUG_SHARED_POINTERS
//#define TNL_DEBUG_SHARED_POINTERS
#ifdef TNL_DEBUG_SHARED_POINTERS
#include <typeinfo>
......@@ -83,7 +83,7 @@ class SharedPointer< Object, Devices::Host, lazy > : public SmartPointer
typedef Object ObjectType;
typedef Devices::Host DeviceType;
typedef SharedPointer< Object, Devices::Host, lazy > ThisType;
template< typename... Args >
explicit SharedPointer( Args... args )
: pd( nullptr )
......
......@@ -11,6 +11,7 @@
#pragma once
#include <TNL/Object.h>
#include <TNL/SharedPointer.h>
namespace TNL {
namespace Solvers {
......@@ -26,7 +27,12 @@ class Dummy
void update( const Matrix& matrix ) {}
template< typename Vector1, typename Vector2 >
bool solve( const Vector1& b, Vector2& x ) const { return true; }
bool solve( const Vector1& b, Vector2& x ) const
{
Assert( false,
std::cerr << "The solve() method of a dummy preconditioner should not be called." << std::endl; );
return true;
}
String getType() const
{
......@@ -39,7 +45,8 @@ class SolverStarterSolverPreconditionerSetter
{
public:
static void run( LinearSolver& solver, Preconditioner& preconditioner )
static void run( LinearSolver& solver,
SharedPointer< Preconditioner, typename LinearSolver::DeviceType >& preconditioner )
{
solver.setPreconditioner( preconditioner );
}
......@@ -53,7 +60,8 @@ class SolverStarterSolverPreconditionerSetter< LinearSolver, Dummy< Real, Device
typedef Device DeviceType;
typedef Dummy< Real, DeviceType, Index > PreconditionerType;
static void run( LinearSolver& solver, PreconditionerType& preconditioner )
static void run( LinearSolver& solver,
SharedPointer< PreconditionerType, typename LinearSolver::DeviceType >& preconditioner )
{
// do nothing
}
......
......@@ -158,7 +158,7 @@ solve( const RealType& time,
RealType t = time;
this->linearSystemSolver->setMatrix( this->matrix );
PreconditionerPointer preconditioner;
Linear::Preconditioners::SolverStarterSolverPreconditionerSetter< LinearSystemSolverType, PreconditionerPointer >
Linear::Preconditioners::SolverStarterSolverPreconditionerSetter< LinearSystemSolverType, PreconditionerType >
::run( *(this->linearSystemSolver), preconditioner );
while( t < stopTime )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment