diff --git a/include/aspect/particle/interface.h b/include/aspect/particle/interface.h index 04ab2a319ba..bbe34c9530c 100644 --- a/include/aspect/particle/interface.h +++ b/include/aspect/particle/interface.h @@ -37,6 +37,11 @@ namespace aspect class ParticleInterfaceBase : public Plugins::InterfaceBase { public: + /** + * Constructor. + */ + ParticleInterfaceBase(); + /** * @brief Set which particle world the plugin belongs to. * diff --git a/include/aspect/particle/property/interface.h b/include/aspect/particle/property/interface.h index b1047d14928..03b93213d18 100644 --- a/include/aspect/particle/property/interface.h +++ b/include/aspect/particle/property/interface.h @@ -749,6 +749,11 @@ namespace aspect write_plugin_graph (std::ostream &output_stream); private: + /** + * Stores the index to the particle world, to which this manager belongs. + */ + unsigned int particle_world_index; + /** * Stores the names of the plugins which are present * in the order they are executed. diff --git a/source/particle/interface.cc b/source/particle/interface.cc index 659e348739c..42cd78b354d 100644 --- a/source/particle/interface.cc +++ b/source/particle/interface.cc @@ -25,6 +25,12 @@ namespace aspect { namespace Particle { + ParticleInterfaceBase::ParticleInterfaceBase() + : particle_world_index(numbers::invalid_unsigned_int) + {} + + + void ParticleInterfaceBase::set_particle_world_index(const unsigned int particle_world_index) { diff --git a/source/particle/property/interface.cc b/source/particle/property/interface.cc index 577d858286f..e75412f5615 100644 --- a/source/particle/property/interface.cc +++ b/source/particle/property/interface.cc @@ -714,11 +714,13 @@ namespace aspect if (SimulatorAccess *sim = dynamic_cast*>(this->plugin_objects.back().get())) sim->initialize_simulator (this->get_simulator()); + this->plugin_objects.back()->set_particle_world_index(particle_world_index); this->plugin_objects.back()->parse_parameters (prm); } - // lastly store internal integrator properties + // lastly store internal integrator properties: this->plugin_objects.emplace_back (std::make_unique>()); + this->plugin_objects.back()->set_particle_world_index(particle_world_index); this->plugin_objects.back()->parse_parameters (prm); } @@ -728,10 +730,9 @@ namespace aspect void Manager::set_particle_world_index(unsigned int particle_world_index) { - for (auto &property : this->plugin_objects) - { - property->set_particle_world_index(particle_world_index); - } + // Save this value. We will tell our plugins about this, once they + // have been created in parse_parameters(). + this->particle_world_index = particle_world_index; }