Loading Documentation/Examples/Solvers/Linear/IterativeLinearSolverExample.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Solvers/Linear/GMRES.h> #include <TNL/Solvers/Linear/TFQMR.h> template< typename Device > void iterativeLinearSolverExample() Loading Loading @@ -63,7 +63,7 @@ void iterativeLinearSolverExample() /*** * Solve the linear system */ using LinearSolver = TNL::Solvers::Linear::GMRES< MatrixType >; using LinearSolver = TNL::Solvers::Linear::TFQMR< MatrixType >; LinearSolver solver; solver.setMatrix( matrix_ptr ); solver.solve( b, x ); Loading @@ -73,7 +73,7 @@ void iterativeLinearSolverExample() int main( int argc, char* argv[] ) { std::cout << "Solving linear system on host: " << std::endl; iterativeLinearSolverExample< TNL::Devices::Host >(); iterativeLinearSolverExample< TNL::Devices::Sequential >(); #ifdef HAVE_CUDA std::cout << "Solving linear system on CUDA device: " << std::endl; Loading Documentation/Examples/Solvers/Linear/IterativeLinearSolverWithMonitorExample.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <thread> #include <TNL/Algorithms/ParallelFor.h> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Sequential.h> #include <TNL/Devices/Cuda.h> #include <TNL/Solvers/Linear/Jacobi.h> Loading @@ -14,11 +14,11 @@ void iterativeLinearSolverExample() /*** * Set the following matrix (dots represent zero matrix elements): * * / 2 -1 . . . \ * | -1 2 -1 . . | * | . -1 2 -1. . | * | . . -1 2 -1 | * \ . . . -1 2 / * / 2.5 -1 . . . \ * | -1 2.5 -1 . . | * | . -1 2.5 -1. . | * | . . -1 2.5 -1 | * \ . . . -1 2.5 / */ using MatrixType = TNL::Matrices::SparseMatrix< double, Device >; using Vector = TNL::Containers::Vector< double, Device >; Loading Loading @@ -68,23 +68,18 @@ void iterativeLinearSolverExample() using LinearSolver = TNL::Solvers::Linear::Jacobi< MatrixType >; LinearSolver solver; solver.setMatrix( matrix_ptr ); solver.setOmega( 0.0005 ); /*** * Setup monitor of the iterative solver */ using IterativeSolverMonitorType = TNL::Solvers::IterativeSolverMonitor< double, int >; IterativeSolverMonitorType monitor; TNL::Solvers::SolverMonitorThread t(monitor); monitor.setRefreshRate(100); // refresh rate = timeout in milliseconds TNL::Solvers::SolverMonitorThread monitorThread(monitor); monitor.setRefreshRate(10); // refresh rate in milliseconds monitor.setVerbose(1); monitor.setStage( "Jacobi stage:" ); TNL::Timer timer; monitor.setTimer( timer ); solver.setSolverMonitor(monitor); solver.setOmega( 0.001 ); //std::this_thread::sleep_for(std::chrono::milliseconds(3000)); // wait for 3 seconds to let the monitor doing something timer.start(); solver.solve( b, x ); monitor.stopMainLoop(); std::cout << "Vector x = " << x << std::endl; Loading Loading
Documentation/Examples/Solvers/Linear/IterativeLinearSolverExample.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Solvers/Linear/GMRES.h> #include <TNL/Solvers/Linear/TFQMR.h> template< typename Device > void iterativeLinearSolverExample() Loading Loading @@ -63,7 +63,7 @@ void iterativeLinearSolverExample() /*** * Solve the linear system */ using LinearSolver = TNL::Solvers::Linear::GMRES< MatrixType >; using LinearSolver = TNL::Solvers::Linear::TFQMR< MatrixType >; LinearSolver solver; solver.setMatrix( matrix_ptr ); solver.solve( b, x ); Loading @@ -73,7 +73,7 @@ void iterativeLinearSolverExample() int main( int argc, char* argv[] ) { std::cout << "Solving linear system on host: " << std::endl; iterativeLinearSolverExample< TNL::Devices::Host >(); iterativeLinearSolverExample< TNL::Devices::Sequential >(); #ifdef HAVE_CUDA std::cout << "Solving linear system on CUDA device: " << std::endl; Loading
Documentation/Examples/Solvers/Linear/IterativeLinearSolverWithMonitorExample.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <thread> #include <TNL/Algorithms/ParallelFor.h> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Sequential.h> #include <TNL/Devices/Cuda.h> #include <TNL/Solvers/Linear/Jacobi.h> Loading @@ -14,11 +14,11 @@ void iterativeLinearSolverExample() /*** * Set the following matrix (dots represent zero matrix elements): * * / 2 -1 . . . \ * | -1 2 -1 . . | * | . -1 2 -1. . | * | . . -1 2 -1 | * \ . . . -1 2 / * / 2.5 -1 . . . \ * | -1 2.5 -1 . . | * | . -1 2.5 -1. . | * | . . -1 2.5 -1 | * \ . . . -1 2.5 / */ using MatrixType = TNL::Matrices::SparseMatrix< double, Device >; using Vector = TNL::Containers::Vector< double, Device >; Loading Loading @@ -68,23 +68,18 @@ void iterativeLinearSolverExample() using LinearSolver = TNL::Solvers::Linear::Jacobi< MatrixType >; LinearSolver solver; solver.setMatrix( matrix_ptr ); solver.setOmega( 0.0005 ); /*** * Setup monitor of the iterative solver */ using IterativeSolverMonitorType = TNL::Solvers::IterativeSolverMonitor< double, int >; IterativeSolverMonitorType monitor; TNL::Solvers::SolverMonitorThread t(monitor); monitor.setRefreshRate(100); // refresh rate = timeout in milliseconds TNL::Solvers::SolverMonitorThread monitorThread(monitor); monitor.setRefreshRate(10); // refresh rate in milliseconds monitor.setVerbose(1); monitor.setStage( "Jacobi stage:" ); TNL::Timer timer; monitor.setTimer( timer ); solver.setSolverMonitor(monitor); solver.setOmega( 0.001 ); //std::this_thread::sleep_for(std::chrono::milliseconds(3000)); // wait for 3 seconds to let the monitor doing something timer.start(); solver.solve( b, x ); monitor.stopMainLoop(); std::cout << "Vector x = " << x << std::endl; Loading