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

Allow different boundary temperature plugins on different boundaries #2051

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gassmoeller
Copy link
Member

This sits on top of #2044 and does the same thing for boundary temperature plugins. Now, one can select different boundary temperature plugins for different boundaries in the same style and input format as for velocities. I still want to make the parsing a bit more intuitive by allowing to only specify plugin names (that are then used for all boundaries) and not only pairs of boundaries and plugins, but this gets a bit complicated due to backwards compatibility to the current system, where a single entry is interpreted as a boundary id (not a plugin name). I need to do some more work on the parsing and documentation before this is finished.

@bangerth
Copy link
Contributor

bangerth commented Jan 9, 2018

Let me know once you have this rebased after merging #2044.

@gassmoeller gassmoeller force-pushed the extend_boundary_temperature_manager branch from 0864574 to c907ea7 Compare January 10, 2018 00:00
@gassmoeller gassmoeller added this to the 2.0 milestone Jan 30, 2018
@gassmoeller gassmoeller force-pushed the extend_boundary_temperature_manager branch 5 times, most recently from 4569c47 to 66eef39 Compare February 15, 2018 22:55
@gassmoeller gassmoeller changed the title [WIP] Allow different boundary temperature plugins on different boundaries Allow different boundary temperature plugins on different boundaries Feb 15, 2018
@gassmoeller
Copy link
Member Author

This should be ready for review. I recommend reviewing in 'split' mode, as much of interface.cc has changed. On the upside I was able to remove several deprecated things, so that the new structure looks actually simpler than before. The only complicated part is the Manager::parse_parameters function which figures out which plugins to use on which boundaries.

* The point of this function is to allow complex boundary temperature
* 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 temperature change at a boundary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to remove this comment?

boundary_temperature (const types::boundary_id boundary_indicator,
const Point<dim> &position) const;
const std::vector<std_cxx11::shared_ptr<Interface<dim> > > &
get_active_boundary_temperature_conditions () const;

/**
* Return the minimal temperature of all selected plugins on that
* part of the boundary on which Dirichlet conditions are posed.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is no longer accurate (and hasn't been for a while). That's because it's not that part of the boundary on which Dirichlet conditions are posed, but in fact that subset of Dirichlet boundaries with indicators given by the argument list. While you're here, can you update this? Or maybe leave it for a follow-up, if you prefer given that this likely shows up in a number of places -- in that case, just open an issue.

= std::set<types::boundary_id>()) const;
double
maximal_temperature (const std::set<types::boundary_id> &fixed_boundary_ids
= std::set<types::boundary_id>()) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this function.

= std::set<types::boundary_id>()) const;

/**
* A function that calls the boundary_temperature functions of all the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the indentation of the comment here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, if you write it as boundary_temperature() (with parens) then doxygen will automatically link to it

}



template <int dim>
double
Manager<dim>::boundary_temperature (const types::boundary_id boundary_indicator,
const Point<dim> &position) const
Manager<dim>::minimal_temperature (const std::set<types::boundary_id> &/*fixed_boundary_ids*/) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, this negates my comment on the documentation of the function -- the function apparently ignores its argument. is this intended? If so, this is not a virtual function, so it's not possible to overload it, and if the only existing implementation ignores the argument, why not drop it altogether?

@@ -200,13 +135,15 @@ namespace aspect

template <int dim>
double
Manager<dim>::minimal_temperature (const std::set<types::boundary_id> &fixed_boundary_ids) const
Manager<dim>::maximal_temperature (const std::set<types::boundary_id> &/*fixed_boundary_ids*/) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, of course

AssertThrow(false,
ExcMessage ("ASPECT only accepts the following operators: "
"add, subtract, minimum and maximum. But your parameter file "
"contains: " + operation + ". Please check your parameter file.") );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just write this as

  "contains <" + operation + ">. Please check..."

for consistency with other places.

In some places, we pass the name of the parameter where this happened to similar functions (e..g., to possibly_extend_1_to_N()) so that it's easier to find the location where this happened in the input file. Could we do the same here?

parameters.fixed_temperature_boundary_indicators.erase(bottom);
std::set<types::boundary_id> &temperature_boundary_ids =
const_cast<std::set<types::boundary_id> &> (simulator_access.get_boundary_temperature_manager().get_fixed_temperature_boundary_indicators());
temperature_boundary_ids.erase(bottom);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, if this was anywhere other than in a test, I'd be quite unhappy about such a trick :-)

@gassmoeller
Copy link
Member Author

I addressed most issues. About your comments:

First comment: I removed the part about the purpose, because it is not happening in this function. The Manager::update function only calls all the update functions of the plugins, and I did not want to duplicate the documentation too much. Would you prefer to keep the paragraph?

I updated the documentation and implementation of the minimal_temperature and maximal_temperature functions to do what they were meant to do. I do not like those functions though, and would vote for deprecating and at some point removing them (maybe replacing them by a representative_surface_temperature and representative_bottom_temperature function in the manager class). I will open a separate issue about that.

I added a parameter to the create_model_operator_list function to indicate the wrong input parameter.

Last comment: I am also not happy about this. Problem is that the test tested functionality that is now not longer easily available. The parameter to change is not longer a member of Parameters, but only Parameters is handed over as writable reference. I am not sure what to do here. It is a pretty exotic case though (removing a boundary condition during the model run).

