Template Numerical Library version\ main:47c9bc3e
Loading...
Searching...
No Matches
TNL::Solvers::IterativeSolverMonitor< Real, Index > Class Template Reference

Object for monitoring convergence of iterative solvers. More...

#include <TNL/Solvers/IterativeSolverMonitor.h>

Inheritance diagram for TNL::Solvers::IterativeSolverMonitor< Real, Index >:
Collaboration diagram for TNL::Solvers::IterativeSolverMonitor< Real, Index >:

Public Types

using IndexType = Index
 A type for indexing.
using RealType = Real
 A type of the floating-point arithmetics.

Public Member Functions

 IterativeSolverMonitor ()=default
 Construct with no parameters.
void refresh () override
 Causes that the monitor prints out the status of the solver.
void setIterations (const IndexType &iterations)
 Set number of the current iteration.
void setNodesPerIteration (const IndexType &nodes)
 Set the number of nodes of the numerical mesh or lattice.
void setResidue (const RealType &residue)
 Set residue of the current approximation of the solution.
void setStage (const std::string &stage)
 This method can be used for naming a stage of the monitored solver.
void setTime (const RealType &time)
 Set the time of the simulated evolution if it is time dependent.
void setTimeStep (const RealType &timeStep)
 Set the time step for time dependent iterative solvers.
void setVerbose (const IndexType &verbose)
 Set up the verbosity of the monitor.
Public Member Functions inherited from TNL::Solvers::SolverMonitor
 SolverMonitor ()=default
 Basic construct with no arguments.
bool isStopped () const
 Checks whether the main loop was stopped.
void runMainLoop ()
 Starts the main loop from which the method SolverMonitor::refresh is called in given time periods.
void setRefreshRate (const int &refreshRate)
 Set the time interval between two consecutive calls of SolverMonitor::refresh.
void setTimer (Timer &timer)
 Set a timer object for the solver monitor.
void stopMainLoop ()
 Stops the main loop of the monitor. See runMainLoop.

Protected Member Functions

int getLineWidth ()
Protected Member Functions inherited from TNL::Solvers::SolverMonitor
double getElapsedTime ()

Protected Attributes

std::atomic_bool attributes_changed { false }
RealType elapsed_time_before_refresh = 0
IndexType iterations = 0
IndexType iterations_before_refresh = 0
RealType last_mlups = 0
IndexType nodesPerIteration = 0
RealType residue = 0
std::atomic_bool saved { false }
IndexType saved_iterations = 0
RealType saved_residue = 0
std::string saved_stage
RealType saved_time = 0
RealType saved_timeStep = 0
std::string stage
RealType time = 0
RealType timeStep = 0
IndexType verbose = 2
Protected Attributes inherited from TNL::Solvers::SolverMonitor
std::atomic_bool started { false }
std::atomic_bool stopped { false }
std::atomic_int timeout_milliseconds { 500 }
Timertimer = nullptr

Detailed Description

template<typename Real = double, typename Index = int>
class TNL::Solvers::IterativeSolverMonitor< Real, Index >

Object for monitoring convergence of iterative solvers.

Template Parameters
Realis a type of the floating-point arithmetics.
Indexis an indexing type.

The following example shows how to use the iterative solver monitor for monitoring convergence of linear iterative solver:

1#include <iostream>
2#include <memory>
3#include <chrono>
4#include <thread>
5#include <TNL/Matrices/SparseMatrix.h>
6#include <TNL/Devices/Sequential.h>
7#include <TNL/Devices/Cuda.h>
8#include <TNL/Solvers/Linear/Jacobi.h>
9
10template< typename Device >
11void
12iterativeLinearSolverExample()
13{
14 /***
15 * Set the following matrix (dots represent zero matrix elements):
16 *
17 * / 2.5 -1 . . . \
18 * | -1 2.5 -1 . . |
19 * | . -1 2.5 -1. . |
20 * | . . -1 2.5 -1 |
21 * \ . . . -1 2.5 /
22 */
25 const int size( 5 );
26 auto matrix_ptr = std::make_shared< MatrixType >();
27 matrix_ptr->setDimensions( size, size );
28 matrix_ptr->setRowCapacities( Vector( { 2, 3, 3, 3, 2 } ) );
29
30 auto f = [ = ] __cuda_callable__( typename MatrixType::RowView & row ) mutable
31 {
32 const int rowIdx = row.getRowIndex();
33 if( rowIdx == 0 ) {
34 row.setElement( 0, rowIdx, 2.5 ); // diagonal element
35 row.setElement( 1, rowIdx + 1, -1 ); // element above the diagonal
36 }
37 else if( rowIdx == size - 1 ) {
38 row.setElement( 0, rowIdx - 1, -1.0 ); // element below the diagonal
39 row.setElement( 1, rowIdx, 2.5 ); // diagonal element
40 }
41 else {
42 row.setElement( 0, rowIdx - 1, -1.0 ); // element below the diagonal
43 row.setElement( 1, rowIdx, 2.5 ); // diagonal element
44 row.setElement( 2, rowIdx + 1, -1.0 ); // element above the diagonal
45 }
46 };
47
48 /***
49 * Set the matrix elements.
50 */
51 matrix_ptr->forAllRows( f );
52 std::cout << *matrix_ptr << std::endl;
53
54 /***
55 * Set the right-hand side vector.
56 */
57 Vector x( size, 1.0 );
58 Vector b( size );
59 matrix_ptr->vectorProduct( x, b );
60 x = 0.0;
61 std::cout << "Vector b = " << b << std::endl;
62
63 /***
64 * Setup solver of the linear system.
65 */
67 LinearSolver solver;
68 solver.setMatrix( matrix_ptr );
69 solver.setOmega( 0.0005 );
70
71 /***
72 * Setup monitor of the iterative solver.
73 */
74 using IterativeSolverMonitorType = TNL::Solvers::IterativeSolverMonitor< double, int >;
75 IterativeSolverMonitorType monitor;
76 TNL::Solvers::SolverMonitorThread monitorThread( monitor );
77 monitor.setRefreshRate( 10 ); // refresh rate in milliseconds
78 monitor.setVerbose( 1 );
79 monitor.setStage( "Jacobi stage:" );
80 solver.setSolverMonitor( monitor );
81 solver.setConvergenceResidue( 1.0e-6 );
82 solver.solve( b, x );
83 monitor.stopMainLoop();
84 std::cout << "Vector x = " << x << std::endl;
85}
86
87int
88main( int argc, char* argv[] )
89{
90 std::cout << "Solving linear system on host: " << std::endl;
91 iterativeLinearSolverExample< TNL::Devices::Sequential >();
92
93#ifdef __CUDACC__
94 std::cout << "Solving linear system on CUDA device: " << std::endl;
95 iterativeLinearSolverExample< TNL::Devices::Cuda >();
96#endif
97}
#define __cuda_callable__
Definition Macros.h:49
Vector extends Array with algebraic operations.
Definition Vector.h:36
Implementation of sparse matrix, i.e. matrix storing only non-zero elements.
Definition SparseMatrix.h:55
Iterative solver of linear systems based on the Jacobi method.
Definition Jacobi.h:21
void setMatrix(const MatrixPointer &matrix)
Set the matrix of the linear system.
Definition LinearSolver.h:120
A RAII wrapper for launching the SolverMonitor's main loop in a separate thread.
Definition SolverMonitor.h:133
T endl(T... args)
T make_shared(T... args)

