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
Allowing multiple traction models for a boundary #5220
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Changed: Boundary traction models are now allowed to combine | ||
and used for single boundary. | ||
<br> | ||
(Chameera Silva, Rene Gassmoeller, 2023/07/13) |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -126,31 +126,168 @@ namespace aspect | |||||||
const GeometryModel::Interface<dim> *geometry_model; | ||||||||
}; | ||||||||
|
||||||||
template <int dim> | ||||||||
class Manager : public ::aspect::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. | ||||||||
*/ | ||||||||
Tensor<1,dim> | ||||||||
boundary_traction (const types::boundary_id boundary_indicator, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you will have to change something compared to the velocity manager. Take a look at line 100 of this file, the |
||||||||
const Point<dim> &position, | ||||||||
const Tensor<1,dim> &normal_vector) const; | ||||||||
|
||||||||
/** | ||||||||
* Register a traction boundary conditions model so that it can be | ||||||||
* selected from the parameter file. | ||||||||
* | ||||||||
* @param name A string that identifies the traction boundary conditions | ||||||||
* model | ||||||||
* @param description A text description of what this model does and that | ||||||||
* will be listed in the documentation of the parameter file. | ||||||||
* @param declare_parameters_function A pointer to a function that can be | ||||||||
* used to declare the parameters that this traction boundary conditions | ||||||||
* model wants to read from input files. | ||||||||
* @param factory_function A pointer to a function that can create an | ||||||||
* object of this traction boundary conditions model. | ||||||||
* | ||||||||
* @ingroup BoundaryTractions | ||||||||
*/ | ||||||||
template <int dim> | ||||||||
void | ||||||||
register_boundary_traction (const std::string &name, | ||||||||
const std::string &description, | ||||||||
void (*declare_parameters_function) (ParameterHandler &), | ||||||||
std::unique_ptr<Interface<dim>> (*factory_function) ()); | ||||||||
/** | ||||||||
* Return the names of all prescribed boundary traction models currently | ||||||||
* used in the computation as specified in the input file. The function | ||||||||
* returns a map between a boundary identifier and a pair. The | ||||||||
* first part of the pair is a string that represents the prescribed | ||||||||
* traction components on this boundary (e.g. y, xz, or xyz) and the | ||||||||
* second part is a vector of strings that represent the names of | ||||||||
* boundary traction plugins for this boundary. | ||||||||
* If there are no prescribed boundary traction plugins | ||||||||
* for a particular boundary, this boundary identifier will not appear | ||||||||
* in the map. | ||||||||
*/ | ||||||||
const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> & | ||||||||
get_active_boundary_traction_names () const; | ||||||||
|
||||||||
/** | ||||||||
* Return pointers to all boundary traction models | ||||||||
* currently used in the computation, as specified in the input file. | ||||||||
* The function returns a map between a boundary identifier and a vector | ||||||||
* of unique pointers that represent the names of prescribed traction | ||||||||
* 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. | ||||||||
*/ | ||||||||
const std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryTraction::Interface<dim>>>> & | ||||||||
get_active_boundary_traction_conditions () const; | ||||||||
|
||||||||
/** | ||||||||
* Declare the parameters of all known boundary traction plugins, as | ||||||||
* well as the ones this class has itself. | ||||||||
*/ | ||||||||
static | ||||||||
void | ||||||||
declare_parameters (ParameterHandler &prm); | ||||||||
|
||||||||
/** | ||||||||
* Read the parameters this class declares from the parameter file. | ||||||||
* This determines which boundary traction objects will be created; | ||||||||
* then let these objects read their parameters as well. | ||||||||
*/ | ||||||||
void | ||||||||
parse_parameters (ParameterHandler &prm); | ||||||||
|
||||||||
/** | ||||||||
* Go through the list of all boundary traction models that have been selected | ||||||||
* in the input file (and are consequently currently active) and return | ||||||||
* true if one of them has the desired type specified by the template | ||||||||
* argument. | ||||||||
*/ | ||||||||
template <typename BoundaryTractionType> | ||||||||
bool | ||||||||
has_matching_boundary_traction_model () const; | ||||||||
|
||||||||
/** | ||||||||
* Go through the list of all boundary traction models that have been selected | ||||||||
* in the input file (and are consequently currently active) and see | ||||||||
* if one of them has the type specified by the template | ||||||||
* argument or can be casted to that type. If so, return a reference | ||||||||
* to it. If no boundary traction model is active that matches the given type, | ||||||||
* throw an exception. | ||||||||
*/ | ||||||||
template <typename BoundaryTractionType> | ||||||||
const BoundaryTractionType & | ||||||||
get_matching_boundary_traction_model () const; | ||||||||
|
||||||||
/** | ||||||||
* For the current plugin subsystem, write a connection graph of all of the | ||||||||
* plugins we know about, in the format that the | ||||||||
* programs dot and neato understand. This allows for a visualization of | ||||||||
* how all of the plugins that ASPECT knows about are interconnected, and | ||||||||
* connect to other parts of the ASPECT code. | ||||||||
* | ||||||||
* @param output_stream The stream to write the output to. | ||||||||
*/ | ||||||||
static | ||||||||
void | ||||||||
write_plugin_graph (std::ostream &output_stream); | ||||||||
|
||||||||
|
||||||||
/** | ||||||||
* Exception. | ||||||||
*/ | ||||||||
DeclException1 (ExcBoundaryTractionNameNotFound, | ||||||||
std::string, | ||||||||
<< "Could not find entry <" | ||||||||
<< arg1 | ||||||||
<< "> among the names of registered boundary traction objects."); | ||||||||
|
||||||||
/** | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an empty line here:
Suggested change
|
||||||||
* Register a traction boundary conditions model so that it can be | ||||||||
* selected from the parameter file. | ||||||||
* | ||||||||
* @param name A string that identifies the traction boundary conditions | ||||||||
* model | ||||||||
* @param description A text description of what this model does and that | ||||||||
* will be listed in the documentation of the parameter file. | ||||||||
* @param declare_parameters_function A pointer to a function that can be | ||||||||
* used to declare the parameters that this traction boundary conditions | ||||||||
* model wants to read from input files. | ||||||||
* @param factory_function A pointer to a function that can create an | ||||||||
* object of this traction boundary conditions model. | ||||||||
* | ||||||||
* @ingroup BoundaryTractions | ||||||||
*/ | ||||||||
static | ||||||||
void | ||||||||
register_boundary_traction (const std::string &name, | ||||||||
const std::string &description, | ||||||||
void (*declare_parameters_function) (ParameterHandler &), | ||||||||
std::unique_ptr<Interface<dim>> (*factory_function) ()); | ||||||||
|
||||||||
private: | ||||||||
/** | ||||||||
* A list of boundary traction objects that have been requested in the | ||||||||
* parameter file. | ||||||||
*/ | ||||||||
std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryTraction::Interface<dim>>>> boundary_traction_objects; | ||||||||
|
||||||||
/** | ||||||||
* Map from boundary id to a pair | ||||||||
* ("components", list of "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"). If the components string is empty, it is assumed the | ||||||||
* plugins are used for all components. | ||||||||
*/ | ||||||||
std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> boundary_traction_indicators; | ||||||||
|
||||||||
}; | ||||||||
|
||||||||
/** | ||||||||
* A function that given the name of a model returns a pointer to an | ||||||||
|
@@ -214,10 +351,10 @@ namespace aspect | |||||||
namespace ASPECT_REGISTER_BOUNDARY_TRACTION_MODEL_ ## classname \ | ||||||||
{ \ | ||||||||
aspect::internal::Plugins::RegisterHelper<aspect::BoundaryTraction::Interface<2>,classname<2>> \ | ||||||||
dummy_ ## classname ## _2d (&aspect::BoundaryTraction::register_boundary_traction<2>, \ | ||||||||
dummy_ ## classname ## _2d (&aspect::BoundaryTraction::Manager<2>::register_boundary_traction, \ | ||||||||
name, description); \ | ||||||||
aspect::internal::Plugins::RegisterHelper<aspect::BoundaryTraction::Interface<3>,classname<3>> \ | ||||||||
dummy_ ## classname ## _3d (&aspect::BoundaryTraction::register_boundary_traction<3>, \ | ||||||||
dummy_ ## classname ## _3d (&aspect::BoundaryTraction::Manager<3>::register_boundary_traction, \ | ||||||||
name, description); \ | ||||||||
} | ||||||||
} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one empty line before the class. Our usual convention is to have one empty line between functions/classes in the header file and three empty lines between functions in the source .cc file.