Skip to content

Commit

Permalink
Reduce number of sweeps
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Jan 9, 2024
1 parent 0e74f25 commit f642dd1
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -5178,33 +5178,30 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
evaluation_function);
this->signals_non_nested.prolongation(false);

// Weight operator in case some points are owned by multiple cells.
if (rpe.is_map_unique() == false)
{
const auto evaluation_point_results_temp = evaluation_point_results;
evaluation_point_results.clear();
evaluation_point_results.reserve(rpe.get_point_ptrs().size() - 1);
const auto &ptr = rpe.get_point_ptrs();

const auto &ptr = rpe.get_point_ptrs();
for (unsigned int j = 0;
j < (rpe.is_map_unique() ? evaluation_point_results.size() :
(ptr.size() - 1));
++j)
{
value_type point_result = {};

for (unsigned int i = 0; i < ptr.size() - 1; ++i)
// Weight operator in case some points are owned by multiple cells.
if (rpe.is_map_unique() == false)
{
const auto n_entries = ptr[i + 1] - ptr[i];

value_type result{};
const auto n_entries = ptr[j + 1] - ptr[j];

if (n_entries > 0)
{
for (unsigned int j = 0; j < n_entries; ++j)
result += evaluation_point_results_temp[ptr[i] + j];
result /= n_entries;
for (unsigned int i = 0; i < n_entries; ++i)
point_result += evaluation_point_results[ptr[j] + i];
point_result /= n_entries;
}
evaluation_point_results.push_back(result);
}
}
else
point_result = evaluation_point_results[j];

for (unsigned int j = 0; j < evaluation_point_results.size(); ++j)
{
if (level_dof_indices_fine_ptrs.empty())
{
for (unsigned int c = 0; c < n_components; ++c)
Expand All @@ -5213,7 +5210,7 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
this->level_dof_indices_fine.size());
dst.local_element(
this->level_dof_indices_fine[n_components * j + c]) +=
internal::access(evaluation_point_results[j], c);
internal::access(point_result, c);
}
}
else
Expand All @@ -5227,7 +5224,7 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
this->level_dof_indices_fine.size());
dst.local_element(
this->level_dof_indices_fine[n_components * i + c]) +=
internal::access(evaluation_point_results[j], c);
internal::access(point_result, c);
}
}
}
Expand Down Expand Up @@ -5299,20 +5296,16 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
this->level_dof_indices_fine[n_components * i + c]);
}
}
}

// Weight operator in case some points are owned by multiple cells.
if (rpe.is_map_unique() == false)
{
const auto &ptr = rpe.get_point_ptrs();

for (unsigned int i = 0; i < ptr.size() - 1; ++i)
if (rpe.is_map_unique() == false)
{
const auto n_entries = ptr[i + 1] - ptr[i];
const auto &ptr = rpe.get_point_ptrs();

const auto n_entries = ptr[j + 1] - ptr[j];
if (n_entries == 0)
continue;

evaluation_point_results[i] /= n_entries;
evaluation_point_results[j] /= n_entries;
}
}

Expand Down

0 comments on commit f642dd1

Please sign in to comment.