Loading src/solvers/linear/krylov/tnlGMRESSolver_impl.h +3 −5 Original line number Diff line number Diff line Loading @@ -269,11 +269,9 @@ bool tnlGMRESSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector& if( preconditioner ) { matrix -> vectorProduct( x, _M_tmp ); for( IndexType i = 0; i < _size; i ++ ) M_tmp[ i ] = b[ i ] - M_tmp[ i ]; //preconditioner -> solve( M_tmp, r ); for( IndexType i = 0; i < _size; i ++ ) beta += r[ i ] * r[ i ]; _M_tmp.addVector( b, ( RealType ) 1.0, -1.0 ); preconditioner -> solve( _M_tmp, _r ); beta = _r. lpNorm( ( RealType ) 2.0 ); } else { Loading src/solvers/pde/tnlSemiImplicitTimeStepper.h +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ class tnlSemiImplicitTimeStepper typedef typename ProblemType::DofVectorType DofVectorType; typedef typename ProblemType::MeshDependentDataType MeshDependentDataType; typedef LinearSystemSolver LinearSystemSolverType; typedef typename LinearSystemSolverType::PreconditionerType PreconditionerType; typedef typename ProblemType::MatrixType MatrixType; tnlSemiImplicitTimeStepper(); Loading src/solvers/pde/tnlSemiImplicitTimeStepper_impl.h +7 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,10 @@ solve( const RealType& time, tnlAssert( this->problem != 0, ); RealType t = time; this->linearSystemSolver->setMatrix( this->matrix ); PreconditionerType preconditioner; tnlSolverStarterSolverPreconditionerSetter< LinearSystemSolverType, PreconditionerType > ::run( *(this->linearSystemSolver), preconditioner ); while( t < stopTime ) { RealType currentTau = Min( this->timeStep, stopTime - t ); Loading Loading @@ -173,6 +177,9 @@ solve( const RealType& time, if( verbose ) cout << " Solving the linear system for time " << t + currentTau << " \r" << flush; // TODO: add timer preconditioner.update( this->matrix ); this->linearSystemSolverTimer.start(); if( ! this->linearSystemSolver->template solve< DofVectorType, tnlLinearResidueGetter< MatrixType, DofVectorType > >( this->rightHandSide, dofVector ) ) { Loading src/solvers/preconditioners/CMakeLists.txt +2 −0 Original line number Diff line number Diff line SET( headers tnlDummyPreconditioner.h tnlDiagonalPreconditioner.h tnlDiagonalPreconditioner_impl.h ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/solvers/preconditioners ) src/solvers/preconditioners/tnlDiagonalPreconditioner.h 0 → 100644 +33 −0 Original line number Diff line number Diff line #ifndef TNLDIAGONALPRECONDITIONER_H_ #define TNLDIAGONALPRECONDITIONER_H_ #include <core/tnlObject.h> #include <core/vectors/tnlVector.h> template< typename Real, typename Device, typename Index > class tnlDiagonalPreconditioner { public: typedef Real RealType; typedef Device DeviceType; typedef Index IndexType; typedef tnlVector< Real, Device, Index > VectorType; template< typename Matrix > void update( const Matrix& matrix ); template< typename Vector1, typename Vector2 > bool solve( const Vector1& b, Vector2& x ) const; tnlString getType() const { return tnlString( "tnlDiagonalPreconditioner" ); } protected: VectorType diagonal; }; #include <solvers/preconditioners/tnlDiagonalPreconditioner_impl.h> #endif /* TNLDIAGONALPRECONDITIONER_H_ */ Loading
src/solvers/linear/krylov/tnlGMRESSolver_impl.h +3 −5 Original line number Diff line number Diff line Loading @@ -269,11 +269,9 @@ bool tnlGMRESSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector& if( preconditioner ) { matrix -> vectorProduct( x, _M_tmp ); for( IndexType i = 0; i < _size; i ++ ) M_tmp[ i ] = b[ i ] - M_tmp[ i ]; //preconditioner -> solve( M_tmp, r ); for( IndexType i = 0; i < _size; i ++ ) beta += r[ i ] * r[ i ]; _M_tmp.addVector( b, ( RealType ) 1.0, -1.0 ); preconditioner -> solve( _M_tmp, _r ); beta = _r. lpNorm( ( RealType ) 2.0 ); } else { Loading
src/solvers/pde/tnlSemiImplicitTimeStepper.h +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ class tnlSemiImplicitTimeStepper typedef typename ProblemType::DofVectorType DofVectorType; typedef typename ProblemType::MeshDependentDataType MeshDependentDataType; typedef LinearSystemSolver LinearSystemSolverType; typedef typename LinearSystemSolverType::PreconditionerType PreconditionerType; typedef typename ProblemType::MatrixType MatrixType; tnlSemiImplicitTimeStepper(); Loading
src/solvers/pde/tnlSemiImplicitTimeStepper_impl.h +7 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,10 @@ solve( const RealType& time, tnlAssert( this->problem != 0, ); RealType t = time; this->linearSystemSolver->setMatrix( this->matrix ); PreconditionerType preconditioner; tnlSolverStarterSolverPreconditionerSetter< LinearSystemSolverType, PreconditionerType > ::run( *(this->linearSystemSolver), preconditioner ); while( t < stopTime ) { RealType currentTau = Min( this->timeStep, stopTime - t ); Loading Loading @@ -173,6 +177,9 @@ solve( const RealType& time, if( verbose ) cout << " Solving the linear system for time " << t + currentTau << " \r" << flush; // TODO: add timer preconditioner.update( this->matrix ); this->linearSystemSolverTimer.start(); if( ! this->linearSystemSolver->template solve< DofVectorType, tnlLinearResidueGetter< MatrixType, DofVectorType > >( this->rightHandSide, dofVector ) ) { Loading
src/solvers/preconditioners/CMakeLists.txt +2 −0 Original line number Diff line number Diff line SET( headers tnlDummyPreconditioner.h tnlDiagonalPreconditioner.h tnlDiagonalPreconditioner_impl.h ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/solvers/preconditioners )
src/solvers/preconditioners/tnlDiagonalPreconditioner.h 0 → 100644 +33 −0 Original line number Diff line number Diff line #ifndef TNLDIAGONALPRECONDITIONER_H_ #define TNLDIAGONALPRECONDITIONER_H_ #include <core/tnlObject.h> #include <core/vectors/tnlVector.h> template< typename Real, typename Device, typename Index > class tnlDiagonalPreconditioner { public: typedef Real RealType; typedef Device DeviceType; typedef Index IndexType; typedef tnlVector< Real, Device, Index > VectorType; template< typename Matrix > void update( const Matrix& matrix ); template< typename Vector1, typename Vector2 > bool solve( const Vector1& b, Vector2& x ) const; tnlString getType() const { return tnlString( "tnlDiagonalPreconditioner" ); } protected: VectorType diagonal; }; #include <solvers/preconditioners/tnlDiagonalPreconditioner_impl.h> #endif /* TNLDIAGONALPRECONDITIONER_H_ */