24#include <unordered_set>
44template <
typename StorageIndex>
47 const std::unordered_set<StorageIndex>& neighbors_in_coarse_grid,
48 const std::unordered_set<StorageIndex>& neighbors_in_fine_grid)
49 -> std::optional<StorageIndex> {
50 for (
const auto neighbor : neighbors_in_fine_grid) {
51 if (std::ranges::none_of(connections.connected_nodes_to(neighbor),
52 [neighbors_in_coarse_grid](StorageIndex index) {
53 return neighbors_in_coarse_grid.contains(index);
70template <
typename StorageIndex>
78 std::unordered_set<StorageIndex> neighbors_in_coarse_grid;
79 std::unordered_set<StorageIndex> neighbors_in_fine_grid;
80 for (
const auto neighbor :
83 neighbors_in_coarse_grid.insert(neighbor);
87 neighbors_in_fine_grid.insert(neighbor);
92 connections, neighbors_in_coarse_grid, neighbors_in_fine_grid);
93 if (!unsatisfying_node) {
97 neighbors_in_fine_grid.erase(*unsatisfying_node);
98 neighbors_in_coarse_grid.insert(*unsatisfying_node);
101 connections, neighbors_in_coarse_grid, neighbors_in_fine_grid)) {
120template <
typename StorageIndex>
132 if (node_classification[connected_node_index] ==
134 ++num_connected_nodes;
137 if (num_connected_nodes == 0) {
146 connections, node_classification, i);
Definition of assertion macros.
#define NUM_COLLECT_DEBUG_ASSERT(CONDITION)
Macro to check whether a condition is satisfied in debug build only.
Class of lists of connected nodes per node.
auto connected_nodes_to(index_type node_index) const -> std::span< const storage_index_type >
Get the list of indices of connected nodes to the node with the given index.
Class of vectors wrapping std::vector class to use singed integers as indices.
auto size() const -> index_type
Get the size of this vector.
Definition of index_type type.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of internal implementations of algebraic multigrid method ruge1987.
auto find_node_unsatisfying_interpolation_condition(const node_connection_list< StorageIndex > &connections, const std::unordered_set< StorageIndex > &neighbors_in_coarse_grid, const std::unordered_set< StorageIndex > &neighbors_in_fine_grid) -> std::optional< StorageIndex >
Find a neighboring node unsatisfying the condition of interpolation in ruge1987 for a node.
void tune_coarse_grid_selection(const node_connection_list< StorageIndex > &connections, const node_connection_list< StorageIndex > &transposed_connections, util::vector< node_layer > &node_classification)
Tune a coarse grid to satisfy the condition for interpolation specified in ruge1987.
@ fine
Only in finer grid.
void tune_coarse_grid_selection_for_one_node(const node_connection_list< StorageIndex > &connections, util::vector< node_layer > &node_classification, index_type tested_node_index)
Tune a node in a coarse grid to satisfy the condition for interpolation specified in ruge1987.
Definition of node_connection_list class.
Definition of node_class enumeration.
Definition of vector class.