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

Generalize GridTools::rotate for arbitrary rotation axes. #12816

Merged
merged 2 commits into from Oct 20, 2021

Conversation

marcfehling
Copy link
Member

We have the Physics::Transformation::Rotations namespace which we can use the generalize the GridTools::rotate functions. Currently, the rotation matrices in GridTools::rotate are hard-coded.

I deprecated the old interface, in which you can specify the (Cartesian) rotation axis with an integer. Further, I removed some comments at the end of grid_tools.h which fixes the indentation of #include directives. This makes this PR looks way larger than it actually is.

I adjusted all tests to use the new function with the new interface. These tests only rotated triangulation around Cartesian axes. I can provide another test with an oblique orientation axis if you want to.

Further, the Physics::Transformation::Rotations::rotation_matrix_3d takes the axis parameter first and then the angle, while the GridTools::rotate function takes the angle first and then the axis. Shall we take the chance and unify the interface?

Copy link
Member

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Otherwise, looks OK to me.

include/deal.II/grid/grid_tools.h Outdated Show resolved Hide resolved
@marcfehling
Copy link
Member Author

marcfehling commented Oct 12, 2021

Adjusted this PR to have a unified interface between namespaces GridTools and Physics. We also now use Tensor as a parameter for the axis -- this will not break any user code, since Point objects will be implicitly converted.

@masterleinad
Copy link
Member

In file included from /Users/runner/work/dealii/dealii/source/base/symmetric_tensor.cc:20:
/Users/runner/work/dealii/dealii/include/deal.II/base/symmetric_tensor.templates.h:761:17: error: no matching function for call to 'rotation_matrix_3d'
            R = dealii::Physics::Transformations::Rotations::rotation_matrix_3d(
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/dealii/dealii/include/deal.II/physics/transformations.h:915:38: note: candidate function [with Number = double] not viable: cannot convert initializer list argument to 'const Tensor<1, 3, double>'
Physics::Transformations::Rotations::rotation_matrix_3d(
                                     ^
In file included from /Users/runner/work/dealii/dealii/source/base/symmetric_tensor.cc:20:
/Users/runner/work/dealii/dealii/include/deal.II/base/symmetric_tensor.templates.h:765:17: error: no matching function for call to 'rotation_matrix_3d'
            R = dealii::Physics::Transformations::Rotations::rotation_matrix_3d(
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/dealii/dealii/include/deal.II/physics/transformations.h:915:38: note: candidate function [with Number = double] not viable: cannot convert initializer list argument to 'const Tensor<1, 3, double>'
Physics::Transformations::Rotations::rotation_matrix_3d(
                                     ^
In file included from /Users/runner/work/dealii/dealii/source/base/symmetric_tensor.cc:20:
/Users/runner/work/dealii/dealii/include/deal.II/base/symmetric_tensor.templates.h:769:17: error: no matching function for call to 'rotation_matrix_3d'
            R = dealii::Physics::Transformations::Rotations::rotation_matrix_3d(
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/dealii/dealii/include/deal.II/physics/transformations.h:915:38: note: candidate function [with Number = double] not viable: cannot convert initializer list argument to 'const Tensor<1, 3, double>'
Physics::Transformations::Rotations::rotation_matrix_3d(
                                     ^
3 errors generated.

@marcfehling
Copy link
Member Author

/rebuild

@marcfehling
Copy link
Member Author

Adjusted this PR to have a unified interface between namespaces GridTools and Physics. We also now use Tensor as a parameter for the axis -- this will not break any user code, since Point objects will be implicitly converted.

Adjusting the interface for the Physics function broke the test physics/transformations-rotations_01 fixed in 70b14fb. Maybe we should leave the old Physics function then and deprecate it.

@marcfehling
Copy link
Member Author

Squashed the commits. Ready for final review.

doc/news/changes/incompatibilities/20211011Fehling Outdated Show resolved Hide resolved
include/deal.II/grid/grid_tools.h Outdated Show resolved Hide resolved
@@ -69,7 +70,7 @@ transform_grid(Triangulation<2> &tria, const unsigned int transform)
// second round: rotate
// triangulation
case 1:
GridTools::rotate(3.14159265358 / 2, tria);
Copy link
Member

Choose a reason for hiding this comment

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

That was a funny one - only 12 digits and then with wrong rounding (the first omitted digit of pi is 9, so even in case this we would have found 12 digits sufficient it should have been ...5359) - thanks for fixing things up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was checking which tests are affected by the change by grepping for the function name and thought I could fix this along the way. There might be more occurrences of these magic numbers in the testsuite. I can check for these as a follow-up.

@marcfehling
Copy link
Member Author

Something funny happened while adding your suggestions. PR is back on track now!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@masterleinad masterleinad merged commit 16357cb into dealii:master Oct 20, 2021
@marcfehling marcfehling deleted the rotate branch October 20, 2021 02:57
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.

None yet

3 participants