@gassmoeller gassmoeller force-pushed the extend_boundary_temperature_manager branch from ce75622 to 1c06bc1 Compare February 26, 2018 23:52
@gassmoeller gassmoeller force-pushed the extend_boundary_temperature_manager branch from 1c06bc1 to 8771bf9 Compare March 7, 2018 03:21
@gassmoeller gassmoeller force-pushed the extend_boundary_temperature_manager branch from 8771bf9 to 2da2617 Compare March 7, 2018 03:23
@gassmoeller gassmoeller force-pushed the extend_boundary_temperature_manager branch from 2da2617 to 3af7d82 Compare March 7, 2018 11:05
Copy link
Contributor

@jdannberg jdannberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't unerstand all of the technical details, but I guess as @bangerth has already looked at this, this is fine.
@bangerth, as @gassmoeller already addressed your comments, is this okay from your side?

@gassmoeller: You need to add a changelog entry. And I'll add this to the list of cookbooks we need, because I feel this is really not intuitive to understand without an example. Do you think it would be worth it to add a short section to the manual, just to explain the syntax?

* A map between fixed_temperature_boundary_indicators and one or more
* indices into the boundary_temperature_names,
* boundary_temperature_objects, and boundary_temperature_operators vectors.
* This variable stores which plugins are active for which boundary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused how this works. Can you extend the comment a bit and explain how this is structured (how do I know what this second index is for; boundary_temperature_name, boundary_temperature_object, or boundary_temperature_operator)?

"but not explicitly listed here will end up with no-flux "
"(insulating) boundary conditions."
"\n\n"
"The names of the boundaries listed here can either by "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by --> be?

"compute the boundary temperature. If only one plugin is given, "
"only this plugin is used. The same boundary identifier can "
"appear multiple times with different plugin names, in which "
"case all given plugins will be combined to compute the boundary "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a sentence to make it more clear that this is the only way to assign more than one plugin to a boundary, because it would not work to write 'boundary identifier : plugin name 1, plugin name 2'. By the way, the only reason that this does not work is that if there is a comma in the list, we do not know if the thing after it is a new boundary indicator or another plugin, right? So what about allowing something like 'boundary identifier : [plugin name 1, plugin name 2]'? I feel that would be much easier to read in the input file than 'boundary identifier : plugin name 1, boundary identifier : plugin name 2', and this way you could check again if any of the indicators is present in the list twice, and let the user know, so it would be less error prone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about this for a while, I guess the most reasonable approach I see would be to change this format to allow something like:

set Fixed temperature boundary indicators = top : box & function & constant, left : box & initial temperature, bottom

If there is no colon, all plugins are applied (as it is right now, so it's backwards compatible). I guess that means duplicating the list of plugins in the 'List of model names' parameter, but I don't really see any other way to do this, and it would only come up in complex models.

So I guess the only other question we have to think about here is: Do we ever want to allow having the same kind of plugin, but with different parameters, for different boundaries (like 2 different functions)? Because I don't really see how we would put that into this framework, so we would essentially say that this is someting we do not want to change in the near future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at this since my last review, but just about the format: instead of & we've generally used ; as a top-level separator between entries I believe.

"on which the temperature is fixed and described by the "
"boundary temperature objects selected in the "
"<Boundary temperature model/List of model names> parameter "
"of this input file. All boundary indicators used by the geometry "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question: With this new format, is there still a reason to even have the section Boundary temperature model/List of model names other than backwards compatibility? Or in other words, should we also allow users to put in boundary temperature plugins here that they have not selected in the List of model names? This way, we could deprecate the other parameter and remove it at some point, and we would end up with the same format for the temperature and the velocity boundary conditions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I see, you need it to apply the operators. So do we have plans for the future to allow several plugins for the velocity boundary conditions too? Because then I guess it would make sense to think about a format that would work for all three (temperature, composition, velocity).

prm.leave_subsection();

// Now create and initialize all of the requested models. We can only do this here at the end,
// because some models might ask, which boundary they are responsible for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comma

@@ -123,7 +123,8 @@ namespace aspect
Utilities::possibly_extend_from_1_to_N (Utilities::split_string_list(prm.get("List of model operators")),
model_names.size(),
"List of model operators");
model_operators = Utilities::create_model_operator_list(model_operator_names);
model_operators = Utilities::create_model_operator_list(model_operator_names,
"Boundary composition model/List of model operators");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be initial temperature, not boundary composition, right? And maybe add a test for that if we haven't caught this with any of the existing tests?

{
AssertThrow(false,
ExcMessage ("ASPECT only accepts the following operators: "
"add, subtract, minimum and maximum. But your parameter file "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to get the operators we allow from the Operator object instead of spelling them out by hand? This would allow adding operators in the future without having to change the error message by hand (which we might forget).

@@ -272,17 +275,6 @@ namespace aspect
"will be used to append the listed temperature models onto "
"the previous models. If only one operator is given, "
"the same operator is applied to all models.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this doesn't have anything to do with your pull request, but can you please add a sentence here (and in other places where we declare these operators), that this list of operators has to be exactly as long as the list of plugins (if it doesn't have just one entry), and that the order has to be the same as in the 'List of model names' because each operator will be applied to a plugin according to the order they're given in.

@gassmoeller
Copy link
Member Author

Same as #2099, lets postpone this after 2.0.

@gassmoeller gassmoeller removed this from the 2.0 milestone Apr 10, 2018
@bangerth
Copy link
Contributor

@gassmoeller: What's the status here? Can you rebase and should I then take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants