Skip to content

Commit 74fbe92

Browse files
authored
Merge pull request #6097 from gassmoeller/convert_managers
Derive remaining managers from ManagerBase
2 parents bbe58d8 + fcdb42d commit 74fbe92

File tree

30 files changed

+600
-458
lines changed

30 files changed

+600
-458
lines changed
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Changed: ASPECT's boundary traction and boundary velocity manager classes are
2+
now also derived from the common classes Plugins::ManagerBase. In order to
3+
standardize the interface, the functions get_active_boundary_traction_conditions()
4+
and get_active_boundary_traction_names() (and their velocity counterparts)
5+
have been deprecated. They have been replaced by the new functions get_active_plugins(),
6+
get_active_plugin_boundary_indicators(), get_prescribed_boundary_traction_indicators(),
7+
and get_component_mask().
8+
<br>
9+
(Rene Gassmoeller, 2025/02/02)

include/aspect/boundary_traction/interface.h

+74-23
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,13 @@ namespace aspect
6969
};
7070

7171
template <int dim>
72-
class Manager : public SimulatorAccess<dim>
72+
class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
7373
{
7474
public:
75-
/**
76-
* Destructor. Made virtual since this class has virtual member
77-
* functions.
78-
*/
79-
~Manager () override;
80-
81-
/**
82-
* A function that is called at the beginning of each time step and
83-
* calls the corresponding functions of all created plugins.
84-
*
85-
* The point of this function is to allow complex boundary traction
86-
* models to do an initialization step once at the beginning of each
87-
* time step. An example would be a model that needs to call an
88-
* external program to compute the traction change at a boundary.
89-
*/
90-
virtual
91-
void
92-
update ();
93-
9475
/**
9576
* A function that calls the boundary_traction functions of all the
96-
* individual boundary traction objects and uses the stored operators
97-
* to combine them.
77+
* individual boundary traction objects that are active for boundary id
78+
* @p boundary_indicator and uses the stored operators to combine them.
9879
*/
9980
Tensor<1,dim>
10081
boundary_traction (const types::boundary_id boundary_indicator,
@@ -112,7 +93,11 @@ namespace aspect
11293
* If there are no prescribed boundary traction plugins
11394
* for a particular boundary, this boundary identifier will not appear
11495
* in the map.
96+
*
97+
* @deprecated This function will be removed. Use the function
98+
* get_active_plugin_names() of the base class ManagerBase instead.
11599
*/
100+
DEAL_II_DEPRECATED
116101
const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> &
117102
get_active_boundary_traction_names () const;
118103

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

120+
/**
121+
* Return a set of boundary indicators for which boundary
122+
* tractions are prescribed.
123+
*/
124+
const std::set<types::boundary_id> &
125+
get_prescribed_boundary_traction_indicators () const;
126+
127+
/**
128+
* Return a list of boundary indicators that indicate for
129+
* each active plugin which boundary id
130+
* it is responsible for. The list of active plugins can be
131+
* requested by calling get_active_plugins().
132+
*/
133+
const std::vector<types::boundary_id> &
134+
get_active_plugin_boundary_indicators() const;
135+
136+
/**
137+
* Return a component mask that indicates for the given
138+
* @p boundary_id which traction components are prescribed by
139+
* this manager class. All plugins that are responsible
140+
* for this boundary use the same component mask.
141+
* The list of plugin objects can be
142+
* requested by calling get_active_plugins() and the
143+
* list of boundaries they are responsible for is
144+
* returned by get_active_plugin_boundary_indicators().
145+
*/
146+
ComponentMask
147+
get_component_mask(const types::boundary_id boundary_id) const;
148+
131149
/**
132150
* Declare the parameters of all known boundary traction plugins, as
133151
* well as the ones this class has itself.
@@ -142,7 +160,7 @@ namespace aspect
142160
* then let these objects read their parameters as well.
143161
*/
144162
void
145-
parse_parameters (ParameterHandler &prm);
163+
parse_parameters (ParameterHandler &prm) override;
146164

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

193211
private:
212+
/**
213+
* A list of boundary indicators that indicate for
214+
* each plugin in the list of plugin_objects which boundary id
215+
* it is responsible for. By default each plugin
216+
* is active for all boundaries, but this list
217+
* can be modified by derived classes to limit the application
218+
* of plugins to specific boundaries.
219+
*/
220+
std::vector<types::boundary_id> boundary_indicators;
221+
222+
/**
223+
* A list of boundary indicators that indicate for
224+
* each plugin in the list of plugin_objects which components
225+
* it is responsible for. By default each plugin
226+
* is active for all components, but this list
227+
* can be modified by derived classes to limit the application
228+
* of plugins to specific boundaries.
229+
*/
230+
std::vector<ComponentMask> component_masks;
231+
232+
/**
233+
* A set of boundary indicators, on which tractions are prescribed.
234+
*/
235+
std::set<types::boundary_id> prescribed_traction_boundary_indicators;
236+
194237
/**
195238
* A list of boundary traction objects that have been requested in the
196239
* parameter file.
240+
*
241+
* @deprecated This variable is no longer used, but needed to issue a proper
242+
* error message in the function get_active_boundary_traction_conditions().
197243
*/
198244
std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryTraction::Interface<dim>>>> boundary_traction_objects;
199245

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

include/aspect/boundary_velocity/interface.h

+84-21
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,9 @@ namespace aspect
7777
* @ingroup BoundaryVelocities
7878
*/
7979
template <int dim>
80-
class Manager : public SimulatorAccess<dim>
80+
class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
8181
{
8282
public:
83-
/**
84-
* Destructor. Made virtual since this class has virtual member
85-
* functions.
86-
*/
87-
~Manager () override;
88-
89-
/**
90-
* A function that is called at the beginning of each time step and
91-
* calls the corresponding functions of all created plugins.
92-
*
93-
* The point of this function is to allow complex boundary velocity
94-
* models to do an initialization step once at the beginning of each
95-
* time step. An example would be a model that needs to call an
96-
* external program to compute the velocity change at a boundary.
97-
*/
98-
virtual
99-
void
100-
update ();
101-
10283
/**
10384
* A function that calls the boundary_velocity functions of all the
10485
* individual boundary velocity objects and uses the stored operators
@@ -144,7 +125,11 @@ namespace aspect
144125
* If there are no prescribed boundary velocity plugins
145126
* for a particular boundary, this boundary identifier will not appear
146127
* in the map.
128+
*
129+
* @deprecated This function will be removed. Use the function
130+
* get_active_plugin_names() of the base class ManagerBase instead.
147131
*/
132+
DEAL_II_DEPRECATED
148133
const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> &
149134
get_active_boundary_velocity_names () const;
150135

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

152+
/**
153+
* Return a list of boundary indicators that indicate for
154+
* each active plugin which boundary id
155+
* it is responsible for. The list of active plugins can be
156+
* requested by calling get_active_plugins().
157+
*/
158+
const std::vector<types::boundary_id> &
159+
get_active_plugin_boundary_indicators() const;
160+
161+
/**
162+
* Return a component mask that indicates for the given
163+
* @p boundary_id which velocity components are prescribed by
164+
* this manager class. All plugins that are responsible
165+
* for this boundary use the same component mask.
166+
* The list of plugin objects can be
167+
* requested by calling get_active_plugins() and the
168+
* list of boundaries they are responsible for is
169+
* returned by get_active_plugin_boundary_indicators().
170+
*/
171+
ComponentMask
172+
get_component_mask(const types::boundary_id boundary_id) const;
173+
174+
/**
175+
* Return a set of boundary indicators for which boundary
176+
* velocities are prescribed.
177+
*/
178+
const std::set<types::boundary_id> &
179+
get_prescribed_boundary_velocity_indicators () const;
180+
163181
/**
164182
* Return a list of boundary ids on which the velocity is prescribed
165183
* to be zero (no-slip).
@@ -188,7 +206,7 @@ namespace aspect
188206
* then let these objects read their parameters as well.
189207
*/
190208
void
191-
parse_parameters (ParameterHandler &prm);
209+
parse_parameters (ParameterHandler &prm) override;
192210

193211
/**
194212
* Go through the list of all boundary velocity models that have been selected
@@ -198,9 +216,15 @@ namespace aspect
198216
*
199217
* This function can only be called if the given template type (the first template
200218
* argument) is a class derived from the Interface class in this namespace.
219+
*
220+
* @deprecated Instead of this function, use the
221+
* Plugins::ManagerBase::has_matching_active_plugin() and
222+
* Plugins::ManagerBase::get_matching_active_plugin() functions of the base
223+
* class of the current class.
201224
*/
202225
template <typename BoundaryVelocityType,
203226
typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
227+
DEAL_II_DEPRECATED
204228
bool
205229
has_matching_boundary_velocity_model () const;
206230

@@ -214,9 +238,15 @@ namespace aspect
214238
*
215239
* This function can only be called if the given template type (the first template
216240
* argument) is a class derived from the Interface class in this namespace.
241+
*
242+
* @deprecated Instead of this function, use the
243+
* Plugins::ManagerBase::has_matching_active_plugin() and
244+
* Plugins::ManagerBase::get_matching_active_plugin() functions of the base
245+
* class of the current class.
217246
*/
218247
template <typename BoundaryVelocityType,
219248
typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
249+
DEAL_II_DEPRECATED
220250
const BoundaryVelocityType &
221251
get_matching_boundary_velocity_model () const;
222252

@@ -243,9 +273,32 @@ namespace aspect
243273
<< arg1
244274
<< "> among the names of registered boundary velocity objects.");
245275
private:
276+
/**
277+
* A list of boundary indicators that indicate for
278+
* each plugin in the list of plugin_objects which boundary id
279+
* it is responsible for. By default each plugin
280+
* is active for all boundaries, but this list
281+
* can be modified by derived classes to limit the application
282+
* of plugins to specific boundaries.
283+
*/
284+
std::vector<types::boundary_id> boundary_indicators;
285+
286+
/**
287+
* A list of boundary indicators that indicate for
288+
* each plugin in the list of plugin_objects which components
289+
* it is responsible for. By default each plugin
290+
* is active for all components, but this list
291+
* can be modified by derived classes to limit the application
292+
* of plugins to specific boundaries.
293+
*/
294+
std::vector<ComponentMask> component_masks;
295+
246296
/**
247297
* A list of boundary velocity objects that have been requested in the
248298
* parameter file.
299+
*
300+
* @deprecated This variable is no longer used, but needed to issue a proper
301+
* error message in the function get_active_boundary_velocity_conditions().
249302
*/
250303
std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> boundary_velocity_objects;
251304

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

320+
/**
321+
* A set of boundary indicators, on which velocities are prescribed.
322+
*/
323+
std::set<types::boundary_id> prescribed_velocity_boundary_indicators;
324+
262325
/**
263326
* A set of boundary indicators, on which velocities are prescribed to
264327
* zero (no-slip).

include/aspect/parameters.h

-8
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,6 @@ namespace aspect
635635
bool enable_additional_stokes_rhs;
636636
bool enable_prescribed_dilation;
637637

638-
/**
639-
* Map from boundary id to a pair "components", "traction boundary type",
640-
* where components is of the format "[x][y][z]" and the traction type is
641-
* mapped to one of the plugins of traction boundary conditions (e.g.
642-
* "function")
643-
*/
644-
std::map<types::boundary_id, std::pair<std::string,std::string>> prescribed_traction_boundary_indicators;
645-
646638
/**
647639
* A set of boundary ids on which the boundary_heat_flux objects
648640
* will be applied.

include/aspect/plugins.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
#include <deal.II/base/utilities.h>
2828
#include <deal.II/base/parameter_handler.h>
29-
#include <tuple>
3029
#include <deal.II/base/exceptions.h>
30+
#include <deal.II/fe/component_mask.h>
3131

3232
#include <boost/core/demangle.hpp>
3333

34+
#include <tuple>
3435
#include <string>
3536
#include <list>
3637
#include <set>

source/boundary_traction/ascii_data.cc

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ namespace aspect
3535
void
3636
AsciiData<dim>::initialize ()
3737
{
38-
for (const auto &bv : this->get_boundary_traction_manager().get_active_boundary_traction_conditions())
38+
unsigned int i=0;
39+
for (const auto &plugin : this->get_boundary_traction_manager().get_active_plugins())
3940
{
40-
for (const auto &plugin : bv.second)
41-
if (plugin.get() == this)
42-
boundary_ids.insert(bv.first);
41+
if (plugin.get() == this)
42+
boundary_ids.insert(this->get_boundary_traction_manager().get_active_plugin_boundary_indicators()[i]);
43+
44+
++i;
4345
}
44-
AssertThrow(*(boundary_ids.begin()) != numbers::invalid_boundary_id,
46+
47+
AssertThrow(boundary_ids.empty() == false,
4548
ExcMessage("Did not find the boundary indicator for the traction ascii data plugin."));
4649

4750
Utilities::AsciiDataBoundary<dim>::initialize(boundary_ids,

0 commit comments

Comments
 (0)