Skip to content

Commit 9c83210

Browse files
committed
re-generate particles in initial adaptive refinement
1 parent 70f4496 commit 9c83210

File tree

6 files changed

+2243
-3
lines changed

6 files changed

+2243
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Changed: ASPECT now re-generates particles in each adaptive
2+
refinement cycle instead of only once after global refinement.
3+
This means that particle locations during adaptive refinement
4+
are chosen according to the generator instead of randomly.
5+
<br>
6+
(Juliane Dannberg, 2025/01/29)

source/particle/manager.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,14 @@ namespace aspect
574574
void
575575
Manager<dim>::setup_initial_state ()
576576
{
577-
// If we are in the first adaptive refinement cycle generate particles
578-
if (this->get_pre_refinement_step() == 0)
579-
generate_particles();
577+
// We want to generate a new set of particles in each adaptive refinement
578+
// cycle to get the right number of particles per cell and to accurately
579+
// initialize their properties. Delete existing particles beforehand.
580+
if (this->get_pre_refinement_step() > 0)
581+
particle_handler->clear();
582+
583+
// Generate particles in each adaptive refinement cycle
584+
generate_particles();
580585

581586
// And initialize the particle properties according to the initial
582587
// conditions on the current mesh
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Like particle_generator_reference_cell.prm but with initial adaptive
2+
# refinement to test correct particle initialization.
3+
# There should be 4 particles per direction within each cell.
4+
5+
set Dimension = 2
6+
7+
include $ASPECT_SOURCE_DIR/tests/particle_generator_reference_cell.prm
8+
9+
subsection Mesh refinement
10+
set Initial adaptive refinement = 1
11+
set Strategy = composition gradient
12+
set Initial global refinement = 3
13+
set Coarsening fraction = 0.6
14+
set Refinement fraction = 0.15
15+
set Adapt by fraction of cells = true
16+
end
17+
18+
subsection Particles
19+
set Load balancing strategy = remove and add particles
20+
set Minimum particles per cell = 16
21+
end

0 commit comments

Comments
 (0)