Skip to content

Commit

Permalink
convert velocity boundary manager
Browse files Browse the repository at this point in the history
  • Loading branch information
gassmoeller committed Oct 23, 2024
1 parent 2f4273f commit ba097d3
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 340 deletions.
12 changes: 12 additions & 0 deletions include/aspect/boundary_traction/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ namespace aspect
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
Expand Down Expand Up @@ -220,6 +227,11 @@ namespace aspect
*/
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.
Expand Down
101 changes: 80 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,39 @@ 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 list of component masks that indicate for
* each active plugin which components it is responsible for.
* The list of plugin objects can be
* requested by calling get_active_plugins().
*/
const std::vector<ComponentMask> &
get_active_plugin_component_masks() 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 +204,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 +214,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 +236,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 +271,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 +307,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
26 changes: 18 additions & 8 deletions source/boundary_traction/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ namespace aspect



template <int dim>
const std::set<types::boundary_id> &
Manager<dim>::get_prescribed_boundary_traction_indicators () const
{
return prescribed_traction_boundary_indicators;
}



template <int dim>
const std::vector<types::boundary_id> &
Manager<dim>::get_active_plugin_boundary_indicators() const
Expand Down Expand Up @@ -273,16 +282,17 @@ namespace aspect

this->plugin_names.push_back(value);
boundary_indicators.push_back(boundary_id);
prescribed_traction_boundary_indicators.insert(boundary_id);

const bool default_component_mask = comp.empty();
ComponentMask component_mask(dim, default_component_mask);
ComponentMask component_mask(this->introspection().n_components,
false);

if (comp.find('x') != std::string::npos)
component_mask.set(0,true);
if (comp.find('y') != std::string::npos)
component_mask.set(1,true);
if (dim == 3 && comp.find('z') != std::string::npos)
component_mask.set(2,true);
if (comp.empty() || comp.find('x') != std::string::npos)
component_mask.set(this->introspection().component_indices.velocities[0],true);
if (comp.empty() || comp.find('y') != std::string::npos)
component_mask.set(this->introspection().component_indices.velocities[1],true);
if (dim == 3 && (comp.empty() || comp.find('z') != std::string::npos))
component_mask.set(this->introspection().component_indices.velocities[2],true);

component_masks.push_back(component_mask);
}
Expand Down
15 changes: 9 additions & 6 deletions source/boundary_velocity/ascii_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ namespace aspect
void
AsciiData<dim>::initialize ()
{
for (const auto &p : this->get_boundary_velocity_manager().get_active_boundary_velocity_conditions())
unsigned int i=0;
for (const auto &plugin : this->get_boundary_velocity_manager().get_active_plugins())
{
for (const auto &plugin : p.second)
if (plugin.get() == this)
boundary_ids.insert(p.first);
if (plugin.get() == this)
boundary_ids.insert(this->get_boundary_velocity_manager().get_active_plugin_boundary_indicators()[i]);

++i;
}
AssertThrow(*(boundary_ids.begin()) != numbers::invalid_boundary_id,
ExcMessage("Did not find the boundary indicator for the prescribed data plugin."));

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

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

0 comments on commit ba097d3

Please sign in to comment.