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

Added coordinate systems to Gravity model function plug-in #5752

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

KerrMadeleine
Copy link
Contributor

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.

Copy link
Member

@gassmoeller gassmoeller left a 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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?

Comment on lines 44 to 45
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);
Copy link
Member

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);

Comment on lines 71 to 77
/**
* 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.
*/
Copy link
Member

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.

Comment on lines 1 to 5
# 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).
Copy link
Member

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.

@@ -0,0 +1,100 @@
# This setup is a copy of the
Copy link
Member

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.

Copy link
Member

@gassmoeller gassmoeller left a 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;
Copy link
Member

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.

@gassmoeller
Copy link
Member

/rebuild

@gassmoeller
Copy link
Member

Many thanks @KerrMadeleine! 🎉

@gassmoeller gassmoeller merged commit d19df55 into geodynamics:main Jun 6, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants