Skip to content

Commit

Permalink
Merge pull request #6026 from gassmoeller/assert_correct_n_particle_w…
Browse files Browse the repository at this point in the history
…orlds

Assert maximum number of particle worlds.
  • Loading branch information
tjhei authored Sep 5, 2024
2 parents 6a6396c + 9e541f7 commit 4dbb936
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/aspect/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
#cmakedefine ASPECT_WITH_WORLD_BUILDER
#cmakedefine ASPECT_USE_FP_EXCEPTIONS
#cmakedefine ASPECT_WITH_FASTSCAPE
#cmakedefine ASPECT_MAX_NUM_PARTICLE_WORLDS @ASPECT_MAX_NUM_PARTICLE_WORLDS@

#define ASPECT_MAX_NUM_PARTICLE_WORLDS @ASPECT_MAX_NUM_PARTICLE_WORLDS@
#endif
7 changes: 7 additions & 0 deletions source/simulator/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ namespace aspect
if (postprocess_manager.template has_matching_active_plugin<Postprocess::Particles<dim>>())
{
particle_worlds.emplace_back(std::move(std::make_unique<Particle::World<dim>>()));

AssertThrow(particle_worlds.size() <= ASPECT_MAX_NUM_PARTICLE_WORLDS,
ExcMessage("You have selected " + std::to_string(particle_worlds.size()) + " particle worlds, but ASPECT "
"has been compiled with a maximum of " + std::to_string(ASPECT_MAX_NUM_PARTICLE_WORLDS) + ". "
"Please recompile ASPECT with a higher value for ASPECT_MAX_NUM_PARTICLE_WORLDS. You can set a higher number "
"specifying the CMake variable -DASPECT_MAX_NUM_PARTICLE_WORLDS=<number>"));

for (unsigned int particle_world_index = 0 ; particle_world_index < particle_worlds.size(); ++particle_world_index)
{
if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(particle_worlds[particle_world_index].get()))
Expand Down

0 comments on commit 4dbb936

Please sign in to comment.