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

Random uniform distribution deflected as rotation with tests #713

Merged
merged 8 commits into from
Jun 6, 2024

Conversation

Wang-yijun
Copy link
Contributor

Generated= random uniform distribution with a deflection as rotations and apply these rotations to an input orientation represented with Euler angle or rotation matrix. This grain model is added for all features.
I also removed the old tests for this grain model random_uniform_distribution_deflected using two different random number seed and added new tests.
Some sample generated textures (plotted using MTEX in Matlab):
Input Euler angle (0,0,0), deflection=0.001
shearbox_test_0_0_0_0 001
Input Euler angle (0,0,0), deflection=1
shearbox_test_0_0_0_1
Input Euler angle (0,90,0), deflection=0.001
shearbox_test_0_90_0_0 001
Input Euler angle (90,90,0), deflection=0.001
shearbox_test_90_90_0_0 001

Copy link

github-actions bot commented May 29, 2024

Benchmark Main Feature Difference (99.9% CI)
Slab interpolation simple none 1.015 ± 0.004 (s=446) 0.991 ± 0.005 (s=454) -2.4% .. -2.3%
Slab interpolation curved simple none 1.020 ± 0.004 (s=433) 0.995 ± 0.004 (s=463) -2.6% .. -2.4%
Spherical slab interpolation simple none 1.183 ± 0.007 (s=391) 1.161 ± 0.007 (s=379) -2.0% .. -1.7%
Slab interpolation simple curved CMS 1.061 ± 0.003 (s=447) 1.032 ± 0.004 (s=415) -2.9% .. -2.7%
Spherical slab interpolation simple CMS 1.594 ± 0.011 (s=299) 1.571 ± 0.012 (s=272) -1.6% .. -1.2%
Spherical fault interpolation simple none 1.191 ± 0.008 (s=399) 1.167 ± 0.006 (s=366) -2.1% .. -1.9%
Cartesian min max surface 2.304 ± 0.019 (s=200) 2.317 ± 0.017 (s=192) +0.3% .. +0.9%
Spherical min max surface 7.227 ± 0.038 (s=69) 7.043 ± 0.035 (s=60) -2.8% .. -2.3%

@Wang-yijun
Copy link
Contributor Author

More examples on textures with 10,000 grains (plotted with MTEX default colormap in Matlab):
Input Euler angle (0,90,0), deflection=0.001
shearbox_test_0_90_0_0 001
Input Euler angle (0,90,0), deflection=0.1
shearbox_test_0_90_0_0 1
Input Euler angle (0,90,0), deflection=0.3
shearbox_test_0_90_0_0 3
Input Euler angle (0,90,0), deflection=0.6
shearbox_test_0_90_0_0 6
Input Euler angle (0,90,0), deflection=0.9
shearbox_test_0_90_0_0 9
Input Euler angle (0,90,0), deflection=1
shearbox_test_0_90_0_1

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the changes! Great to see that you also added a plume version. I need to look a bit more into some of the code, but here are already some comments.

  1. I think it would make sense to move the matrix_multiply function to a utilities function multiply_3x3_matrices or something similar.
  2. Add a unit test for the matrix multiply function to make sure that it works as expected.

@MFraters
Copy link
Member

More examples on textures with 10,000 grains (plotted with MTEX default colormap in Matlab): ....

This looks great, thanks!

@Wang-yijun
Copy link
Contributor Author

I've moved the matrix_multiply functions in grain model features into utilities and made a unit test for it.

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

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

Just a few more comments. Also can you fix the unit tests? You just need to add a few more approx.

Then we can see how the coverage is doing.

const double feature_max_depth) const override final;

private:
// uniform grains submodule parameters
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
// uniform grains submodule parameters


// Then U' = R * U * R^T
std::array<std::array<double,3>,3> result1 = Utilities::multiply_3x3_matrices(rotation_matrices, basis_rotation_matrices[i]);
// std::array<std::array<double,3>,3> rotated_rotation_matrix = matrix_multiply(result1, rot_T);
Copy link
Member

Choose a reason for hiding this comment

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

Can this line go?

}





Copy link
Member

Choose a reason for hiding this comment

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

Five new lines seems a bit excessive to me.


// Then U' = R * U * R^T
std::array<std::array<double,3>,3> result1 = multiply_3x3_matrices(rotation_matrices, basis_rotation_matrices[i]);
// std::array<std::array<double,3>,3> rotated_rotation_matrix = multiply_3x3_matrices(result1, rot_T);
Copy link
Member

Choose a reason for hiding this comment

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

same here


