diff --git a/include/aspect/particle/generator/interface.h b/include/aspect/particle/generator/interface.h index 713869d96b0..13508fa1c41 100644 --- a/include/aspect/particle/generator/interface.h +++ b/include/aspect/particle/generator/interface.h @@ -21,7 +21,7 @@ #ifndef _aspect_particle_generator_interface_h #define _aspect_particle_generator_interface_h -#include +#include #include #include @@ -65,7 +65,7 @@ namespace aspect * @ingroup ParticleGenerators */ template - class Interface : public SimulatorAccess, public Plugins::InterfaceBase + class Interface : public SimulatorAccess, public ParticleInterfaceBase { public: virtual diff --git a/include/aspect/particle/integrator/interface.h b/include/aspect/particle/integrator/interface.h index 84e1ba196b5..dab8f945625 100644 --- a/include/aspect/particle/integrator/interface.h +++ b/include/aspect/particle/integrator/interface.h @@ -21,7 +21,7 @@ #ifndef _aspect_particle_integrator_interface_h #define _aspect_particle_integrator_interface_h -#include +#include #include #include @@ -44,7 +44,7 @@ namespace aspect * @ingroup ParticleIntegrators */ template - class Interface : public Plugins::InterfaceBase + class Interface : public ParticleInterfaceBase { public: /** diff --git a/include/aspect/particle/interface.h b/include/aspect/particle/interface.h new file mode 100644 index 00000000000..04ab2a319ba --- /dev/null +++ b/include/aspect/particle/interface.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2015 - 2022 by the authors of the ASPECT code. + + This file is part of ASPECT. + + ASPECT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + ASPECT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ASPECT; see the file LICENSE. If not see + . + */ + +#ifndef _aspect_particle_interface_h +#define _aspect_particle_interface_h + +#include + +namespace aspect +{ + namespace Particle + { + /** + * A base class defining methods and member variables + * shared along all the particle plugins. This includes the generator, + * integrator, interpolator and the property classes. + * + * @ingroup Particle + */ + class ParticleInterfaceBase : public Plugins::InterfaceBase + { + public: + /** + * @brief Set which particle world the plugin belongs to. + * + * @param particle_world_index The index of the particle world this plugin belongs to. + */ + void set_particle_world_index(unsigned int particle_world_index); + + /** + * @brief Gets which particle world the plugin belong to. + */ + unsigned int get_particle_world_index() const; + + private: + /** + * Stores the index to the particle world, to which the plugin belongs. + */ + unsigned int particle_world_index; + }; + + } +} + + +#endif diff --git a/include/aspect/particle/interpolator/interface.h b/include/aspect/particle/interpolator/interface.h index 127b133353c..6d52b743356 100644 --- a/include/aspect/particle/interpolator/interface.h +++ b/include/aspect/particle/interpolator/interface.h @@ -21,7 +21,7 @@ #ifndef _aspect_particle_interpolator_interface_h #define _aspect_particle_interpolator_interface_h -#include +#include #include #include @@ -47,7 +47,7 @@ namespace aspect * @ingroup ParticleInterpolators */ template - class Interface : public Plugins::InterfaceBase + class Interface : public ParticleInterfaceBase { public: /** diff --git a/include/aspect/particle/property/interface.h b/include/aspect/particle/property/interface.h index 188e928590b..c38cec81970 100644 --- a/include/aspect/particle/property/interface.h +++ b/include/aspect/particle/property/interface.h @@ -21,8 +21,8 @@ #ifndef _aspect_particle_property_interface_h #define _aspect_particle_property_interface_h +#include #include -#include #include #include @@ -305,7 +305,7 @@ namespace aspect * @ingroup ParticleProperties */ template - class Interface : public Plugins::InterfaceBase + class Interface : public ParticleInterfaceBase { public: /** @@ -733,6 +733,12 @@ namespace aspect void parse_parameters (ParameterHandler &prm); + /** + * @brief Set the particle world index for all particle properties + * + * @param particle_world_index The index of the particle world. + */ + void set_particle_world_index(unsigned int particle_world_index); /** * For the current plugin subsystem, write a connection graph of all of the diff --git a/source/particle/interface.cc b/source/particle/interface.cc new file mode 100644 index 00000000000..659e348739c --- /dev/null +++ b/source/particle/interface.cc @@ -0,0 +1,42 @@ +/* + Copyright (C) 2024 by the authors of the ASPECT code. + + This file is part of ASPECT. + + ASPECT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + ASPECT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ASPECT; see the file LICENSE. If not see + . + */ + +#include + + +namespace aspect +{ + namespace Particle + { + void + ParticleInterfaceBase::set_particle_world_index(const unsigned int particle_world_index) + { + this->particle_world_index = particle_world_index; + } + + + + unsigned int + ParticleInterfaceBase::get_particle_world_index() const + { + return particle_world_index; + } + } +} diff --git a/source/particle/property/interface.cc b/source/particle/property/interface.cc index 8935dfdb8e8..add91d4a325 100644 --- a/source/particle/property/interface.cc +++ b/source/particle/property/interface.cc @@ -748,6 +748,18 @@ namespace aspect + template + void + Manager::set_particle_world_index(unsigned int particle_world_index) + { + for (auto &property : property_list) + { + property->set_particle_world_index(particle_world_index); + } + } + + + template void Manager:: diff --git a/source/particle/world.cc b/source/particle/world.cc index 06d37152878..0c558f8a996 100644 --- a/source/particle/world.cc +++ b/source/particle/world.cc @@ -1334,6 +1334,7 @@ namespace aspect generator = Generator::create_particle_generator (prm); if (SimulatorAccess *sim = dynamic_cast*>(generator.get())) sim->initialize_simulator (this->get_simulator()); + generator->set_particle_world_index(world_index); generator->parse_parameters(prm); generator->initialize(); @@ -1341,6 +1342,7 @@ namespace aspect property_manager = std::make_unique> (); SimulatorAccess *sim = dynamic_cast*>(property_manager.get()); sim->initialize_simulator (this->get_simulator()); + property_manager->set_particle_world_index(world_index); property_manager->parse_parameters(prm); property_manager->initialize(); @@ -1348,6 +1350,7 @@ namespace aspect integrator = Integrator::create_particle_integrator (prm); if (SimulatorAccess *sim = dynamic_cast*>(integrator.get())) sim->initialize_simulator (this->get_simulator()); + integrator->set_particle_world_index(world_index); integrator->parse_parameters(prm); integrator->initialize(); @@ -1355,6 +1358,7 @@ namespace aspect interpolator = Interpolator::create_particle_interpolator (prm); if (SimulatorAccess *sim = dynamic_cast*>(interpolator.get())) sim->initialize_simulator (this->get_simulator()); + interpolator->set_particle_world_index(world_index); interpolator->parse_parameters(prm); interpolator->initialize();