numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::linear::algebraic_multigrid_solver< Matrix > Class Template Reference

Class to solve linear equations using algebraic multigrid method [24]. More...

#include <num_collect/linear/algebraic_multigrid_solver.h>

+ Inheritance diagram for num_collect::linear::algebraic_multigrid_solver< Matrix >:
+ Collaboration diagram for num_collect::linear::algebraic_multigrid_solver< Matrix >:

Classes

struct  final_layer_data
 Struct of internal data for the final layer. More...
 
struct  first_layer_data
 Struct of internal data for the first layer. More...
 
struct  intermidiate_layer_data
 Struct of internal data for the intermidiate layers. More...
 

Public Types

using base_type = iterative_solver_base<algebraic_multigrid_solver<Matrix>>
 Type of the base class.
 
using this_type = algebraic_multigrid_solver<Matrix>
 Type of this class.
 
- Public Types inherited from num_collect::linear::iterative_solver_base< algebraic_multigrid_solver< Matrix > >
enum  
 
using matrix_type
 Type of matrices.
 
using MatrixType
 Type of matrices. (For Eigen library.)
 
using real_scalar_type
 Type of real scalars.
 
using RealScalar
 Type of real scalars. (For Eigen library.)
 
using Scalar
 Type of scalars. (For Eigen library.)
 
using scalar_type
 Type of scalars.
 
using storage_index_type
 Type of indices in storages.
 
using StorageIndex
 Type of indices in storages. (For Eigen library.)
 

Public Member Functions

 algebraic_multigrid_solver ()
 Constructor.
 
void compute (const matrix_type &coeff)
 Prepare to solve.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto maximum_directly_solved_matrix_size (index_type value) -> algebraic_multigrid_solver &
 Set the maximum size of matrices to solve directly.
 
auto residual_rate () const noexcept -> scalar_type
 Get the rate of the last residual.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void solve_vector_in_place (const Right &right, Solution &solution) const
 Iterate repeatedly until stop criterion is satisfied for a vector.
 
- Public Member Functions inherited from num_collect::linear::iterative_solver_base< algebraic_multigrid_solver< Matrix > >
 iterative_solver_base ()
 Constructor.
 
void _solve_impl (const Right &right, Solution &solution) const
 Internal function to solve for a right-hand-side vector.
 
void _solve_with_guess_impl (const Right &right, Solution &solution) const
 Internal function to solve for a right-hand-side vector.
 
auto cols () const noexcept -> Eigen::Index
 Get the number of columns.
 
auto compute (const matrix_type &coeff) -> algebraic_multigrid_solver< Matrix > &
 Initialize this solver using a coefficient matrix.
 
auto max_iterations () const noexcept -> index_type
 Get the maximum number of iterations.
 
auto max_iterations (index_type val) -> algebraic_multigrid_solver< Matrix > &
 Set the maximum number of iterations.
 
auto rows () const noexcept -> Eigen::Index
 Get the number of rows.
 
auto solve (const Right &right) const -> Eigen::Solve< algebraic_multigrid_solver< Matrix >, Right >
 Solve a linear equation.
 
auto solve_with_guess (const Right &right, const Solution &solution) const -> Eigen::SolveWithGuess< algebraic_multigrid_solver< Matrix >, Right, Solution >
 Solve a linear equation with a guess of the solution.
 
auto tolerance () const noexcept -> real_scalar_type
 Get the tolerance of rate of residual.
 
auto tolerance (const real_scalar_type &val) -> algebraic_multigrid_solver< Matrix > &
 Set the tolerance of rate of residual.
 
- Public Member Functions inherited from num_collect::logging::logging_mixin
 logging_mixin (log_tag_view tag)
 Constructor.
 
template<typename Child >
void configure_child_algorithm_logger_if_exists (Child &child)
 Configure a logger of a child algorithm if exists.
 
auto logger () const noexcept -> const num_collect::logging::logger &
 Access to the logger.
 
auto logger () noexcept -> num_collect::logging::logger &
 Access to the logger.
 

Private Types

using dense_matrix_type = Eigen::MatrixX<scalar_type>
 Type of the dense matrix used in this algorithm.
 
using dense_vector_type = Eigen::VectorX<scalar_type>
 Type of the dense vector used in this algorithm.
 

Private Member Functions

void compute_prolongation_matrix (matrix_type &prolongation_matrix, const matrix_type &coeff_matrix)
 Compute prolongation matrix from a coefficient matrix.
 
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void iterate (const Right &right, Solution &solution) const
 Iterate once.
 

Private Attributes

final_layer_data final_layer_ {}
 Data of the final layer.
 
first_layer_data first_layer_ {}
 Data of the first layer.
 
std::deque< intermidiate_layer_dataintermidiate_layers_ {}
 Data of the intermidiate layers.
 
