Skip to content

Commit 8b384b9

Browse files
authored
Merge pull request #5252 from tjhei/2.5-5251
[2.5] take over #5251: fix for latest deal.II master: support cell_weight
2 parents ac01e1f + 1bb33f8 commit 8b384b9

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

include/aspect/particle/world.h

+6
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,15 @@ namespace aspect
230230
* before a refinement step. A weight is attached to every cell
231231
* depending on the number of contained particles.
232232
*/
233+
#if DEAL_II_VERSION_GTE(9,6,0)
234+
unsigned int
235+
cell_weight(const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
236+
const CellStatus status);
237+
#else
233238
unsigned int
234239
cell_weight(const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
235240
const typename parallel::distributed::Triangulation<dim>::CellStatus status);
241+
#endif
236242

237243
/**
238244
* Update the particle properties if necessary.

source/particle/world.cc

+26-5
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ namespace aspect
5454
{
5555
CitationInfo::add("particles");
5656
if (particle_load_balancing & ParticleLoadBalancing::repartition)
57-
#if DEAL_II_VERSION_GTE(9,4,0)
5857
this->get_triangulation().signals.weight.connect(
58+
#if DEAL_II_VERSION_GTE(9,6,0)
59+
[&] (const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
60+
const CellStatus status)
61+
-> unsigned int
5962
#else
60-
this->get_triangulation().signals.cell_weight.connect(
61-
#endif
6263
[&] (const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
6364
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
6465
-> unsigned int
66+
#endif
6567
{
6668
return this->cell_weight(cell, status);
6769
});
@@ -390,7 +392,12 @@ namespace aspect
390392
template <int dim>
391393
unsigned int
392394
World<dim>::cell_weight(const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
393-
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
395+
#if DEAL_II_VERSION_GTE(9,6,0)
396+
const CellStatus status
397+
#else
398+
const typename parallel::distributed::Triangulation<dim>::CellStatus status
399+
#endif
400+
)
394401
{
395402
if (cell->is_active() && !cell->is_locally_owned())
396403
return 0;
@@ -400,6 +407,20 @@ namespace aspect
400407
unsigned int n_particles_in_cell = 0;
401408
switch (status)
402409
{
410+
#if DEAL_II_VERSION_GTE(9,6,0)
411+
case CellStatus::cell_will_persist:
412+
case CellStatus::cell_will_be_refined:
413+
n_particles_in_cell = particle_handler->n_particles_in_cell(cell);
414+
break;
415+
416+
case CellStatus::cell_invalid:
417+
break;
418+
419+
case CellStatus::children_will_be_coarsened:
420+
for (const auto &child : cell->child_iterators())
421+
n_particles_in_cell += particle_handler->n_particles_in_cell(child);
422+
break;
423+
#else
403424
case parallel::distributed::Triangulation<dim>::CELL_PERSIST:
404425
case parallel::distributed::Triangulation<dim>::CELL_REFINE:
405426
n_particles_in_cell = particle_handler->n_particles_in_cell(cell);
@@ -412,7 +433,7 @@ namespace aspect
412433
for (const auto &child : cell->child_iterators())
413434
n_particles_in_cell += particle_handler->n_particles_in_cell(child);
414435
break;
415-
436+
#endif
416437
default:
417438
Assert(false, ExcInternalError());
418439
break;

0 commit comments

Comments
 (0)