// Then U' = R * U * R^T
std::array<std::array<double,3>,3> result1 = multiply_3x3_matrices(rotation_matrices, basis_rotation_matrices[i]);
// std::array<std::array<double,3>,3> rotated_rotation_matrix = multiply_3x3_matrices(result1, rot_T);
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed this and a few other similar comments and empty lines. I also added approx to all unit test checks.

@MFraters
Copy link
Member

Some testers fail because std::transform is a c++17 feature, and currently the world builder is a c++14 code. Can you rewrite it in a c++14 way and maybe leave as a comment that once we switch to c++17 we can update it.

@Wang-yijun
Copy link
Contributor Author

I've changed std::transform to for loops.

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

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

Thanks! It looks good to me now. Please squash the commits as discussed and then it should be ready to merge.

@Wang-yijun Wang-yijun force-pushed the apply_as_rotation branch from 5659647 to 1aa6e0b Compare June 4, 2024 19:21
@Wang-yijun Wang-yijun force-pushed the apply_as_rotation branch from 1aa6e0b to fed9ae7 Compare June 4, 2024 19:33
Fix indentation
@Wang-yijun Wang-yijun force-pushed the apply_as_rotation branch from fed9ae7 to 8319b98 Compare June 4, 2024 19:50
Copy link

codecov bot commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 99.60784% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.27%. Comparing base (dbf0e2c) to head (b44bd4a).
Report is 129 commits behind head on main.

Files with missing lines Patch % Lines
...ls/grains/random_uniform_distribution_deflected.cc 98.88% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #713      +/-   ##
==========================================
+ Coverage   98.17%   98.27%   +0.10%     
==========================================
  Files         107      108       +1     
  Lines        7463     7666     +203     
==========================================
+ Hits         7327     7534     +207     
+ Misses        136      132       -4     
Files with missing lines Coverage Δ
...ls/grains/random_uniform_distribution_deflected.cc 98.92% <100.00%> (+1.70%) ⬆️
...ls/grains/random_uniform_distribution_deflected.cc 98.88% <100.00%> (+1.78%) ⬆️
...ls/grains/random_uniform_distribution_deflected.cc 98.92% <100.00%> (+1.70%) ⬆️
...ls/grains/random_uniform_distribution_deflected.cc 98.92% <100.00%> (+1.70%) ⬆️
...ls/grains/random_uniform_distribution_deflected.cc 98.88% <100.00%> (+1.78%) ⬆️
source/world_builder/utilities.cc 97.25% <100.00%> (+0.03%) ⬆️
...ls/grains/random_uniform_distribution_deflected.cc 98.88% <98.88%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1501cb...b44bd4a. Read the comment docs.

@MFraters
Copy link
Member

MFraters commented Jun 4, 2024

Based on the coverage results, it looks like there is no test for random_uniform_distribution_deflected. Could you add that?

@Wang-yijun
Copy link
Contributor Author

The tests I added are called "random_uniform_distribution_deflected_asrotation_seed1.wb" and "random_uniform_distribution_deflected_asrotation_seed1000.wb". Is this the reason that the tests are not detected?

@MFraters
Copy link
Member

MFraters commented Jun 5, 2024

The tests are run, see https://github.com/GeodynamicWorldBuilder/WorldBuilder/actions/runs/9373443402/job/25807253224?pr=713, but they do not cover the that part of the code. I also just noticed that some comments have not been addressed, can you take another look at them?

Remove unnessary comments and lines
@Wang-yijun Wang-yijun force-pushed the apply_as_rotation branch from dc5f50b to b044567 Compare June 5, 2024 21:10
@Wang-yijun
Copy link
Contributor Author

I might have messed up the commits with squash. I've fixed the plume test and addressed the comments above now.

@Wang-yijun
Copy link
Contributor Author

I've added tests to use rotation matrices for initial textures to improve the coverage.

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

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

Great, thanks for also fixing the coverage! One more thing, can you add a changelog entry in Changelog.md?

@Wang-yijun
Copy link
Contributor Author

Done!

Copy link
Member

@MFraters MFraters left a comment

Choose a reason for hiding this comment

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

Thanks!

@MFraters MFraters merged commit 62f16e7 into GeodynamicWorldBuilder:main Jun 6, 2024
39 of 40 checks passed
MFraters added a commit to MFraters/WorldBuilder-1 that referenced this pull request Jun 8, 2024
MFraters added a commit to MFraters/WorldBuilder-1 that referenced this pull request Jun 8, 2024
MFraters added a commit to MFraters/WorldBuilder-1 that referenced this pull request Jun 10, 2024
MFraters added a commit to MFraters/WorldBuilder-1 that referenced this pull request Jun 10, 2024
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.

2 participants