Loading src/matrix/Makefile.am +2 −2 Original line number Diff line number Diff line ## Process this file with automake to produce Makefile.in headers = \ mMatrix.h \ tnlMatrix.h \ tnlCSRMatrix.h \ tnlFullMatrix.h \ tnlBaseMatrix.h \ mMatrixSolver.h \ tnlMatrixSolver.h \ mPETSCMatrix.h \ mPETSCSolver.h \ mSORSolver.h \ Loading src/matrix/mPETSCMatrix.h +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ template< typename T > class mPETSCMatrix : public tnlBaseMatrix< T > const tnlString& GetMatrixClass() const { return mMatrixClass :: petsc; return tnlMatrixClass :: petsc; }; void GetData( Mat& _matrix ) Loading src/matrix/mPETSCSolver.h +9 −9 Original line number Diff line number Diff line Loading @@ -23,14 +23,14 @@ #include <petsc.h> #endif #include <matrix/mMatrixSolver.h> #include <matrix/tnlMatrixSolver.h> #ifdef HAVE_PETSC template< typename T > inline PetscErrorCode PETSCSolverMonitorCallback( KSP petsc_solver, PetscInt iter, PetscReal rnorm, void* ctx ); #endif //! This class is a wrapper for the PETSc solvers. template< typename T > class mPETSCSolver : public mMatrixSolver< T > template< typename T > class mPETSCSolver : public tnlMatrixSolver< T > { #ifdef HAVE_PETSC KSP petsc_solver; Loading Loading @@ -74,9 +74,9 @@ template< typename T > class mPETSCSolver : public mMatrixSolver< T > KSPGetIterationNumber( petsc_solver, &it ); PetscReal res; KSPGetResidualNorm( petsc_solver, &res ); mMatrixSolver< T > :: iteration = it; mMatrixSolver< T > :: residue = res; mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: iteration = it; tnlMatrixSolver< T > :: residue = res; tnlMatrixSolver< T > :: PrintOut(); #else cerr << "Missing support for PETSC at the file " << __FILE__ << " line " << __LINE__ << endl; #endif Loading @@ -90,7 +90,7 @@ template< typename T > class mPETSCSolver : public mMatrixSolver< T > mPreconditioner< T >* precond = 0 ) { #ifdef HAVE_PETSC assert( A. GetMatrixClass() == mMatrixClass :: petsc ); assert( A. GetMatrixClass() == tnlMatrixClass :: petsc ); Vec petsc_x, petsc_b; mPETSCMatrix< T >* petsc_matrix = ( mPETSCMatrix< T >* ) & A; Mat matrix; Loading Loading @@ -133,13 +133,13 @@ template< typename T > class mPETSCSolver : public mMatrixSolver< T > PetscInt its; KSPGetIterationNumber( petsc_solver, &its ); mMatrixSolver< T > :: iteration = its; tnlMatrixSolver< T > :: iteration = its; if( mMatrixSolver< T > :: iteration < 0 ) return false; if( tnlMatrixSolver< T > :: iteration < 0 ) return false; PetscReal res; KSPGetResidualNorm( petsc_solver, &res ); mMatrixSolver< T > :: residue = res / normb; tnlMatrixSolver< T > :: residue = res / normb; //KSPDestroy( petsc_solver ); Loading src/matrix/mSORSolver.h +14 −14 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ #define mSORSolverH #include <math.h> #include <matrix/mMatrixSolver.h> #include <matrix/tnlMatrixSolver.h> template< typename T > class mSORSolver : public mMatrixSolver< T > template< typename T > class mSORSolver : public tnlMatrixSolver< T > { public: Loading @@ -43,16 +43,16 @@ template< typename T > class mSORSolver : public mMatrixSolver< T > { const long int size = A. GetSize(); long int i; mMatrixSolver< T > :: iteration = 0; mMatrixSolver< T > :: residue = max_residue + 1.0;; tnlMatrixSolver< T > :: iteration = 0; tnlMatrixSolver< T > :: residue = max_residue + 1.0;; T b_norm( 0.0 ); for( i = 0; i < size; i ++ ) b_norm += b[ i ] * b[ i ]; b_norm = sqrt( b_norm ); while( mMatrixSolver< T > :: iteration < max_iterations && max_residue < mMatrixSolver< T > :: residue ) while( tnlMatrixSolver< T > :: iteration < max_iterations && max_residue < tnlMatrixSolver< T > :: residue ) { for( i = 0; i < size; i ++ ) { Loading @@ -67,19 +67,19 @@ template< typename T > class mSORSolver : public mMatrixSolver< T > } x[ i ] = ( 1.0 - sor_omega ) * x_i + sor_omega * ( b[ i ] - sigma ) / diag_entry; } if( mMatrixSolver< T > :: iteration % 10 == 0 && mMatrixSolver< T > :: verbosity > 1 ) if( tnlMatrixSolver< T > :: iteration % 10 == 0 && tnlMatrixSolver< T > :: verbosity > 1 ) { mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); tnlMatrixSolver< T > :: PrintOut(); } mMatrixSolver< T > :: iteration ++; tnlMatrixSolver< T > :: iteration ++; } if( mMatrixSolver< T > :: verbosity > 0 ) if( tnlMatrixSolver< T > :: verbosity > 0 ) { mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); tnlMatrixSolver< T > :: PrintOut(); } if( mMatrixSolver< T > :: iteration <= max_iterations ) return true; if( tnlMatrixSolver< T > :: iteration <= max_iterations ) return true; return false; }; Loading src/matrix/tnlBICGSolver.h +14 −14 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ #define tnlBICGSolverH #include <math.h> #include <matrix/mMatrixSolver.h> #include <matrix/tnlMatrixSolver.h> template< typename T > class tnlBICGSolver : public mMatrixSolver< T > template< typename T > class tnlBICGSolver : public tnlMatrixSolver< T > { public: Loading Loading @@ -50,8 +50,8 @@ template< typename T > class tnlBICGSolver : public mMatrixSolver< T > return false; } mMatrixSolver< T > :: residue = max_residue + 1.0; mMatrixSolver< T > :: iteration = 0; tnlMatrixSolver< T > :: residue = max_residue + 1.0; tnlMatrixSolver< T > :: iteration = 0; T alpha, beta, s1, s2; T b_norm( 0.0 ); long int i; Loading @@ -70,8 +70,8 @@ template< typename T > class tnlBICGSolver : public mMatrixSolver< T > p[ i ] = p_ast[ i ] = b[ i ] - r[ i ]; while( mMatrixSolver< T > :: iteration < max_iterations && mMatrixSolver< T > :: residue > max_residue ) while( tnlMatrixSolver< T > :: iteration < max_iterations && tnlMatrixSolver< T > :: residue > max_residue ) { //dbgCout( "Starting BiCG iteration " << iter + 1 ); Loading Loading @@ -130,17 +130,17 @@ template< typename T > class tnlBICGSolver : public mMatrixSolver< T > r_ast_new = r_ast; r_ast = q; if( mMatrixSolver< T > :: iteration % 10 == 0 ) if( tnlMatrixSolver< T > :: iteration % 10 == 0 ) { mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, tmp ); if( mMatrixSolver< T > :: verbosity > 1 ) mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, tmp ); if( tnlMatrixSolver< T > :: verbosity > 1 ) tnlMatrixSolver< T > :: PrintOut(); } mMatrixSolver< T > :: iteration ++; tnlMatrixSolver< T > :: iteration ++; } mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, r ); if( mMatrixSolver< T > :: verbosity > 0 ) mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, r ); if( tnlMatrixSolver< T > :: verbosity > 0 ) tnlMatrixSolver< T > :: PrintOut(); }; ~tnlBICGSolver() Loading Loading
src/matrix/Makefile.am +2 −2 Original line number Diff line number Diff line ## Process this file with automake to produce Makefile.in headers = \ mMatrix.h \ tnlMatrix.h \ tnlCSRMatrix.h \ tnlFullMatrix.h \ tnlBaseMatrix.h \ mMatrixSolver.h \ tnlMatrixSolver.h \ mPETSCMatrix.h \ mPETSCSolver.h \ mSORSolver.h \ Loading
src/matrix/mPETSCMatrix.h +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ template< typename T > class mPETSCMatrix : public tnlBaseMatrix< T > const tnlString& GetMatrixClass() const { return mMatrixClass :: petsc; return tnlMatrixClass :: petsc; }; void GetData( Mat& _matrix ) Loading
src/matrix/mPETSCSolver.h +9 −9 Original line number Diff line number Diff line Loading @@ -23,14 +23,14 @@ #include <petsc.h> #endif #include <matrix/mMatrixSolver.h> #include <matrix/tnlMatrixSolver.h> #ifdef HAVE_PETSC template< typename T > inline PetscErrorCode PETSCSolverMonitorCallback( KSP petsc_solver, PetscInt iter, PetscReal rnorm, void* ctx ); #endif //! This class is a wrapper for the PETSc solvers. template< typename T > class mPETSCSolver : public mMatrixSolver< T > template< typename T > class mPETSCSolver : public tnlMatrixSolver< T > { #ifdef HAVE_PETSC KSP petsc_solver; Loading Loading @@ -74,9 +74,9 @@ template< typename T > class mPETSCSolver : public mMatrixSolver< T > KSPGetIterationNumber( petsc_solver, &it ); PetscReal res; KSPGetResidualNorm( petsc_solver, &res ); mMatrixSolver< T > :: iteration = it; mMatrixSolver< T > :: residue = res; mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: iteration = it; tnlMatrixSolver< T > :: residue = res; tnlMatrixSolver< T > :: PrintOut(); #else cerr << "Missing support for PETSC at the file " << __FILE__ << " line " << __LINE__ << endl; #endif Loading @@ -90,7 +90,7 @@ template< typename T > class mPETSCSolver : public mMatrixSolver< T > mPreconditioner< T >* precond = 0 ) { #ifdef HAVE_PETSC assert( A. GetMatrixClass() == mMatrixClass :: petsc ); assert( A. GetMatrixClass() == tnlMatrixClass :: petsc ); Vec petsc_x, petsc_b; mPETSCMatrix< T >* petsc_matrix = ( mPETSCMatrix< T >* ) & A; Mat matrix; Loading Loading @@ -133,13 +133,13 @@ template< typename T > class mPETSCSolver : public mMatrixSolver< T > PetscInt its; KSPGetIterationNumber( petsc_solver, &its ); mMatrixSolver< T > :: iteration = its; tnlMatrixSolver< T > :: iteration = its; if( mMatrixSolver< T > :: iteration < 0 ) return false; if( tnlMatrixSolver< T > :: iteration < 0 ) return false; PetscReal res; KSPGetResidualNorm( petsc_solver, &res ); mMatrixSolver< T > :: residue = res / normb; tnlMatrixSolver< T > :: residue = res / normb; //KSPDestroy( petsc_solver ); Loading
src/matrix/mSORSolver.h +14 −14 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ #define mSORSolverH #include <math.h> #include <matrix/mMatrixSolver.h> #include <matrix/tnlMatrixSolver.h> template< typename T > class mSORSolver : public mMatrixSolver< T > template< typename T > class mSORSolver : public tnlMatrixSolver< T > { public: Loading @@ -43,16 +43,16 @@ template< typename T > class mSORSolver : public mMatrixSolver< T > { const long int size = A. GetSize(); long int i; mMatrixSolver< T > :: iteration = 0; mMatrixSolver< T > :: residue = max_residue + 1.0;; tnlMatrixSolver< T > :: iteration = 0; tnlMatrixSolver< T > :: residue = max_residue + 1.0;; T b_norm( 0.0 ); for( i = 0; i < size; i ++ ) b_norm += b[ i ] * b[ i ]; b_norm = sqrt( b_norm ); while( mMatrixSolver< T > :: iteration < max_iterations && max_residue < mMatrixSolver< T > :: residue ) while( tnlMatrixSolver< T > :: iteration < max_iterations && max_residue < tnlMatrixSolver< T > :: residue ) { for( i = 0; i < size; i ++ ) { Loading @@ -67,19 +67,19 @@ template< typename T > class mSORSolver : public mMatrixSolver< T > } x[ i ] = ( 1.0 - sor_omega ) * x_i + sor_omega * ( b[ i ] - sigma ) / diag_entry; } if( mMatrixSolver< T > :: iteration % 10 == 0 && mMatrixSolver< T > :: verbosity > 1 ) if( tnlMatrixSolver< T > :: iteration % 10 == 0 && tnlMatrixSolver< T > :: verbosity > 1 ) { mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); tnlMatrixSolver< T > :: PrintOut(); } mMatrixSolver< T > :: iteration ++; tnlMatrixSolver< T > :: iteration ++; } if( mMatrixSolver< T > :: verbosity > 0 ) if( tnlMatrixSolver< T > :: verbosity > 0 ) { mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm ); tnlMatrixSolver< T > :: PrintOut(); } if( mMatrixSolver< T > :: iteration <= max_iterations ) return true; if( tnlMatrixSolver< T > :: iteration <= max_iterations ) return true; return false; }; Loading
src/matrix/tnlBICGSolver.h +14 −14 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ #define tnlBICGSolverH #include <math.h> #include <matrix/mMatrixSolver.h> #include <matrix/tnlMatrixSolver.h> template< typename T > class tnlBICGSolver : public mMatrixSolver< T > template< typename T > class tnlBICGSolver : public tnlMatrixSolver< T > { public: Loading Loading @@ -50,8 +50,8 @@ template< typename T > class tnlBICGSolver : public mMatrixSolver< T > return false; } mMatrixSolver< T > :: residue = max_residue + 1.0; mMatrixSolver< T > :: iteration = 0; tnlMatrixSolver< T > :: residue = max_residue + 1.0; tnlMatrixSolver< T > :: iteration = 0; T alpha, beta, s1, s2; T b_norm( 0.0 ); long int i; Loading @@ -70,8 +70,8 @@ template< typename T > class tnlBICGSolver : public mMatrixSolver< T > p[ i ] = p_ast[ i ] = b[ i ] - r[ i ]; while( mMatrixSolver< T > :: iteration < max_iterations && mMatrixSolver< T > :: residue > max_residue ) while( tnlMatrixSolver< T > :: iteration < max_iterations && tnlMatrixSolver< T > :: residue > max_residue ) { //dbgCout( "Starting BiCG iteration " << iter + 1 ); Loading Loading @@ -130,17 +130,17 @@ template< typename T > class tnlBICGSolver : public mMatrixSolver< T > r_ast_new = r_ast; r_ast = q; if( mMatrixSolver< T > :: iteration % 10 == 0 ) if( tnlMatrixSolver< T > :: iteration % 10 == 0 ) { mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, tmp ); if( mMatrixSolver< T > :: verbosity > 1 ) mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, tmp ); if( tnlMatrixSolver< T > :: verbosity > 1 ) tnlMatrixSolver< T > :: PrintOut(); } mMatrixSolver< T > :: iteration ++; tnlMatrixSolver< T > :: iteration ++; } mMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, r ); if( mMatrixSolver< T > :: verbosity > 0 ) mMatrixSolver< T > :: PrintOut(); tnlMatrixSolver< T > :: residue = GetResidue( A, b, x, b_norm, r ); if( tnlMatrixSolver< T > :: verbosity > 0 ) tnlMatrixSolver< T > :: PrintOut(); }; ~tnlBICGSolver() Loading