Skip to content

Commit

Permalink
Merge pull request #5921 from MFraters/add_partcleInterfaceBase_to_se…
Browse files Browse the repository at this point in the history
…t_particle_world_index

Add ParticleInterfaceBase to set the particle world index for the particle plugins.
  • Loading branch information
gassmoeller authored Jun 20, 2024
2 parents 7b8dde8 + 861cd50 commit fbbb4e5
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/aspect/particle/generator/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef _aspect_particle_generator_interface_h
#define _aspect_particle_generator_interface_h

#include <aspect/plugins.h>
#include <aspect/particle/interface.h>
#include <aspect/simulator_access.h>

#include <deal.II/particles/particle.h>
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace aspect
* @ingroup ParticleGenerators
*/
template <int dim>
class Interface : public SimulatorAccess<dim>, public Plugins::InterfaceBase
class Interface : public SimulatorAccess<dim>, public ParticleInterfaceBase
{
public:
virtual
Expand Down
4 changes: 2 additions & 2 deletions include/aspect/particle/integrator/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef _aspect_particle_integrator_interface_h
#define _aspect_particle_integrator_interface_h

#include <aspect/plugins.h>
#include <aspect/particle/interface.h>
#include <aspect/global.h>

#include <deal.II/particles/particle.h>
Expand All @@ -44,7 +44,7 @@ namespace aspect
* @ingroup ParticleIntegrators
*/
template <int dim>
class Interface : public Plugins::InterfaceBase
class Interface : public ParticleInterfaceBase
{
public:
/**
Expand Down
63 changes: 63 additions & 0 deletions include/aspect/particle/interface.h
Original file line number Diff line number Diff line change
@@ -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
<http://www.gnu.org/licenses/>.
*/

#ifndef _aspect_particle_interface_h
#define _aspect_particle_interface_h

#include <aspect/plugins.h>

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
4 changes: 2 additions & 2 deletions include/aspect/particle/interpolator/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef _aspect_particle_interpolator_interface_h
#define _aspect_particle_interpolator_interface_h

#include <aspect/plugins.h>
#include <aspect/particle/interface.h>
#include <aspect/global.h>

#include <deal.II/particles/particle.h>
Expand All @@ -47,7 +47,7 @@ namespace aspect
* @ingroup ParticleInterpolators
*/
template <int dim>
class Interface : public Plugins::InterfaceBase
class Interface : public ParticleInterfaceBase
{
public:
/**
Expand Down
10 changes: 8 additions & 2 deletions include/aspect/particle/property/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#ifndef _aspect_particle_property_interface_h
#define _aspect_particle_property_interface_h

#include <aspect/particle/interface.h>
#include <aspect/global.h>
#include <aspect/plugins.h>

#include <aspect/particle/interpolator/interface.h>
#include <aspect/simulator_access.h>
Expand Down Expand Up @@ -305,7 +305,7 @@ namespace aspect
* @ingroup ParticleProperties
*/
template <int dim>
class Interface : public Plugins::InterfaceBase
class Interface : public ParticleInterfaceBase
{
public:
/**
Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions source/particle/interface.cc
Original file line number Diff line number Diff line change
@@ -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
<http://www.gnu.org/licenses/>.
*/

#include <aspect/particle/interface.h>


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;
}
}
}
12 changes: 12 additions & 0 deletions source/particle/property/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,18 @@ namespace aspect



template <int dim>
void
Manager<dim>::set_particle_world_index(unsigned int particle_world_index)
{
for (auto &property : property_list)
{
property->set_particle_world_index(particle_world_index);
}
}



template <int dim>
void
Manager<dim>::
Expand Down
4 changes: 4 additions & 0 deletions source/particle/world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1334,27 +1334,31 @@ namespace aspect
generator = Generator::create_particle_generator<dim> (prm);
if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(generator.get()))
sim->initialize_simulator (this->get_simulator());
generator->set_particle_world_index(world_index);
generator->parse_parameters(prm);
generator->initialize();

// Create a property_manager object and initialize its properties
property_manager = std::make_unique<Property::Manager<dim>> ();
SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(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();

// Create an integrator object depending on the specified parameter
integrator = Integrator::create_particle_integrator<dim> (prm);
if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(integrator.get()))
sim->initialize_simulator (this->get_simulator());
integrator->set_particle_world_index(world_index);
integrator->parse_parameters(prm);
integrator->initialize();

// Create an interpolator object depending on the specified parameter
interpolator = Interpolator::create_particle_interpolator<dim> (prm);
if (SimulatorAccess<dim> *sim = dynamic_cast<SimulatorAccess<dim>*>(interpolator.get()))
sim->initialize_simulator (this->get_simulator());
interpolator->set_particle_world_index(world_index);
interpolator->parse_parameters(prm);
interpolator->initialize();

Expand Down

0 comments on commit fbbb4e5

Please sign in to comment.