The result looks as follows:

Solving linear system on host:
Row: 0 -> 0:2.5 1:-1
Row: 1 -> 0:-1 1:2.5 2:-1
Row: 2 -> 1:-1 2:2.5 3:-1
Row: 3 -> 2:-1 3:2.5 4:-1
Row: 4 -> 3:-1 4:2.5
Vector b = [ 1.5, 0.5, 0.5, 0.5, 1.5 ]
Jacobi stage: ITER: 33709 RES: 0.0040741
Jacobi stage: ITER: 68265 RES: 2.0177e-05
Vector x = [ 0.999999, 0.999999, 0.999998, 0.999999, 0.999999 ]
Solving linear system on CUDA device:
Row: 0 -> 0:2.5 1:-1
Row: 1 -> 0:-1 1:2.5 2:-1
Row: 2 -> 1:-1 2:2.5 3:-1
Row: 3 -> 2:-1 3:2.5 4:-1
Row: 4 -> 3:-1 4:2.5
Vector b = [ 1.5, 0.5, 0.5, 0.5, 1.5 ]
Jacobi stage: ITER: 1443 RES: 0.66045
Jacobi stage: ITER: 1843 RES: 0.60246
Jacobi stage: ITER: 2175 RES: 0.56113
Jacobi stage: ITER: 2507 RES: 0.52465
Jacobi stage: ITER: 2839 RES: 0.4921
Jacobi stage: ITER: 3171 RES: 0.46275
Jacobi stage: ITER: 3503 RES: 0.43606
Jacobi stage: ITER: 3835 RES: 0.4116
Jacobi stage: ITER: 4167 RES: 0.38904
Jacobi stage: ITER: 4499 RES: 0.36812
Jacobi stage: ITER: 4835 RES: 0.3484
Jacobi stage: ITER: 5159 RES: 0.3306
Jacobi stage: ITER: 5499 RES: 0.31308
Jacobi stage: ITER: 5839 RES: 0.29663
Jacobi stage: ITER: 6147 RES: 0.28256
Jacobi stage: ITER: 6487 RES: 0.26788
Jacobi stage: ITER: 6827 RES: 0.25403
Jacobi stage: ITER: 7167 RES: 0.24093
Jacobi stage: ITER: 7509 RES: 0.2284
Jacobi stage: ITER: 7779 RES: 0.21911
Jacobi stage: ITER: 8079 RES: 0.20918
Jacobi stage: ITER: 8415 RES: 0.1986
Jacobi stage: ITER: 8751 RES: 0.18856
Jacobi stage: ITER: 9091 RES: 0.17894
Jacobi stage: ITER: 9431 RES: 0.16981
Jacobi stage: ITER: 9773 RES: 0.16105
Jacobi stage: ITER: 10063 RES: 0.15407
Jacobi stage: ITER: 10375 RES: 0.14685
Jacobi stage: ITER: 10709 RES: 0.13945
Jacobi stage: ITER: 11045 RES: 0.13243
Jacobi stage: ITER: 11385 RES: 0.12569
Jacobi stage: ITER: 11727 RES: 0.11929
Jacobi stage: ITER: 12067 RES: 0.11322
Jacobi stage: ITER: 12351 RES: 0.10838
Jacobi stage: ITER: 12651 RES: 0.1035
Jacobi stage: ITER: 12991 RES: 0.098232
Jacobi stage: ITER: 13331 RES: 0.093232
Jacobi stage: ITER: 13671 RES: 0.088488
Jacobi stage: ITER: 14011 RES: 0.083985
Jacobi stage: ITER: 14337 RES: 0.079858
Jacobi stage: ITER: 14651 RES: 0.076121
Jacobi stage: ITER: 14951 RES: 0.072692
Jacobi stage: ITER: 15281 RES: 0.069078
Jacobi stage: ITER: 15623 RES: 0.065563
Jacobi stage: ITER: 15961 RES: 0.062227
Jacobi stage: ITER: 16303 RES: 0.05906
Jacobi stage: ITER: 16631 RES: 0.056158
Jacobi stage: ITER: 16949 RES: 0.053465
Jacobi stage: ITER: 17287 RES: 0.050775
Jacobi stage: ITER: 17563 RES: 0.048668
Jacobi stage: ITER: 17883 RES: 0.046334
Jacobi stage: ITER: 18223 RES: 0.043976
Jacobi stage: ITER: 18563 RES: 0.041738
Jacobi stage: ITER: 18903 RES: 0.039614
Jacobi stage: ITER: 19245 RES: 0.037575
Jacobi stage: ITER: 19569 RES: 0.035751
Jacobi stage: ITER: 19907 RES: 0.033953
Jacobi stage: ITER: 20127 RES: 0.032825
Jacobi stage: ITER: 20459 RES: 0.031193
Jacobi stage: ITER: 20799 RES: 0.029606
Jacobi stage: ITER: 21139 RES: 0.028099
Jacobi stage: ITER: 21479 RES: 0.026669
Jacobi stage: ITER: 21773 RES: 0.025484
Jacobi stage: ITER: 22091 RES: 0.024276
Jacobi stage: ITER: 22427 RES: 0.023055
Jacobi stage: ITER: 22763 RES: 0.021896
Jacobi stage: ITER: 23099 RES: 0.020794
Jacobi stage: ITER: 23435 RES: 0.019748
Jacobi stage: ITER: 23771 RES: 0.018755
Jacobi stage: ITER: 24107 RES: 0.017812
Jacobi stage: ITER: 24443 RES: 0.016916
Jacobi stage: ITER: 24779 RES: 0.016065
Jacobi stage: ITER: 25115 RES: 0.015257
Jacobi stage: ITER: 25451 RES: 0.014489
Jacobi stage: ITER: 25789 RES: 0.013752
Jacobi stage: ITER: 26125 RES: 0.01306
Jacobi stage: ITER: 26463 RES: 0.012403
Jacobi stage: ITER: 26799 RES: 0.011779
Jacobi stage: ITER: 27135 RES: 0.011187
Jacobi stage: ITER: 27471 RES: 0.010624
Jacobi stage: ITER: 27807 RES: 0.01009
Jacobi stage: ITER: 28143 RES: 0.0095822
Jacobi stage: ITER: 28479 RES: 0.0091002
Jacobi stage: ITER: 28815 RES: 0.0086425
Jacobi stage: ITER: 29151 RES: 0.0082078
Jacobi stage: ITER: 29487 RES: 0.0077949
Jacobi stage: ITER: 29823 RES: 0.0074028
Jacobi stage: ITER: 30161 RES: 0.0070261
Jacobi stage: ITER: 30497 RES: 0.0066727
Jacobi stage: ITER: 30833 RES: 0.0063371
Jacobi stage: ITER: 31169 RES: 0.0060183
Jacobi stage: ITER: 31505 RES: 0.0057156
Jacobi stage: ITER: 31843 RES: 0.0054281
Jacobi stage: ITER: 32179 RES: 0.005155
Jacobi stage: ITER: 32515 RES: 0.0048957
Jacobi stage: ITER: 32851 RES: 0.0046495
Jacobi stage: ITER: 33187 RES: 0.0044156
Jacobi stage: ITER: 33523 RES: 0.0041935
Jacobi stage: ITER: 33859 RES: 0.0039826
Jacobi stage: ITER: 34197 RES: 0.0037799
Jacobi stage: ITER: 34533 RES: 0.0035898
Jacobi stage: ITER: 34869 RES: 0.0034092
Jacobi stage: ITER: 35205 RES: 0.0032377
Jacobi stage: ITER: 35543 RES: 0.0030749
Jacobi stage: ITER: 35879 RES: 0.0029202
Jacobi stage: ITER: 36215 RES: 0.0027733
Jacobi stage: ITER: 36551 RES: 0.0026338
Jacobi stage: ITER: 36887 RES: 0.0025013
Jacobi stage: ITER: 37223 RES: 0.0023755
Jacobi stage: ITER: 37559 RES: 0.002256
Jacobi stage: ITER: 37895 RES: 0.0021425
Jacobi stage: ITER: 38231 RES: 0.0020348
Jacobi stage: ITER: 38567 RES: 0.0019324
Jacobi stage: ITER: 38903 RES: 0.0018352
Jacobi stage: ITER: 39241 RES: 0.0017418
Jacobi stage: ITER: 39577 RES: 0.0016542
Jacobi stage: ITER: 39913 RES: 0.001571
Jacobi stage: ITER: 40249 RES: 0.001492
Jacobi stage: ITER: 40585 RES: 0.0014169
Jacobi stage: ITER: 40921 RES: 0.0013457
Jacobi stage: ITER: 41259 RES: 0.001278
Jacobi stage: ITER: 41595 RES: 0.0012137
Jacobi stage: ITER: 41931 RES: 0.0011526
Jacobi stage: ITER: 42267 RES: 0.0010947
Jacobi stage: ITER: 42603 RES: 0.0010396
Jacobi stage: ITER: 42939 RES: 0.0009873
Jacobi stage: ITER: 43275 RES: 0.00093764
Jacobi stage: ITER: 43611 RES: 0.00089048
Jacobi stage: ITER: 43947 RES: 0.00084568
Jacobi stage: ITER: 44285 RES: 0.00080265
Jacobi stage: ITER: 44621 RES: 0.00076228
Jacobi stage: ITER: 44957 RES: 0.00072393
Jacobi stage: ITER: 45293 RES: 0.00068752
Jacobi stage: ITER: 45629 RES: 0.00065294
Jacobi stage: ITER: 45965 RES: 0.00062009
Jacobi stage: ITER: 46301 RES: 0.0005889
Jacobi stage: ITER: 46639 RES: 0.00055928
Jacobi stage: ITER: 46975 RES: 0.00053115
Jacobi stage: ITER: 47311 RES: 0.00050443
Jacobi stage: ITER: 47647 RES: 0.00047906
Jacobi stage: ITER: 47983 RES: 0.00045496
Jacobi stage: ITER: 48319 RES: 0.00043208
Jacobi stage: ITER: 48655 RES: 0.00041034
Jacobi stage: ITER: 48991 RES: 0.0003897
Jacobi stage: ITER: 49327 RES: 0.0003701
Jacobi stage: ITER: 49663 RES: 0.00035148
Jacobi stage: ITER: 49999 RES: 0.0003338
Jacobi stage: ITER: 50335 RES: 0.00031701
Jacobi stage: ITER: 50671 RES: 0.00030107
Jacobi stage: ITER: 51007 RES: 0.00028592
Jacobi stage: ITER: 51343 RES: 0.00027154
Jacobi stage: ITER: 51679 RES: 0.00025788
Jacobi stage: ITER: 52015 RES: 0.00024491
Jacobi stage: ITER: 52351 RES: 0.00023259
Jacobi stage: ITER: 52687 RES: 0.00022089
Jacobi stage: ITER: 53025 RES: 0.00020965
Jacobi stage: ITER: 53361 RES: 0.00019911
Jacobi stage: ITER: 53697 RES: 0.00018909
Jacobi stage: ITER: 54033 RES: 0.00017958
Jacobi stage: ITER: 54369 RES: 0.00017055
Jacobi stage: ITER: 54705 RES: 0.00016197
Jacobi stage: ITER: 55043 RES: 0.00015382
Jacobi stage: ITER: 55379 RES: 0.00014608
Jacobi stage: ITER: 55715 RES: 0.00013873
Jacobi stage: ITER: 56051 RES: 0.00013176
Jacobi stage: ITER: 56387 RES: 0.00012513
Jacobi stage: ITER: 56723 RES: 0.00011883
Jacobi stage: ITER: 57059 RES: 0.00011286
Jacobi stage: ITER: 57395 RES: 0.00010718
Jacobi stage: ITER: 57731 RES: 0.00010179
Jacobi stage: ITER: 58067 RES: 9.6669e-05
Jacobi stage: ITER: 58405 RES: 9.175e-05
Jacobi stage: ITER: 58741 RES: 8.7135e-05
Jacobi stage: ITER: 59077 RES: 8.2752e-05
Jacobi stage: ITER: 59413 RES: 7.8589e-05
Jacobi stage: ITER: 59749 RES: 7.4636e-05
Jacobi stage: ITER: 60085 RES: 7.0882e-05
Jacobi stage: ITER: 60423 RES: 6.7317e-05
Jacobi stage: ITER: 60759 RES: 6.393e-05
Jacobi stage: ITER: 61095 RES: 6.0715e-05
Jacobi stage: ITER: 61431 RES: 5.7661e-05
Jacobi stage: ITER: 61767 RES: 5.476e-05
Jacobi stage: ITER: 62103 RES: 5.2006e-05
Jacobi stage: ITER: 62439 RES: 4.939e-05
Jacobi stage: ITER: 62775 RES: 4.6905e-05
Jacobi stage: ITER: 63111 RES: 4.4546e-05
Jacobi stage: ITER: 63447 RES: 4.2305e-05
Jacobi stage: ITER: 63783 RES: 4.0177e-05
Jacobi stage: ITER: 64119 RES: 3.8156e-05
Jacobi stage: ITER: 64455 RES: 3.6237e-05
Jacobi stage: ITER: 64793 RES: 3.4393e-05
Jacobi stage: ITER: 65129 RES: 3.2663e-05
Jacobi stage: ITER: 65465 RES: 3.102e-05
Jacobi stage: ITER: 65801 RES: 2.946e-05
Jacobi stage: ITER: 66139 RES: 2.7978e-05
Jacobi stage: ITER: 66475 RES: 2.6571e-05
Jacobi stage: ITER: 66811 RES: 2.5234e-05
Jacobi stage: ITER: 67147 RES: 2.3965e-05
Jacobi stage: ITER: 67483 RES: 2.2759e-05
Jacobi stage: ITER: 67819 RES: 2.1615e-05
Jacobi stage: ITER: 68155 RES: 2.0527e-05
Jacobi stage: ITER: 68491 RES: 1.9495e-05
Jacobi stage: ITER: 68827 RES: 1.8514e-05
Jacobi stage: ITER: 69163 RES: 1.7583e-05
Jacobi stage: ITER: 69499 RES: 1.6698e-05
Jacobi stage: ITER: 69835 RES: 1.5859e-05
Jacobi stage: ITER: 70173 RES: 1.5052e-05
Jacobi stage: ITER: 70509 RES: 1.4294e-05
Jacobi stage: ITER: 70845 RES: 1.3575e-05
Jacobi stage: ITER: 71181 RES: 1.2893e-05
Jacobi stage: ITER: 71517 RES: 1.2244e-05
Jacobi stage: ITER: 71855 RES: 1.1628e-05
Jacobi stage: ITER: 72191 RES: 1.1043e-05
Jacobi stage: ITER: 72527 RES: 1.0488e-05
Jacobi stage: ITER: 72863 RES: 9.9602e-06
Jacobi stage: ITER: 73199 RES: 9.4592e-06
Jacobi stage: ITER: 73535 RES: 8.9834e-06
Jacobi stage: ITER: 73871 RES: 8.5315e-06
Jacobi stage: ITER: 74207 RES: 8.1024e-06
Jacobi stage: ITER: 74543 RES: 7.6948e-06
Jacobi stage: ITER: 74879 RES: 7.3078e-06
Jacobi stage: ITER: 75215 RES: 6.9402e-06
Jacobi stage: ITER: 75553 RES: 6.5871e-06
Jacobi stage: ITER: 75889 RES: 6.2557e-06
Jacobi stage: ITER: 76225 RES: 5.941e-06
Jacobi stage: ITER: 76563 RES: 5.6422e-06
Jacobi stage: ITER: 76899 RES: 5.3584e-06
Jacobi stage: ITER: 77235 RES: 5.0889e-06
Jacobi stage: ITER: 77571 RES: 4.8329e-06
Jacobi stage: ITER: 77907 RES: 4.5898e-06
Jacobi stage: ITER: 78243 RES: 4.3589e-06
Jacobi stage: ITER: 78579 RES: 4.1397e-06
Jacobi stage: ITER: 78917 RES: 3.929e-06
Jacobi stage: ITER: 79253 RES: 3.7314e-06
Jacobi stage: ITER: 79589 RES: 3.5437e-06
Jacobi stage: ITER: 79925 RES: 3.3654e-06
Jacobi stage: ITER: 80263 RES: 3.1962e-06
Jacobi stage: ITER: 80599 RES: 3.0354e-06
Jacobi stage: ITER: 80935 RES: 2.8827e-06
Jacobi stage: ITER: 81271 RES: 2.7377e-06
Jacobi stage: ITER: 81607 RES: 2.6e-06
Jacobi stage: ITER: 81943 RES: 2.4692e-06
Jacobi stage: ITER: 82279 RES: 2.345e-06
Jacobi stage: ITER: 82615 RES: 2.2271e-06
Jacobi stage: ITER: 82953 RES: 2.1137e-06
Jacobi stage: ITER: 83289 RES: 2.0074e-06
Jacobi stage: ITER: 83625 RES: 1.9064e-06
Jacobi stage: ITER: 83961 RES: 1.8105e-06
Jacobi stage: ITER: 84299 RES: 1.7195e-06
Jacobi stage: ITER: 84635 RES: 1.633e-06
Jacobi stage: ITER: 84971 RES: 1.5508e-06
Jacobi stage: ITER: 85307 RES: 1.4728e-06
Jacobi stage: ITER: 85643 RES: 1.3987e-06
Jacobi stage: ITER: 85979 RES: 1.3284e-06
Jacobi stage: ITER: 86315 RES: 1.2616e-06
Jacobi stage: ITER: 86651 RES: 1.1981e-06
Jacobi stage: ITER: 86989 RES: 1.1371e-06
Jacobi stage: ITER: 87325 RES: 1.0799e-06
Jacobi stage: ITER: 87661 RES: 1.0256e-06
Vector x = [ 0.999999, 0.999999, 0.999998, 0.999999, 0.999999 ]

