Skip to content

Commit 206cd51

Browse files
committed
Better comments and doc in RS-coarsening
1 parent a163b97 commit 206cd51

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

include/ginkgo/core/multigrid/rs.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,23 @@ namespace multigrid {
2222

2323

2424
/**
25-
* RS stands for Ruge-Stueben. TODO
25+
* Rs implements the Ruge–Stueben (classical) Algebraic Multigrid (AMG)
26+
* coarsening strategy for M-matrices. Given a sparse system $Ax = b$,
27+
* it produces one level of an AMG hierarchy: a C/F splitting, a prolongation
28+
* operator $P$, and a coarse-grid operator $A_c = R A P$.
2629
*
30+
* Coarsening proceeds in three steps. First, neighbour $j$ is marked as
31+
* *strongly influencing* row $i$ when $-a_{ij} \ge \theta \cdot
32+
* \max_{k \neq i}(-a_{ik})$. Second, a greedy pass selects C-points by
33+
* repeatedly picking the undecided node with the most strong neighbours,
34+
* marking its undecided strong neighbours as F-points, and updating neighbour
35+
* counts accordingly. Third, we create the coarse grid and compute the
36+
* interpolation via the classical RS direct interpolation formula, accounting
37+
* for both strong C- and F-neighbours.
38+
*
39+
* Ruge, J. W., & Stueben, K. (1987). Algebraic multigrid, Multigrid Methods
40+
* (Vol. 3, pp. 73–130). Society for Industrial and Applied Mathematics.
41+
* https://doi.org/10.1137/1.9781611971057.ch4
2742
*
2843
* @tparam ValueType precision of matrix elements
2944
* @tparam IndexType precision of matrix indexes

reference/multigrid/rs_kernels.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void fill_coarse_and_compute_prolong_row_ptrs(
195195
const auto* a_row_ptrs = A->get_const_row_ptrs();
196196
const auto* a_col_idxs = A->get_const_col_idxs();
197197

198-
/// 1. Fill COARSE ROW INDEX ARRAY
198+
/// 1. FILL COARSE ROW INDEX ARRAY
199199
IndexType idx = 0;
200200
for (size_type i = 0; i < cf_marker.get_size(); ++i) {
201201
if (cf[i] == 1) {

reference/test/multigrid/rs_kernels.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Rs : public ::testing::Test {
3939
{0.0, 0.0, 0.0, -1.0, 2.0}});
4040

4141
// strength mask: all 8 off-diagonals are strong
42-
is_strong =
42+
is_strong_prefilled =
4343
gko::array<bool>(exec, {false, true, true, false, true, true, false,
4444
true, true, false, true, true, false});
4545

@@ -48,7 +48,7 @@ class Rs : public ::testing::Test {
4848

4949
std::shared_ptr<gko::ReferenceExecutor> exec;
5050
std::shared_ptr<csr> A;
51-
gko::array<bool> is_strong;
51+
gko::array<bool> is_strong_prefilled;
5252
gko::array<index_type> cf;
5353
};
5454

@@ -62,20 +62,20 @@ TEST_F(Rs, ComputeSocAndRunRs)
6262
{0.0, 0.0, -1.0, 2.0, -1.0},
6363
{0.0, 0.0, 0.0, -1.0, 2.0}});
6464

65-
gko::array<bool> is_strong(exec, 13);
65+
gko::array<bool> is_strong_empty(exec, 13);
6666
gko::array<index_type> lambda(exec, 5);
6767
gko::array<index_type> cf(exec, 5);
6868
index_type coarse{};
6969

7070
gko::kernels::reference::rs::compute_soc_and_run_rs(
71-
exec, A.get(), 0.5, is_strong, lambda, cf, coarse);
71+
exec, A.get(), 0.5, is_strong_empty, lambda, cf, coarse);
7272

7373
// all off-diagonals are strong
7474
std::vector<bool> expected_soc{false, true, true, false, true, true, false,
7575
true, true, false, true, true, false};
7676

7777
for (int i = 0; i < 13; ++i) {
78-
ASSERT_EQ(is_strong.get_const_data()[i], expected_soc[i]);
78+
ASSERT_EQ(is_strong_empty.get_const_data()[i], expected_soc[i]);
7979
}
8080
// initial lambda: [1, 2, 2, 2, 1]. After greedy RS:
8181
ASSERT_EQ(cf.get_const_data()[0], -1);
@@ -95,7 +95,7 @@ TEST_F(Rs, FillCoarseAndComputeProlongRowPtrs)
9595
gko::array<index_type> coarse(exec, 2);
9696

9797
gko::kernels::reference::rs::fill_coarse_and_compute_prolong_row_ptrs(
98-
exec, cf, coarse, f2c, A.get(), is_strong, p_row_ptrs);
98+
exec, cf, coarse, f2c, A.get(), is_strong_prefilled, p_row_ptrs);
9999

100100
// C-points (1, 3) map to (0, 1)
101101
ASSERT_EQ(f2c.get_const_data()[0], -1);
@@ -120,8 +120,8 @@ TEST_F(Rs, ComputeInterpolation)
120120
P->get_row_ptrs());
121121

122122
gko::kernels::reference::rs::compute_interpolation(
123-
exec, A.get(), is_strong.get_const_data(), cf, f2c.get_const_data(),
124-
P.get());
123+
exec, A.get(), is_strong_prefilled.get_const_data(), cf,
124+
f2c.get_const_data(), P.get());
125125

126126
auto p_vals = P->get_const_values();
127127
auto p_cols = P->get_const_col_idxs();

0 commit comments

Comments
 (0)