Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive remaining managers from ManagerBase #6097

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 74 additions & 23 deletions include/aspect/boundary_traction/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,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 @@ -114,7 +95,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 @@ -126,10 +111,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 masks that indicates for
* each boundary which 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 @@ -144,7 +162,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 @@ -193,9 +211,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 @@ -206,6 +252,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 @@ -79,28 +79,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 @@ -146,7 +127,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 @@ -158,10 +143,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 masks that indicates for
* each boundary which 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 @@ -190,7 +208,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 @@ -200,9 +218,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 @@ -216,9 +240,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 @@ -245,9 +275,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 @@ -258,9 +311,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 @@ -637,14 +637,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
14 changes: 12 additions & 2 deletions 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 Expand Up @@ -294,7 +295,16 @@ namespace aspect
template <typename InterfaceType>
ManagerBase<InterfaceType>::~ManagerBase()
{
Assert (plugin_names.size() == plugin_objects.size(), ExcInternalError());
// only check and throw if we are not unwinding the stack due
// to an active exception
#ifdef DEAL_II_HAVE_CXX17
if (std::uncaught_exceptions() == 0)
#else
if (std::uncaught_exception() == false)
#endif
{
Assert (plugin_names.size() == plugin_objects.size(), ExcInternalError());
}
}


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