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
Allowing multiple traction models for a boundary #5220
Conversation
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.
This goes into the right direction. I have just left some large-scale comments for now, I will take a closer look when you have addressed these comments. Let me know when you have addressed them.
// ------------------------------ Manager ----------------------------- | ||
// -------------------------------- Deal with registering boundary_traction models and automating | ||
// -------------------------------- their setup and selection at run time | ||
// just copy and paste mangaer class from boundary-velocity/interface.cc from line 66 -428 {need to change the descriptions....} |
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.
This type of documentation should be in the header file following the same format as the other documentation strings there.
"may have provided for each part of the boundary. You may want " | ||
"to compare this with the documentation of the geometry model you " | ||
"use in your model."); | ||
// prm.declare_entry ("Tangential velocity boundary indicators", "", |
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.
One of our conventions is to never leave commented code in the repository. In the future it will not be possible to determine why this code is commented. Is it work in progress? Is it outdated? Is it wrong?
We dont need this code, so just remove the whole commented section. Here, and in all other places of your changes.
* 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 |
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.
You still reference the velocity in many places of the header and the source file. The simplest way to fix this is to search for velocity and replace it with traction in all places you find it (you can use ctrl+f in VS code to do this quite quick).
* The point of this function is to allow complex boundary velocity | |
* The point of this function is to allow complex boundary traction |
// explicit instantiations | ||
namespace aspect | ||
{ | ||
namespace internal | ||
{ | ||
namespace Plugins | ||
{ | ||
template <> | ||
std::list<internal::Plugins::PluginList<BoundaryTraction::Interface<2>>::PluginInfo> * | ||
internal::Plugins::PluginList<BoundaryTraction::Interface<2>>::plugins = nullptr; | ||
template <> | ||
std::list<internal::Plugins::PluginList<BoundaryTraction::Interface<3>>::PluginInfo> * | ||
internal::Plugins::PluginList<BoundaryTraction::Interface<3>>::plugins = nullptr; | ||
} | ||
} | ||
|
||
namespace BoundaryTraction | ||
{ | ||
#define INSTANTIATE(dim) \ | ||
template class Interface<dim>; \ | ||
template class Manager<dim>; | ||
|
||
ASPECT_INSTANTIATE(INSTANTIATE) | ||
|
||
#undef INSTANTIATE |
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.
There is already a section further down in this file labeled #explicit instantiations
. Give it a try to merge your changes here with that section further down and find me if you run into problems.
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.
A few more comments. After you have addressed them, find me and we can talk about how to change the core of ASPECT (the Simulator class) to use the new manager class.
@@ -125,7 +125,181 @@ namespace aspect | |||
*/ | |||
const GeometryModel::Interface<dim> *geometry_model; | |||
}; | |||
template <int dim> |
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.
* 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 comment
The 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 boundary_traction
function has a slightly different interface. In particular it takes a third argument that indicates the normal direction on the current boundary. You will have to add this here as an additional argument as well, otherwise the manager cannot call the respective function of the individual plugins.
*/ | ||
static | ||
void | ||
register_boundary_traction (const std::string &name, |
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.
Now that you have this function inside the manager class you can remove the other register_boundary_traction function below (and the function implementation in the source file).
* Return a list of boundary ids on which the traction is prescribed | ||
* to be zero (no-slip). | ||
*/ | ||
const std::set<types::boundary_id> & | ||
get_zero_boundary_traction_indicators () const; |
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.
There is nothing like this for the boundary traction (a zero boundary traction plugin just returns a traction of 0, it is not in any way special). Remove this function here and in the source file.
/** | ||
* A set of boundary indicators, on which velocities are prescribed to | ||
* zero (no-slip). | ||
*/ | ||
std::set<types::boundary_id> zero_traction_boundary_indicators; |
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.
No need to keep this variable.
"Note that the no-slip boundary condition is " | ||
"a special case of the current one where the prescribed traction " | ||
"happens to be zero. It can thus be implemented by indicating that " | ||
"a particular boundary is part of the ones selected " | ||
"using the current parameter and using ``zero traction'' as " | ||
"the boundary values. Alternatively, you can simply list the " | ||
"part of the boundary on which the traction is to be zero with " | ||
"the parameter ``Zero traction boundary indicator'' in the " | ||
"current parameter section." |
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.
This part does not apply anymore.
"Note that when ``Use years in output instead of seconds'' is set " | ||
"to true, traction should be given in m/yr. " |
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.
This needs to be updated to the unit of tractions (N/m^2)
prm.declare_entry ("Zero traction boundary indicators", "", | ||
Patterns::List (Patterns::Anything()), | ||
"A comma separated list of names denoting those boundaries " | ||
"on which the traction is zero." | ||
"\n\n" | ||
"The names of the boundaries listed here can either by " | ||
"numbers (in which case they correspond to the numerical " | ||
"boundary indicators assigned by the geometry object), or they " | ||
"can correspond to any of the symbolic names the geometry object " | ||
"may have provided for each part of the boundary. You may want " | ||
"to compare this with the documentation of the geometry model you " | ||
"use in your model."); |
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.
remove this here, and in the parse_parameters
function below.
@chameerasilva I fixed some of the remaining complicated compiler messages. There are still some more left for you to work on. You can pull the changes of this branch from github into your local branch. Find me if you need help with that. |
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.
Thank you this looks quite good already. I left a lot of small comments, mostly related to code style. Please address these. Also because we are removing a function that was available for all users before, we should add an entry into the ASPECT changelog (see https://aspect.geodynamics.org/doc/doxygen/changes_current.html). Take a look at the directory doc/modules/changes, copy one of the files in there, replace the names, dates, and content with a description that describes what we did in this pull request.
<< "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 comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line here:
/** | |
/** |
/** | ||
* A function that is used to register boundary traction objects in such | ||
* a way that the Manager can deal with all of them without having to | ||
* know them by name. This allows the files in which individual | ||
* plugins are implemented to register these plugins, rather than also | ||
* having to modify the Manager class by adding the new boundary | ||
* traction plugin class. | ||
* | ||
* @param name A string that identifies the boundary traction 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 boundary traction model | ||
* wants to read from input files. | ||
* @param factory_function A pointer to a function that can create an | ||
* object of this boundary traction model. | ||
*/ |
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.
This documentation does not belong to this function. Delete it and copy over the documentation of the same function from the boundary velocity manager and adjust for traction boundaries.
if (bv.second.get() == this) | ||
boundary_ids.insert(bv.first); | ||
|
||
for (const auto &bv : this->get_boundary_traction_manager ().get_active_boundary_traction_conditions ()) |
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.
remove the spaces between function name and parentheses:
for (const auto &bv : this->get_boundary_traction_manager ().get_active_boundary_traction_conditions ()) | |
for (const auto &bv : this->get_boundary_traction_manager().get_active_boundary_traction_conditions()) |
@@ -47,10 +47,11 @@ namespace aspect | |||
// Ensure the initial lithostatic pressure traction boundary conditions are used, | |||
// and register for which boundary indicators these conditions are set. | |||
std::set<types::boundary_id> traction_bi; | |||
for (const auto &p : this->get_boundary_traction()) | |||
for (const auto &p : this->get_boundary_traction_manager ().get_active_boundary_traction_conditions ()) |
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.
as above:
for (const auto &p : this->get_boundary_traction_manager ().get_active_boundary_traction_conditions ()) | |
for (const auto &p : this->get_boundary_traction_manager().get_active_boundary_traction_conditions()) |
@@ -60,9 +60,22 @@ namespace aspect | |||
Interface<dim>::parse_parameters (dealii::ParameterHandler &) | |||
{} | |||
|
|||
template <int dim> |
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.
We use three empty lines between functions in .cc files (one empty line in .h files):
template <int dim> | |
template <int dim> |
source/simulator/melt.cc
Outdated
.find (face->boundary_id()) | ||
!= | ||
this->get_boundary_traction().end()) | ||
this->get_boundary_traction_manager ().get_active_boundary_traction_names().end()) |
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.
this->get_boundary_traction_manager ().get_active_boundary_traction_names().end()) | |
this->get_boundary_traction_manager().get_active_boundary_traction_names().end()) |
source/simulator/melt.cc
Outdated
->boundary_traction (face->boundary_id(), | ||
scratch.face_finite_element_values.quadrature_point(q), | ||
scratch.face_finite_element_values.normal_vector(q)); | ||
= this->get_boundary_traction_manager (). |
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.
= this->get_boundary_traction_manager (). | |
= this->get_boundary_traction_manager(). |
source/simulator/melt.cc
Outdated
@@ -1678,7 +1676,7 @@ namespace aspect | |||
std::make_unique<aspect::Assemblers::MeltStokesSystemBoundary<dim>>()); | |||
|
|||
// add the terms for traction boundary conditions | |||
if (!this->get_boundary_traction().empty()) | |||
if (!this->get_boundary_traction_manager ().get_active_boundary_traction_names().empty()) |
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.
if (!this->get_boundary_traction_manager ().get_active_boundary_traction_names().empty()) | |
if (!this->get_boundary_traction_manager().get_active_boundary_traction_names().empty()) |
source/simulator/newton.cc
Outdated
@@ -98,7 +98,7 @@ namespace aspect | |||
" defined that handles this formulation.")); | |||
|
|||
// add the terms for traction boundary conditions | |||
if (!this->get_boundary_traction().empty()) | |||
if (!this->get_boundary_traction_manager ().get_active_boundary_traction_names ().empty()) |
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.
if (!this->get_boundary_traction_manager ().get_active_boundary_traction_names ().empty()) | |
if (!this->get_boundary_traction_manager().get_active_boundary_traction_names().empty()) |
tests/traction_multiple_model.prm
Outdated
subsection Boundary traction model | ||
set Prescribed traction boundary indicators = 0:ascii data, 0:function | ||
end | ||
|
||
subsection Boundary traction model | ||
subsection Function | ||
set Variable names = x,y | ||
|
||
# The following line is the stress applied to the side boundaries (in Pa) | ||
set Function constants = stress=2000e6 | ||
set Function expression = if (y>600e3 ,-stress,0); 0 | ||
end | ||
end | ||
subsection Boundary velocity model | ||
set Tangential velocity boundary indicators = 1,2,3 | ||
end | ||
|
||
subsection Boundary traction model | ||
subsection Ascii data model | ||
set Data directory =$ASPECT_SOURCE_DIR/data/boundary-traction/ascii-data/test/ | ||
end |
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.
You have three occurrences of subsection Boundary traction model
here. Please merge all of them into one subsection (one subsection Boundary traction model
.... end
block).
a0043f9
to
ef430a3
Compare
No description provided.