-
Notifications
You must be signed in to change notification settings - Fork 242
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
Added coordinate systems to Gravity model function plug-in #5752
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.
Very nice! Just some minor suggestions for improvements. I have one request though, and that is to also add a test where the gravity depends on depth. Just to make sure all options for the coordinate system are covered.
@@ -0,0 +1,3 @@ | |||
Added: The Function expression plug-in for the Gravity model can now evaluate functions in multiple coordinate systems. The plug-in was ammended to read in entries to the "Coordinate system" parameter in the Function subsection and Gravity Model section of the parameter file. There are two added tests for the Gravity model function plug-in to ensure the cartesian and spherical functions evaluate as expected in a 2D cylindrical annulus. |
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.
Added: The Function expression plug-in for the Gravity model can now evaluate functions in multiple coordinate systems. The plug-in was ammended to read in entries to the "Coordinate system" parameter in the Function subsection and Gravity Model section of the parameter file. There are two added tests for the Gravity model function plug-in to ensure the cartesian and spherical functions evaluate as expected in a 2D cylindrical annulus. | |
Added: The Function expression plug-in for the Gravity model can now evaluate functions in multiple coordinate systems. The plug-in was amended to read in entries to the "Coordinate system" parameter in the Function subsection and Gravity Model section of the parameter file. There are two added tests for the Gravity model function plug-in to ensure the cartesian and spherical functions evaluate as expected in a 2D cylindrical annulus. |
What about a test for the depth
option?
source/gravity_model/function.cc
Outdated
for (unsigned int d=0; d<dim; ++d) | ||
gravity[d] = function.value(position,d); | ||
gravity[d] = function.value(Utilities::convert_array_to_point<dim>(point.get_coordinates()),d); |
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.
Your code is not wrong, but this one will be slightly faster, because some computations will be done only once instead of dim
times:
const Point<dim> point_in_coordinate_system = Utilities::convert_array_to_point<dim>(point.get_coordinates());
for (unsigned int d=0; d<dim; ++d)
gravity[d] = function.value(point_in_coordinates,d);
source/gravity_model/function.cc
Outdated
/** | ||
* Choose the coordinates to evaluate the maximum refinement level | ||
* function. The function can be declared in dependence of depth, | ||
* cartesian coordinates or spherical coordinates. Note that the order | ||
* of spherical coordinates is r,phi,theta and not r,theta,phi, since | ||
* this allows for dimension independent expressions. | ||
*/ |
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 all this. The declare_entry
function already receives a lot of documentation about what this parameter means, so this comment is duplicating information.
tests/gravity_model_cartesian.prm
Outdated
# This setup is a copy of the | ||
# benchmarks/onset-of-convection/convection-box-base.prm | ||
# contributed by Max Rudolph, with the difference that | ||
# parameter values are specified explicitly in the input file | ||
# (rather than through an ipython notebook). |
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.
I dont think the detailed reference to the benchmark cookbook here is necessary. You have modified this file quite a bit and it serves a different purpose. It would be more useful to describe the purpose of this test, e.g. something like:
This is a test based on benchmarks/onset-of-convection/convection-box-base.prm. It makes sure that the gravity plugin 'function' works correctly for a Cartesian coordinate system.
tests/gravity_model_spherical.prm
Outdated
@@ -0,0 +1,100 @@ | |||
# This setup is a copy of the |
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.
Same comment as for the other test.
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.
Looks pretty good. Find me tomorrow to talk about how to fix the tester results.
* The coordinate representation to evaluate the function. Possible | ||
* choices are depth, cartesian and spherical. | ||
*/ | ||
Utilities::Coordinates::CoordinateSystem coordinate_system; |
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.
I think you need to add #include <aspect/utilities.h>
so that ASPECT knows what a coordinate system is. Talk to me tomorrow if you want to know why it is not a problem on your laptop, but it is for the tester.
fde7be8
to
5588b37
Compare
/rebuild |
Many thanks @KerrMadeleine! 🎉 |
The function expression plug-in for the gravity model can now evaluate in multiple coordinate systems. The plug-in was amended to take in the coordinate system variable by reading the "Coordinate system" parameter in the Function subsection and Gravity Model section of the parameter file. There are two added tests for the Gravity model function plug-in to ensure the cartesian and spherical functions evaluate as expected in a 2D cylindrical annulus.