The following example shows how to employ timer (TNL::Timer) to the monitor of iterative solvers:

1#include <iostream>
2#include <memory>
3#include <chrono>
4#include <thread>
5#include <TNL/Timer.h>
6#include <TNL/Matrices/SparseMatrix.h>
7#include <TNL/Devices/Sequential.h>
8#include <TNL/Devices/Cuda.h>
9#include <TNL/Solvers/Linear/Jacobi.h>
10
11template< typename Device >
12void
13iterativeLinearSolverExample()
14{
15 /***
16 * Set the following matrix (dots represent zero matrix elements):
17 *
18 * / 2.5 -1 . . . \
19 * | -1 2.5 -1 . . |
20 * | . -1 2.5 -1. . |
21 * | . . -1 2.5 -1 |
22 * \ . . . -1 2.5 /
23 */
26 const int size( 5 );
27 auto matrix_ptr = std::make_shared< MatrixType >();
28 matrix_ptr->setDimensions( size, size );
29 matrix_ptr->setRowCapacities( Vector( { 2, 3, 3, 3, 2 } ) );
30
31 auto f = [ = ] __cuda_callable__( typename MatrixType::RowView & row ) mutable
32 {
33 const int rowIdx = row.getRowIndex();
34 if( rowIdx == 0 ) {
35 row.setElement( 0, rowIdx, 2.5 ); // diagonal element
36 row.setElement( 1, rowIdx + 1, -1 ); // element above the diagonal
37 }
38 else if( rowIdx == size - 1 ) {
39 row.setElement( 0, rowIdx - 1, -1.0 ); // element below the diagonal
40 row.setElement( 1, rowIdx, 2.5 ); // diagonal element
41 }
42 else {
43 row.setElement( 0, rowIdx - 1, -1.0 ); // element below the diagonal
44 row.setElement( 1, rowIdx, 2.5 ); // diagonal element
45 row.setElement( 2, rowIdx + 1, -1.0 ); // element above the diagonal
46 }
47 };
48
49 /***
50 * Set the matrix elements.
51 */
52 matrix_ptr->forAllRows( f );
53 std::cout << *matrix_ptr << std::endl;
54
55 /***
56 * Set the right-hand side vector.
57 */
58 Vector x( size, 1.0 );
59 Vector b( size );
60 matrix_ptr->vectorProduct( x, b );
61 x = 0.0;
62 std::cout << "Vector b = " << b << std::endl;
63
64 /***
65 * Setup solver of the linear system.
66 */
68 LinearSolver solver;
69 solver.setMatrix( matrix_ptr );
70 solver.setOmega( 0.0005 );
71
72 /***
73 * Setup monitor of the iterative solver.
74 */
75 using IterativeSolverMonitorType = TNL::Solvers::IterativeSolverMonitor< double, int >;
76 IterativeSolverMonitorType monitor;
77 TNL::Solvers::SolverMonitorThread mmonitorThread( monitor );
78 monitor.setRefreshRate( 10 ); // refresh rate in milliseconds
79 monitor.setVerbose( 1 );
80 monitor.setStage( "Jacobi stage:" );
81 TNL::Timer timer;
82 monitor.setTimer( timer );
83 timer.start();
84 solver.setSolverMonitor( monitor );
85 solver.setConvergenceResidue( 1.0e-6 );
86 solver.solve( b, x );
87 monitor.stopMainLoop();
88 std::cout << "Vector x = " << x << std::endl;
89}
90
91int
92main( int argc, char* argv[] )
93{
94 std::cout << "Solving linear system on host: " << std::endl;
95 iterativeLinearSolverExample< TNL::Devices::Sequential >();
96
97#ifdef __CUDACC__
98 std::cout << "Solving linear system on CUDA device: " << std::endl;
99 iterativeLinearSolverExample< TNL::Devices::Cuda >();
100#endif
101}
Class for real time, CPU time and CPU cycles measuring.
Definition Timer.h:25
void start()
Starts timer.
Definition Timer.hpp:42

