Skip to content

Commit

Permalink
Merge pull request #6097 from gassmoeller/convert_managers
Browse files Browse the repository at this point in the history
Derive remaining managers from ManagerBase
  • Loading branch information
gassmoeller authored Feb 5, 2025
2 parents bbe58d8 + fcdb42d commit 74fbe92
Show file tree
Hide file tree
Showing 30 changed files with 600 additions and 458 deletions.
9 changes: 9 additions & 0 deletions doc/modules/changes/20250202_gassmoeller
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Changed: ASPECT's boundary traction and boundary velocity manager classes are
now also derived from the common classes Plugins::ManagerBase. In order to
standardize the interface, the functions get_active_boundary_traction_conditions()
and get_active_boundary_traction_names() (and their velocity counterparts)
have been deprecated. They have been replaced by the new functions get_active_plugins(),
get_active_plugin_boundary_indicators(), get_prescribed_boundary_traction_indicators(),
and get_component_mask().
<br>
(Rene Gassmoeller, 2025/02/02)
97 changes: 74 additions & 23 deletions include/aspect/boundary_traction/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,13 @@ namespace aspect
};

template <int dim>
class Manager : public SimulatorAccess<dim>
class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
{
public:
/**
* Destructor. Made virtual since this class has virtual member
* functions.
*/
~Manager () override;

/**
* A function that is called at the beginning of each time step and
* calls the corresponding functions of all created plugins.
*
* The point of this function is to allow complex boundary traction
* models to do an initialization step once at the beginning of each
* time step. An example would be a model that needs to call an
* external program to compute the traction change at a boundary.
*/
virtual
void
update ();

/**
* A function that calls the boundary_traction functions of all the
* individual boundary traction objects and uses the stored operators
* to combine them.
* individual boundary traction objects that are active for boundary id
* @p boundary_indicator and uses the stored operators to combine them.
*/
Tensor<1,dim>
boundary_traction (const types::boundary_id boundary_indicator,
Expand All @@ -112,7 +93,11 @@ namespace aspect
* If there are no prescribed boundary traction plugins
* for a particular boundary, this boundary identifier will not appear
* in the map.
*
* @deprecated This function will be removed. Use the function
* get_active_plugin_names() of the base class ManagerBase instead.
*/
DEAL_II_DEPRECATED
const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> &
get_active_boundary_traction_names () const;

Expand All @@ -124,10 +109,43 @@ namespace aspect
* boundary models for this boundary. If there are no prescribed
* boundary traction plugins for a particular boundary this boundary
* identifier will not appear in the map.
*
* @deprecated This function has been removed. Use the function
* get_active_plugins() of the base class ManagerBase instead.
*/
DEAL_II_DEPRECATED
const std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryTraction::Interface<dim>>>> &
get_active_boundary_traction_conditions () const;

/**
* Return a set of boundary indicators for which boundary
* tractions are prescribed.
*/
const std::set<types::boundary_id> &
get_prescribed_boundary_traction_indicators () const;

/**
* Return a list of boundary indicators that indicate for
* each active plugin which boundary id
* it is responsible for. The list of active plugins can be
* requested by calling get_active_plugins().
*/
const std::vector<types::boundary_id> &
get_active_plugin_boundary_indicators() const;

/**
* Return a component mask that indicates for the given
* @p boundary_id which traction components are prescribed by
* this manager class. All plugins that are responsible
* for this boundary use the same component mask.
* The list of plugin objects can be
* requested by calling get_active_plugins() and the
* list of boundaries they are responsible for is
* returned by get_active_plugin_boundary_indicators().
*/
ComponentMask
get_component_mask(const types::boundary_id boundary_id) const;

/**
* Declare the parameters of all known boundary traction plugins, as
* well as the ones this class has itself.
Expand All @@ -142,7 +160,7 @@ namespace aspect
* then let these objects read their parameters as well.
*/
void
parse_parameters (ParameterHandler &prm);
parse_parameters (ParameterHandler &prm) override;

/**
* For the current plugin subsystem, write a connection graph of all of the
Expand Down Expand Up @@ -191,9 +209,37 @@ namespace aspect
std::unique_ptr<Interface<dim>> (*factory_function) ());

private:
/**
* A list of boundary indicators that indicate for
* each plugin in the list of plugin_objects which boundary id
* it is responsible for. By default each plugin
* is active for all boundaries, but this list
* can be modified by derived classes to limit the application
* of plugins to specific boundaries.
*/
std::vector<types::boundary_id> boundary_indicators;

/**
* A list of boundary indicators that indicate for
* each plugin in the list of plugin_objects which components
* it is responsible for. By default each plugin
* is active for all components, but this list
* can be modified by derived classes to limit the application
* of plugins to specific boundaries.
*/
std::vector<ComponentMask> component_masks;

/**
* A set of boundary indicators, on which tractions are prescribed.
*/
std::set<types::boundary_id> prescribed_traction_boundary_indicators;

/**
* A list of boundary traction objects that have been requested in the
* parameter file.
*
* @deprecated This variable is no longer used, but needed to issue a proper
* error message in the function get_active_boundary_traction_conditions().
*/
std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryTraction::Interface<dim>>>> boundary_traction_objects;

Expand All @@ -204,6 +250,11 @@ namespace aspect
* mapped to one of the plugins of traction boundary conditions (e.g.
* "function"). If the components string is empty, it is assumed the
* plugins are used for all components.
*
* @deprecated Remove this variable when the deprecated functions
* get_active_boundary_traction_names and
* get_active_boundary_traction_conditions are removed. Use the base class
* variable plugin_names instead.
*/
std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> boundary_traction_indicators;

Expand Down
105 changes: 84 additions & 21 deletions include/aspect/boundary_velocity/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,9 @@ namespace aspect
* @ingroup BoundaryVelocities
*/
template <int dim>
class Manager : public SimulatorAccess<dim>
class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
{
public:
/**
* Destructor. Made virtual since this class has virtual member
* functions.
*/
~Manager () override;

/**
* A function that is called at the beginning of each time step and
* calls the corresponding functions of all created plugins.
*
* The point of this function is to allow complex boundary velocity
* models to do an initialization step once at the beginning of each
* time step. An example would be a model that needs to call an
* external program to compute the velocity change at a boundary.
*/
virtual
void
update ();

/**
* A function that calls the boundary_velocity functions of all the
* individual boundary velocity objects and uses the stored operators
Expand Down Expand Up @@ -144,7 +125,11 @@ namespace aspect
* If there are no prescribed boundary velocity plugins
* for a particular boundary, this boundary identifier will not appear
* in the map.
*
* @deprecated This function will be removed. Use the function
* get_active_plugin_names() of the base class ManagerBase instead.
*/
DEAL_II_DEPRECATED
const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> &
get_active_boundary_velocity_names () const;

Expand All @@ -156,10 +141,43 @@ namespace aspect
* boundary models for this boundary. If there are no prescribed
* boundary velocity plugins for a particular boundary this boundary
* identifier will not appear in the map.
*
* @deprecated This function has been removed. Use the function
* get_active_plugins() of the base class ManagerBase instead.
*/
DEAL_II_DEPRECATED
const std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> &
get_active_boundary_velocity_conditions () const;

/**
* Return a list of boundary indicators that indicate for
* each active plugin which boundary id
* it is responsible for. The list of active plugins can be
* requested by calling get_active_plugins().
*/
const std::vector<types::boundary_id> &
get_active_plugin_boundary_indicators() const;

/**
* Return a component mask that indicates for the given
* @p boundary_id which velocity components are prescribed by
* this manager class. All plugins that are responsible
* for this boundary use the same component mask.
* The list of plugin objects can be
* requested by calling get_active_plugins() and the
* list of boundaries they are responsible for is
* returned by get_active_plugin_boundary_indicators().
*/
ComponentMask
get_component_mask(const types::boundary_id boundary_id) const;

/**
* Return a set of boundary indicators for which boundary
* velocities are prescribed.
*/
const std::set<types::boundary_id> &
get_prescribed_boundary_velocity_indicators () const;

/**
* Return a list of boundary ids on which the velocity is prescribed
* to be zero (no-slip).
Expand Down Expand Up @@ -188,7 +206,7 @@ namespace aspect
* then let these objects read their parameters as well.
*/
void
parse_parameters (ParameterHandler &prm);
parse_parameters (ParameterHandler &prm) override;

/**
* Go through the list of all boundary velocity models that have been selected
Expand All @@ -198,9 +216,15 @@ namespace aspect
*
* This function can only be called if the given template type (the first template
* argument) is a class derived from the Interface class in this namespace.
*
* @deprecated Instead of this function, use the
* Plugins::ManagerBase::has_matching_active_plugin() and
* Plugins::ManagerBase::get_matching_active_plugin() functions of the base
* class of the current class.
*/
template <typename BoundaryVelocityType,
typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
DEAL_II_DEPRECATED
bool
has_matching_boundary_velocity_model () const;

Expand All @@ -214,9 +238,15 @@ namespace aspect
*
* This function can only be called if the given template type (the first template
* argument) is a class derived from the Interface class in this namespace.
*
* @deprecated Instead of this function, use the
* Plugins::ManagerBase::has_matching_active_plugin() and
* Plugins::ManagerBase::get_matching_active_plugin() functions of the base
* class of the current class.
*/
template <typename BoundaryVelocityType,
typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
DEAL_II_DEPRECATED
const BoundaryVelocityType &
get_matching_boundary_velocity_model () const;

Expand All @@ -243,9 +273,32 @@ namespace aspect
<< arg1
<< "> among the names of registered boundary velocity objects.");
private:
/**
* A list of boundary indicators that indicate for
* each plugin in the list of plugin_objects which boundary id
* it is responsible for. By default each plugin
* is active for all boundaries, but this list
* can be modified by derived classes to limit the application
* of plugins to specific boundaries.
*/
std::vector<types::boundary_id> boundary_indicators;

/**
* A list of boundary indicators that indicate for
* each plugin in the list of plugin_objects which components
* it is responsible for. By default each plugin
* is active for all components, but this list
* can be modified by derived classes to limit the application
* of plugins to specific boundaries.
*/
std::vector<ComponentMask> component_masks;

/**
* A list of boundary velocity objects that have been requested in the
* parameter file.
*
* @deprecated This variable is no longer used, but needed to issue a proper
* error message in the function get_active_boundary_velocity_conditions().
*/
std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> boundary_velocity_objects;

Expand All @@ -256,9 +309,19 @@ namespace aspect
* mapped to one of the plugins of velocity boundary conditions (e.g.
* "function"). If the components string is empty, it is assumed the
* plugins are used for all components.
*
* @deprecated Remove this variable when the deprecated functions
* get_active_boundary_velocity_names and
* get_active_boundary_velocity_conditions are removed. Use the base class
* variable plugin_names instead.
*/
std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> boundary_velocity_indicators;

/**
* A set of boundary indicators, on which velocities are prescribed.
*/
std::set<types::boundary_id> prescribed_velocity_boundary_indicators;

/**
* A set of boundary indicators, on which velocities are prescribed to
* zero (no-slip).
Expand Down
8 changes: 0 additions & 8 deletions include/aspect/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,6 @@ namespace aspect
bool enable_additional_stokes_rhs;
bool enable_prescribed_dilation;

/**
* Map from boundary id to a pair "components", "traction boundary type",
* where components is of the format "[x][y][z]" and the traction type is
* mapped to one of the plugins of traction boundary conditions (e.g.
* "function")
*/
std::map<types::boundary_id, std::pair<std::string,std::string>> prescribed_traction_boundary_indicators;

/**
* A set of boundary ids on which the boundary_heat_flux objects
* will be applied.
Expand Down
3 changes: 2 additions & 1 deletion include/aspect/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

#include <deal.II/base/utilities.h>
#include <deal.II/base/parameter_handler.h>
#include <tuple>
#include <deal.II/base/exceptions.h>
#include <deal.II/fe/component_mask.h>

#include <boost/core/demangle.hpp>

#include <tuple>
#include <string>
#include <list>
#include <set>
Expand Down
13 changes: 8 additions & 5 deletions source/boundary_traction/ascii_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ namespace aspect
void
AsciiData<dim>::initialize ()
{
for (const auto &bv : this->get_boundary_traction_manager().get_active_boundary_traction_conditions())
unsigned int i=0;
for (const auto &plugin : this->get_boundary_traction_manager().get_active_plugins())
{
for (const auto &plugin : bv.second)
if (plugin.get() == this)
boundary_ids.insert(bv.first);
if (plugin.get() == this)
boundary_ids.insert(this->get_boundary_traction_manager().get_active_plugin_boundary_indicators()[i]);

++i;
}
AssertThrow(*(boundary_ids.begin()) != numbers::invalid_boundary_id,

AssertThrow(boundary_ids.empty() == false,
ExcMessage("Did not find the boundary indicator for the traction ascii data plugin."));

Utilities::AsciiDataBoundary<dim>::initialize(boundary_ids,
Expand Down
Loading

0 comments on commit 74fbe92

Please sign in to comment.