index_type iterations_ {}
 Number of iterations.
 
index_type maximum_directly_solved_matrix_size_
 Maximum size of matrices to solve directly.
 
std::vector< dense_vector_typeresidual_buffers_ {}
 Buffers of residuals in layers except for the first layer.
 
std::vector< dense_vector_typesolution_buffers_ {}
 Buffers of solutions in layers except for the first layer.
 
real_scalar_type strong_coeff_rate_threshold_
 Threshold of the rate of coefficients to determine strong connections.
 

Static Private Attributes

static constexpr index_type default_maximum_directly_solved_matrix_size
 Default value of the maximum size of matrices to solve directly.
 
static constexpr auto default_strong_coeff_rate_threshold
 Default value of the threshold of the rate of coefficients to determine strong connections.
 

Additional Inherited Members

- Protected Types inherited from num_collect::linear::iterative_solver_base< algebraic_multigrid_solver< Matrix > >
using Base
 Base class.
 
- Protected Member Functions inherited from num_collect::linear::iterative_solver_base< algebraic_multigrid_solver< Matrix > >
auto coeff () const noexcept -> const matrix_type &
 Get the coefficient matrix.
 

Detailed Description

template<base::concepts::sparse_matrix Matrix>
class num_collect::linear::algebraic_multigrid_solver< Matrix >

Class to solve linear equations using algebraic multigrid method [24].

Template Parameters
MatrixType of the matrix.

Definition at line 77 of file algebraic_multigrid_solver.h.

Member Typedef Documentation

◆ base_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::algebraic_multigrid_solver< Matrix >::base_type = iterative_solver_base<algebraic_multigrid_solver<Matrix>>

Type of the base class.

Definition at line 88 of file algebraic_multigrid_solver.h.

◆ dense_matrix_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::algebraic_multigrid_solver< Matrix >::dense_matrix_type = Eigen::MatrixX<scalar_type>
private

Type of the dense matrix used in this algorithm.

Definition at line 311 of file algebraic_multigrid_solver.h.

◆ dense_vector_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::algebraic_multigrid_solver< Matrix >::dense_vector_type = Eigen::VectorX<scalar_type>
private

Type of the dense vector used in this algorithm.

Definition at line 314 of file algebraic_multigrid_solver.h.

◆ this_type

template<base::concepts::sparse_matrix Matrix>
using num_collect::linear::algebraic_multigrid_solver< Matrix >::this_type = algebraic_multigrid_solver<Matrix>

Type of this class.

Definition at line 85 of file algebraic_multigrid_solver.h.

Constructor & Destructor Documentation

◆ algebraic_multigrid_solver()

template<base::concepts::sparse_matrix Matrix>
num_collect::linear::algebraic_multigrid_solver< Matrix >::algebraic_multigrid_solver ( )
inline

Constructor.

Definition at line 102 of file algebraic_multigrid_solver.h.

Member Function Documentation

◆ compute()

template<base::concepts::sparse_matrix Matrix>
void num_collect::linear::algebraic_multigrid_solver< Matrix >::compute ( const matrix_type & coeff)
inline

Prepare to solve.

Parameters
[in]coeffCoefficient matrix.

Definition at line 110 of file algebraic_multigrid_solver.h.

◆ compute_prolongation_matrix()

template<base::concepts::sparse_matrix Matrix>
void num_collect::linear::algebraic_multigrid_solver< Matrix >::compute_prolongation_matrix ( matrix_type & prolongation_matrix,
const matrix_type & coeff_matrix )
inlineprivate

Compute prolongation matrix from a coefficient matrix.

Parameters
[out]prolongation_matrixProlongation matrix.
[in]coeff_matrixCoefficient matrix.

Definition at line 297 of file algebraic_multigrid_solver.h.

◆ iterate()

template<base::concepts::sparse_matrix Matrix>
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void num_collect::linear::algebraic_multigrid_solver< Matrix >::iterate ( const Right & right,
Solution & solution ) const
inlineprivate

Iterate once.

Template Parameters
RightType of the right-hand-side vector.
SolutionType of the solution vector.
Parameters
[in]rightRight-hand-side vector.
[in,out]solutionSolution vector.

Definition at line 253 of file algebraic_multigrid_solver.h.

◆ iterations()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::algebraic_multigrid_solver< Matrix >::iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of iterations.

Returns
Number of iterations.

Definition at line 227 of file algebraic_multigrid_solver.h.

◆ maximum_directly_solved_matrix_size()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::algebraic_multigrid_solver< Matrix >::maximum_directly_solved_matrix_size ( index_type value) -> algebraic_multigrid_solver&
inline

Set the maximum size of matrices to solve directly.

Parameters
[in]valueValue.
Returns
This.

Definition at line 213 of file algebraic_multigrid_solver.h.

◆ residual_rate()

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::algebraic_multigrid_solver< Matrix >::residual_rate ( ) const -> scalar_type
inlinenodiscardnoexcept

Get the rate of the last residual.

Note
This value is updated when a iteration is performed.
Returns
Rate of the last residual.

Definition at line 238 of file algebraic_multigrid_solver.h.

◆ solve_vector_in_place()

template<base::concepts::sparse_matrix Matrix>
template<base::concepts::dense_vector_of< scalar_type > Right, base::concepts::dense_vector_of< scalar_type > Solution>
void num_collect::linear::algebraic_multigrid_solver< Matrix >::solve_vector_in_place ( const Right & right,
Solution & solution ) const
inline

Iterate repeatedly until stop criterion is satisfied for a vector.

Template Parameters
RightType of the right-hand-side vector.
SolutionType of the solution vector.
Parameters
[in]rightRight-hand-side vector.
[in,out]solutionSolution vector.

Definition at line 177 of file algebraic_multigrid_solver.h.

Member Data Documentation

◆ default_maximum_directly_solved_matrix_size

template<base::concepts::sparse_matrix Matrix>
index_type num_collect::linear::algebraic_multigrid_solver< Matrix >::default_maximum_directly_solved_matrix_size
staticconstexprprivate
Initial value:
=
500

Default value of the maximum size of matrices to solve directly.

Definition at line 378 of file algebraic_multigrid_solver.h.

◆ default_strong_coeff_rate_threshold

template<base::concepts::sparse_matrix Matrix>
auto num_collect::linear::algebraic_multigrid_solver< Matrix >::default_strong_coeff_rate_threshold
staticconstexprprivate
Initial value:

Default value of the threshold of the rate of coefficients to determine strong connections.

Definition at line 370 of file algebraic_multigrid_solver.h.

◆ final_layer_

template<base::concepts::sparse_matrix Matrix>
final_layer_data num_collect::linear::algebraic_multigrid_solver< Matrix >::final_layer_ {}
private

Data of the final layer.

Definition at line 358 of file algebraic_multigrid_solver.h.

◆ first_layer_

template<base::concepts::sparse_matrix Matrix>
first_layer_data num_collect::linear::algebraic_multigrid_solver< Matrix >::first_layer_ {}
private

Data of the first layer.

Definition at line 347 of file algebraic_multigrid_solver.h.

◆ intermidiate_layers_

template<base::concepts::sparse_matrix Matrix>
std::deque<intermidiate_layer_data> num_collect::linear::algebraic_multigrid_solver< Matrix >::intermidiate_layers_ {}
private

Data of the intermidiate layers.

Note
deque is used to prevent invalidation of references when layers are added.

Definition at line 355 of file algebraic_multigrid_solver.h.

◆ iterations_

template<base::concepts::sparse_matrix Matrix>
index_type num_collect::linear::algebraic_multigrid_solver< Matrix >::iterations_ {}
mutableprivate

Number of iterations.

Definition at line 367 of file algebraic_multigrid_solver.h.

◆ maximum_directly_solved_matrix_size_

template<base::concepts::sparse_matrix Matrix>
index_type num_collect::linear::algebraic_multigrid_solver< Matrix >::maximum_directly_solved_matrix_size_
private
Initial value:
{
static constexpr index_type default_maximum_directly_solved_matrix_size
Default value of the maximum size of matrices to solve directly.

Maximum size of matrices to solve directly.

Definition at line 382 of file algebraic_multigrid_solver.h.

◆ residual_buffers_

template<base::concepts::sparse_matrix Matrix>
std::vector<dense_vector_type> num_collect::linear::algebraic_multigrid_solver< Matrix >::residual_buffers_ {}
mutableprivate

Buffers of residuals in layers except for the first layer.

Definition at line 361 of file algebraic_multigrid_solver.h.

◆ solution_buffers_

template<base::concepts::sparse_matrix Matrix>
std::vector<dense_vector_type> num_collect::linear::algebraic_multigrid_solver< Matrix >::solution_buffers_ {}
mutableprivate

Buffers of solutions in layers except for the first layer.

Definition at line 364 of file algebraic_multigrid_solver.h.

◆ strong_coeff_rate_threshold_

template<base::concepts::sparse_matrix Matrix>
real_scalar_type num_collect::linear::algebraic_multigrid_solver< Matrix >::strong_coeff_rate_threshold_
private
Initial value:
{
static constexpr auto default_strong_coeff_rate_threshold
Default value of the threshold of the rate of coefficients to determine strong connections.

Threshold of the rate of coefficients to determine strong connections.

Definition at line 374 of file algebraic_multigrid_solver.h.


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