The result looks as follows:

Solving linear system on host:
Row: 0 -> 0:2.5 1:-1
Row: 1 -> 0:-1 1:2.5 2:-1
Row: 2 -> 1:-1 2:2.5 3:-1
Row: 3 -> 2:-1 3:2.5 4:-1
Row: 4 -> 3:-1 4:2.5
Vector b = [ 1.5, 0.5, 0.5, 0.5, 1.5 ]
ELA:3.4642e-
ELA: 0.10014 Jacobi stage: ITER: 34949 RES: 0.0033676
ELA: 0.20023 Jacobi stage: ITER: 69855 RES: 1.581e-05
Vector x = [ 0.999999, 0.999999, 0.999998, 0.999999, 0.999999 ]
Solving linear system on CUDA device:
Row: 0 -> 0:2.5 1:-1
Row: 1 -> 0:-1 1:2.5 2:-1
Row: 2 -> 1:-1 2:2.5 3:-1
Row: 3 -> 2:-1 3:2.5 4:-1
Row: 4 -> 3:-1 4:2.5
Vector b = [ 1.5, 0.5, 0.5, 0.5, 1.5 ]
ELA:9.799e-0
ELA: 0.10009 Jacobi stage: ITER: 499 RES: 0.85129
ELA: 0.20018 Jacobi stage: ITER: 857 RES: 0.76724
ELA: 0.30028 Jacobi stage: ITER: 1189 RES: 0.70279
ELA: 0.40037 Jacobi stage: ITER: 1521 RES: 0.64802
ELA: 0.50046 Jacobi stage: ITER: 1853 RES: 0.60087
ELA: 0.60054 Jacobi stage: ITER: 2187 RES: 0.55973
ELA: 0.70063 Jacobi stage: ITER: 2519 RES: 0.52341
ELA: 0.80067 Jacobi stage: ITER: 2851 RES: 0.49098
ELA: 0.90076 Jacobi stage: ITER: 3183 RES: 0.46174
ELA: 1.0009 Jacobi stage: ITER: 3515 RES: 0.43514
ELA: 1.1009 Jacobi stage: ITER: 3851 RES: 0.41048
ELA: 1.2011 Jacobi stage: ITER: 4173 RES: 0.38852
ELA: 1.3012 Jacobi stage: ITER: 4513 RES: 0.36715
ELA: 1.4013 Jacobi stage: ITER: 4845 RES: 0.34772
ELA: 1.5014 Jacobi stage: ITER: 5157 RES: 0.3306
ELA: 1.6015 Jacobi stage: ITER: 5497 RES: 0.31308
ELA: 1.7016 Jacobi stage: ITER: 5835 RES: 0.29682
ELA: 1.8017 Jacobi stage: ITER: 6177 RES: 0.28114
ELA: 1.9019 Jacobi stage: ITER: 6519 RES: 0.26655
ELA: 2.002 Jacobi stage: ITER: 6779 RES: 0.25594
ELA: 2.1021 Jacobi stage: ITER: 7083 RES: 0.2441
ELA: 2.2022 Jacobi stage: ITER: 7415 RES: 0.23183
ELA: 2.3023 Jacobi stage: ITER: 7755 RES: 0.21993
ELA: 2.4024 Jacobi stage: ITER: 8095 RES: 0.20866
ELA: 2.5026 Jacobi stage: ITER: 8435 RES: 0.19799
ELA: 2.6027 Jacobi stage: ITER: 8769 RES: 0.18798
ELA: 2.7028 Jacobi stage: ITER: 9059 RES: 0.17982
ELA: 2.8029 Jacobi stage: ITER: 9373 RES: 0.17128
ELA: 2.903 Jacobi stage: ITER: 9707 RES: 0.16274
ELA: 3.0031 Jacobi stage: ITER: 10041 RES: 0.15454
ELA: 3.1032 Jacobi stage: ITER: 10379 RES: 0.14676
ELA: 3.2033 Jacobi stage: ITER: 10723 RES: 0.1392
ELA: 3.3034 Jacobi stage: ITER: 11051 RES: 0.13235
ELA: 3.4035 Jacobi stage: ITER: 11321 RES: 0.12693
ELA: 3.5036 Jacobi stage: ITER: 11639 RES: 0.12091
ELA: 3.6037 Jacobi stage: ITER: 11979 RES: 0.11476
ELA: 3.7038 Jacobi stage: ITER: 12319 RES: 0.10892
ELA: 3.8039 Jacobi stage: ITER: 12659 RES: 0.10337
ELA: 3.904 Jacobi stage: ITER: 12999 RES: 0.098111
ELA: 4.0041 Jacobi stage: ITER: 13323 RES: 0.093347
ELA: 4.1042 Jacobi stage: ITER: 13603 RES: 0.089417
ELA: 4.2043 Jacobi stage: ITER: 13933 RES: 0.084971
ELA: 4.3044 Jacobi stage: ITER: 14259 RES: 0.080845
ELA: 4.4045 Jacobi stage: ITER: 14599 RES: 0.076731
ELA: 4.5046 Jacobi stage: ITER: 14939 RES: 0.072826
ELA: 4.6047 Jacobi stage: ITER: 15269 RES: 0.069206
ELA: 4.7048 Jacobi stage: ITER: 15607 RES: 0.065724
ELA: 4.8049 Jacobi stage: ITER: 15925 RES: 0.062572
ELA: 4.905 Jacobi stage: ITER: 16253 RES: 0.059497
ELA: 5.0051 Jacobi stage: ITER: 16537 RES: 0.056958
ELA: 5.1052 Jacobi stage: ITER: 16855 RES: 0.054259
ELA: 5.2053 Jacobi stage: ITER: 17191 RES: 0.05153
ELA: 5.3054 Jacobi stage: ITER: 17529 RES: 0.048908
ELA: 5.4054 Jacobi stage: ITER: 17867 RES: 0.046448
ELA: 5.5055 Jacobi stage: ITER: 18211 RES: 0.044057
ELA: 5.6057 Jacobi stage: ITER: 18533 RES: 0.041918
ELA: 5.7058 Jacobi stage: ITER: 18871 RES: 0.03981
ELA: 5.8059 Jacobi stage: ITER: 19091 RES: 0.038487
ELA: 5.906 Jacobi stage: ITER: 19421 RES: 0.036573
ELA: 6.0061 Jacobi stage: ITER: 19757 RES: 0.034734
ELA: 6.1062 Jacobi stage: ITER: 20097 RES: 0.032966
ELA: 6.2063 Jacobi stage: ITER: 20439 RES: 0.031289
ELA: 6.3064 Jacobi stage: ITER: 20721 RES: 0.029953
ELA: 6.4065 Jacobi stage: ITER: 21039 RES: 0.028534
ELA: 6.5066 Jacobi stage: ITER: 21375 RES: 0.027099
ELA: 6.6066 Jacobi stage: ITER: 21711 RES: 0.025736
ELA: 6.7067 Jacobi stage: ITER: 22049 RES: 0.024426
ELA: 6.8068 Jacobi stage: ITER: 22385 RES: 0.023197
ELA: 6.9069 Jacobi stage: ITER: 22721 RES: 0.022031
ELA: 7.007 Jacobi stage: ITER: 23057 RES: 0.020922
ELA: 7.1071 Jacobi stage: ITER: 23393 RES: 0.01987
ELA: 7.2072 Jacobi stage: ITER: 23729 RES: 0.018871
ELA: 7.3073 Jacobi stage: ITER: 24065 RES: 0.017921
ELA: 7.4074 Jacobi stage: ITER: 24401 RES: 0.01702
ELA: 7.5075 Jacobi stage: ITER: 24737 RES: 0.016164
ELA: 7.6077 Jacobi stage: ITER: 25073 RES: 0.015351
ELA: 7.7078 Jacobi stage: ITER: 25411 RES: 0.014579
ELA: 7.8097 Jacobi stage: ITER: 25751 RES: 0.013837
ELA: 7.9098 Jacobi stage: ITER: 26087 RES: 0.013141
ELA: 8.0099 Jacobi stage: ITER: 26425 RES: 0.012472
ELA: 8.1107 Jacobi stage: ITER: 26763 RES: 0.011845
ELA: 8.2108 Jacobi stage: ITER: 27099 RES: 0.011249
ELA: 8.3109 Jacobi stage: ITER: 27435 RES: 0.010683
ELA: 8.4117 Jacobi stage: ITER: 27775 RES: 0.010139
ELA: 8.5118 Jacobi stage: ITER: 28111 RES: 0.0096295
ELA: 8.6119 Jacobi stage: ITER: 28447 RES: 0.0091451
ELA: 8.712 Jacobi stage: ITER: 28783 RES: 0.0086851
ELA: 8.8137 Jacobi stage: ITER: 29125 RES: 0.0082381
ELA: 8.9138 Jacobi stage: ITER: 29461 RES: 0.0078237
ELA: 9.0139 Jacobi stage: ITER: 29797 RES: 0.0074302
ELA: 9.1147 Jacobi stage: ITER: 30135 RES: 0.0070564
ELA: 9.2148 Jacobi stage: ITER: 30471 RES: 0.0067015
ELA: 9.3149 Jacobi stage: ITER: 30809 RES: 0.0063605
ELA: 9.415 Jacobi stage: ITER: 31145 RES: 0.0060405
ELA: 9.5151 Jacobi stage: ITER: 31481 RES: 0.0057367
ELA: 9.6152 Jacobi stage: ITER: 31817 RES: 0.0054481
ELA: 9.7153 Jacobi stage: ITER: 32153 RES: 0.0051741
ELA: 9.8154 Jacobi stage: ITER: 32491 RES: 0.0049138
ELA: 9.9155 Jacobi stage: ITER: 32827 RES: 0.0046666
ELA: 10.016 Jacobi stage: ITER: 33163 RES: 0.0044319
ELA: 10.116 Jacobi stage: ITER: 33499 RES: 0.004209
ELA: 10.216 Jacobi stage: ITER: 33835 RES: 0.0039973
ELA: 10.316 Jacobi stage: ITER: 34171 RES: 0.0037962
ELA: 10.416 Jacobi stage: ITER: 34507 RES: 0.0036052
ELA: 10.516 Jacobi stage: ITER: 34845 RES: 0.0034218
ELA: 10.616 Jacobi stage: ITER: 35181 RES: 0.0032497
ELA: 10.716 Jacobi stage: ITER: 35517 RES: 0.0030862
ELA: 10.816 Jacobi stage: ITER: 35853 RES: 0.002931
ELA: 10.916 Jacobi stage: ITER: 36189 RES: 0.0027835
ELA: 11.017 Jacobi stage: ITER: 36525 RES: 0.0026435
ELA: 11.117 Jacobi stage: ITER: 36863 RES: 0.0025106
ELA: 11.217 Jacobi stage: ITER: 37199 RES: 0.0023843
ELA: 11.317 Jacobi stage: ITER: 37535 RES: 0.0022643
ELA: 11.417 Jacobi stage: ITER: 37871 RES: 0.0021504
ELA: 11.517 Jacobi stage: ITER: 38207 RES: 0.0020423
ELA: 11.617 Jacobi stage: ITER: 38543 RES: 0.0019395
ELA: 11.717 Jacobi stage: ITER: 38879 RES: 0.001842
ELA: 11.817 Jacobi stage: ITER: 39215 RES: 0.0017493
ELA: 11.918 Jacobi stage: ITER: 39551 RES: 0.0016613
ELA: 12.018 Jacobi stage: ITER: 39887 RES: 0.0015778
ELA: 12.118 Jacobi stage: ITER: 40223 RES: 0.0014984
ELA: 12.218 Jacobi stage: ITER: 40561 RES: 0.0014222
ELA: 12.318 Jacobi stage: ITER: 40897 RES: 0.0013506
ELA: 12.418 Jacobi stage: ITER: 41233 RES: 0.0012827
ELA: 12.518 Jacobi stage: ITER: 41569 RES: 0.0012182
ELA: 12.618 Jacobi stage: ITER: 41905 RES: 0.0011569
ELA: 12.719 Jacobi stage: ITER: 42243 RES: 0.0010987
ELA: 12.819 Jacobi stage: ITER: 42579 RES: 0.0010434
ELA: 12.919 Jacobi stage: ITER: 42915 RES: 0.00099095
ELA: 13.019 Jacobi stage: ITER: 43251 RES: 0.0009411
ELA: 13.119 Jacobi stage: ITER: 43587 RES: 0.00089377
ELA: 13.219 Jacobi stage: ITER: 43923 RES: 0.00084881
ELA: 13.319 Jacobi stage: ITER: 44259 RES: 0.00080611
ELA: 13.419 Jacobi stage: ITER: 44595 RES: 0.00076556
ELA: 13.519 Jacobi stage: ITER: 44931 RES: 0.00072706
ELA: 13.62 Jacobi stage: ITER: 45269 RES: 0.00069006
ELA: 13.72 Jacobi stage: ITER: 45605 RES: 0.00065535
ELA: 13.82 Jacobi stage: ITER: 45941 RES: 0.00062238
ELA: 13.92 Jacobi stage: ITER: 46277 RES: 0.00059108
ELA: 14.02 Jacobi stage: ITER: 46613 RES: 0.00056135
ELA: 14.12 Jacobi stage: ITER: 46949 RES: 0.00053311
ELA: 14.22 Jacobi stage: ITER: 47287 RES: 0.00050629
ELA: 14.32 Jacobi stage: ITER: 47623 RES: 0.00048083
ELA: 14.42 Jacobi stage: ITER: 47959 RES: 0.00045664
ELA: 14.521 Jacobi stage: ITER: 48295 RES: 0.00043367
ELA: 14.621 Jacobi stage: ITER: 48631 RES: 0.00041186
ELA: 14.721 Jacobi stage: ITER: 48967 RES: 0.00039114
ELA: 14.821 Jacobi stage: ITER: 49303 RES: 0.00037147
ELA: 14.921 Jacobi stage: ITER: 49639 RES: 0.00035278
ELA: 15.021 Jacobi stage: ITER: 49975 RES: 0.00033504
ELA: 15.121 Jacobi stage: ITER: 50311 RES: 0.00031818
ELA: 15.221 Jacobi stage: ITER: 50647 RES: 0.00030218
ELA: 15.321 Jacobi stage: ITER: 50983 RES: 0.00028698
ELA: 15.421 Jacobi stage: ITER: 51319 RES: 0.00027254
ELA: 15.522 Jacobi stage: ITER: 51655 RES: 0.00025883
ELA: 15.622 Jacobi stage: ITER: 51991 RES: 0.00024581
ELA: 15.722 Jacobi stage: ITER: 52329 RES: 0.00023331
ELA: 15.822 Jacobi stage: ITER: 52665 RES: 0.00022157
ELA: 15.922 Jacobi stage: ITER: 53001 RES: 0.00021043
ELA: 16.022 Jacobi stage: ITER: 53337 RES: 0.00019984
ELA: 16.122 Jacobi stage: ITER: 53673 RES: 0.00018979
ELA: 16.222 Jacobi stage: ITER: 54011 RES: 0.00018024
ELA: 16.322 Jacobi stage: ITER: 54347 RES: 0.00017118
ELA: 16.423 Jacobi stage: ITER: 54683 RES: 0.00016257
ELA: 16.523 Jacobi stage: ITER: 55019 RES: 0.00015439
ELA: 16.623 Jacobi stage: ITER: 55355 RES: 0.00014662
ELA: 16.723 Jacobi stage: ITER: 55691 RES: 0.00013925
ELA: 16.823 Jacobi stage: ITER: 56027 RES: 0.00013224
ELA: 16.923 Jacobi stage: ITER: 56363 RES: 0.00012559
ELA: 17.023 Jacobi stage: ITER: 56699 RES: 0.00011927
ELA: 17.123 Jacobi stage: ITER: 57035 RES: 0.00011327
ELA: 17.223 Jacobi stage: ITER: 57371 RES: 0.00010758
ELA: 17.324 Jacobi stage: ITER: 57707 RES: 0.00010216
ELA: 17.424 Jacobi stage: ITER: 58045 RES: 9.6966e-05
ELA: 17.524 Jacobi stage: ITER: 58381 RES: 9.2089e-05
ELA: 17.624 Jacobi stage: ITER: 58717 RES: 8.7457e-05
ELA: 17.724 Jacobi stage: ITER: 59053 RES: 8.3057e-05
ELA: 17.824 Jacobi stage: ITER: 59389 RES: 7.888e-05
ELA: 17.924 Jacobi stage: ITER: 59725 RES: 7.4912e-05
ELA: 18.024 Jacobi stage: ITER: 60063 RES: 7.1144e-05
ELA: 18.124 Jacobi stage: ITER: 60399 RES: 6.7565e-05
ELA: 18.225 Jacobi stage: ITER: 60735 RES: 6.4167e-05
ELA: 18.325 Jacobi stage: ITER: 61071 RES: 6.0939e-05
ELA: 18.425 Jacobi stage: ITER: 61407 RES: 5.7874e-05
ELA: 18.525 Jacobi stage: ITER: 61743 RES: 5.4963e-05
ELA: 18.625 Jacobi stage: ITER: 62079 RES: 5.2198e-05
ELA: 18.725 Jacobi stage: ITER: 62415 RES: 4.9572e-05
ELA: 18.825 Jacobi stage: ITER: 62751 RES: 4.7079e-05
ELA: 18.925 Jacobi stage: ITER: 63087 RES: 4.4711e-05
ELA: 19.025 Jacobi stage: ITER: 63423 RES: 4.2462e-05
ELA: 19.126 Jacobi stage: ITER: 63759 RES: 4.0326e-05
ELA: 19.226 Jacobi stage: ITER: 64097 RES: 3.8274e-05
ELA: 19.326 Jacobi stage: ITER: 64433 RES: 3.6349e-05
ELA: 19.426 Jacobi stage: ITER: 64769 RES: 3.452e-05
ELA: 19.526 Jacobi stage: ITER: 65107 RES: 3.2784e-05
ELA: 19.626 Jacobi stage: ITER: 65443 RES: 3.1135e-05
ELA: 19.726 Jacobi stage: ITER: 65779 RES: 2.9569e-05
ELA: 19.826 Jacobi stage: ITER: 66115 RES: 2.8081e-05
ELA: 19.927 Jacobi stage: ITER: 66451 RES: 2.6669e-05
ELA: 20.027 Jacobi stage: ITER: 66787 RES: 2.5327e-05
ELA: 20.127 Jacobi stage: ITER: 67123 RES: 2.4053e-05
ELA: 20.227 Jacobi stage: ITER: 67459 RES: 2.2843e-05
ELA: 20.327 Jacobi stage: ITER: 67795 RES: 2.1694e-05
ELA: 20.427 Jacobi stage: ITER: 68131 RES: 2.0603e-05
ELA: 20.527 Jacobi stage: ITER: 68467 RES: 1.9567e-05
ELA: 20.627 Jacobi stage: ITER: 68803 RES: 1.8583e-05
ELA: 20.727 Jacobi stage: ITER: 69141 RES: 1.7637e-05
ELA: 20.827 Jacobi stage: ITER: 69477 RES: 1.675e-05
ELA: 20.928 Jacobi stage: ITER: 69813 RES: 1.5907e-05
ELA: 21.028 Jacobi stage: ITER: 70149 RES: 1.5107e-05
ELA: 21.128 Jacobi stage: ITER: 70485 RES: 1.4347e-05
ELA: 21.228 Jacobi stage: ITER: 70823 RES: 1.3626e-05
ELA: 21.328 Jacobi stage: ITER: 71159 RES: 1.294e-05
ELA: 21.428 Jacobi stage: ITER: 71495 RES: 1.2289e-05
ELA: 21.528 Jacobi stage: ITER: 71831 RES: 1.1671e-05
ELA: 21.628 Jacobi stage: ITER: 72167 RES: 1.1084e-05
ELA: 21.728 Jacobi stage: ITER: 72503 RES: 1.0527e-05
ELA: 21.829 Jacobi stage: ITER: 72839 RES: 9.997e-06
ELA: 21.929 Jacobi stage: ITER: 73175 RES: 9.4942e-06
ELA: 22.029 Jacobi stage: ITER: 73511 RES: 9.0166e-06
ELA: 22.129 Jacobi stage: ITER: 73847 RES: 8.5631e-06
ELA: 22.229 Jacobi stage: ITER: 74183 RES: 8.1323e-06
ELA: 22.329 Jacobi stage: ITER: 74521 RES: 7.7185e-06
ELA: 22.429 Jacobi stage: ITER: 74857 RES: 7.3303e-06
ELA: 22.529 Jacobi stage: ITER: 75195 RES: 6.9616e-06
ELA: 22.629 Jacobi stage: ITER: 75531 RES: 6.6114e-06
ELA: 22.729 Jacobi stage: ITER: 75867 RES: 6.2788e-06
ELA: 22.83 Jacobi stage: ITER: 76203 RES: 5.963e-06
ELA: 22.93 Jacobi stage: ITER: 76539 RES: 5.663e-06
ELA: 23.03 Jacobi stage: ITER: 76875 RES: 5.3782e-06
ELA: 23.13 Jacobi stage: ITER: 77211 RES: 5.1077e-06
ELA: 23.23 Jacobi stage: ITER: 77547 RES: 4.8507e-06
ELA: 23.33 Jacobi stage: ITER: 77885 RES: 4.6039e-06
ELA: 23.43 Jacobi stage: ITER: 78221 RES: 4.3723e-06
ELA: 23.53 Jacobi stage: ITER: 78557 RES: 4.1524e-06
ELA: 23.63 Jacobi stage: ITER: 78893 RES: 3.9435e-06
ELA: 23.731 Jacobi stage: ITER: 79231 RES: 3.7452e-06
ELA: 23.831 Jacobi stage: ITER: 79567 RES: 3.5568e-06
ELA: 23.931 Jacobi stage: ITER: 79903 RES: 3.3779e-06
ELA: 24.031 Jacobi stage: ITER: 80239 RES: 3.208e-06
ELA: 24.131 Jacobi stage: ITER: 80575 RES: 3.0466e-06
ELA: 24.231 Jacobi stage: ITER: 80911 RES: 2.8934e-06
ELA: 24.331 Jacobi stage: ITER: 81247 RES: 2.7478e-06
ELA: 24.431 Jacobi stage: ITER: 81583 RES: 2.6096e-06
ELA: 24.531 Jacobi stage: ITER: 81921 RES: 2.4768e-06
ELA: 24.632 Jacobi stage: ITER: 82257 RES: 2.3522e-06
ELA: 24.732 Jacobi stage: ITER: 82593 RES: 2.2339e-06
ELA: 24.832 Jacobi stage: ITER: 82931 RES: 2.1215e-06
ELA: 24.932 Jacobi stage: ITER: 83267 RES: 2.0148e-06
ELA: 25.032 Jacobi stage: ITER: 83603 RES: 1.9135e-06
ELA: 25.132 Jacobi stage: ITER: 83939 RES: 1.8172e-06
ELA: 25.232 Jacobi stage: ITER: 84275 RES: 1.7258e-06
ELA: 25.332 Jacobi stage: ITER: 84611 RES: 1.639e-06
ELA: 25.432 Jacobi stage: ITER: 84947 RES: 1.5566e-06
ELA: 25.533 Jacobi stage: ITER: 85283 RES: 1.4783e-06
ELA: 25.633 Jacobi stage: ITER: 85619 RES: 1.4039e-06
ELA: 25.733 Jacobi stage: ITER: 85957 RES: 1.3325e-06
ELA: 25.833 Jacobi stage: ITER: 86293 RES: 1.2654e-06
ELA: 25.933 Jacobi stage: ITER: 86629 RES: 1.2018e-06
ELA: 26.033 Jacobi stage: ITER: 87095 RES: 1.1191e-06
ELA: 26.133 Jacobi stage: ITER: 87603 RES: 1.0351e-06
Vector x = [ 0.999999, 0.999999, 0.999998, 0.999999, 0.999999 ]

Member Function Documentation

◆ refresh()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::refresh ( )
overridevirtual

Causes that the monitor prints out the status of the solver.

Implements TNL::Solvers::SolverMonitor.

◆ setIterations()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setIterations ( const IndexType & iterations)

Set number of the current iteration.

Parameters
iterationsis number of the current iteration.

◆ setNodesPerIteration()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setNodesPerIteration ( const IndexType & nodes)

Set the number of nodes of the numerical mesh or lattice.

This can be used to compute the number of nodes processed per one second.

Parameters
nodesis number of nodes of the numerical mesh or lattice.

◆ setResidue()

template<typename Real = double, typename Index = int>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setResidue ( const RealType & residue)

Set residue of the current approximation of the solution.

Parameters
residueis a residue of the current approximation of the solution.

◆ setStage()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setStage ( const std::string & stage)

This method can be used for naming a stage of the monitored solver.

The stage name can be used to differ between various stages of iterative solvers.

Parameters
stageis name of the solver stage.

◆ setTime()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setTime ( const RealType & time)

Set the time of the simulated evolution if it is time dependent.

This can be used for example when solving parabolic or hyperbolic PDEs.

Parameters
timetime of the simulated evolution.

◆ setTimeStep()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setTimeStep ( const RealType & timeStep)

Set the time step for time dependent iterative solvers.

Parameters
timeSteptime step of the time dependent iterative solver.

◆ setVerbose()

template<typename Real, typename Index>
void TNL::Solvers::IterativeSolverMonitor< Real, Index >::setVerbose ( const IndexType & verbose)

Set up the verbosity of the monitor.

Parameters
verboseis the new value of the verbosity of the monitor.

The documentation for this class was generated from the following files: