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

Add random_uniform_distribution_deflected to all features and enable random number seed as input #584

Merged

Conversation

Wang-yijun
Copy link
Contributor

This PR adds random_uniform_distribution_deflected texture to all features (continental plate, oceanic plate, fault, subducting plate and mantle layer), sets default global random number seed as NaN unless entered in the input file, and lets random_uniform_distribution_deflected texture take random number seeds as inputs to generate different random textures with different deflection from the center.

@Wang-yijun Wang-yijun changed the title Add random_uniform_distribution_deflected to all features and enable random number seed as input [WIP] Add random_uniform_distribution_deflected to all features and enable random number seed as input Feb 14, 2024
@Wang-yijun Wang-yijun changed the title [WIP] Add random_uniform_distribution_deflected to all features and enable random number seed as input Add random_uniform_distribution_deflected to all features and enable random number seed as input Feb 15, 2024
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. Here are some initial comments we also discussed.

/**
* Todo
*/
int local_seed;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is needed. Can you remove this and just locally declare it as an int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this.

RandomUniformDistributionDeflected::declare_entries(Parameters &prm, const std::string & /*unused*/)
{
// Document plugin and require entries if needed.
// Add compositions the required 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
// Add compositions the required parameters.
// Add compositions to the required parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this and some other descriptions of the feature in random_uniform_distribution_deflected

normalize_grain_sizes = prm.get_vector<bool>("normalize grain sizes");
deflections = prm.get_vector<double>("deflections");
seed = prm.get<unsigned int>("random number seed");
world->get_random_number_engine().seed(seed);
Copy link
Member

Choose a reason for hiding this comment

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

As discussed, use global one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted this and other use of local seed inside features

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.

The code looks good to me. Can you add tests to that all code is tested?

@@ -276,6 +276,7 @@ namespace WorldBuilder
std::string interpolation;



Copy link
Member

Choose a reason for hiding this comment

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

could you remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test added and empty line removed.

namespace Grains
{
/**
* This class represents a fault and can implement
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment block copied from somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I this is copied from random_uniform_distribution.h in the same folder as a template and I made changes based on that.

const double feature_max_depth) const override final;

private:
// random uniform distribution deflected grains submodule parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

I would delete this comment as it doesn't add any useful information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Copy link

github-actions bot commented Feb 16, 2024

Benchmark Main Feature Difference (99.9% CI)
Slab interpolation simple none 1.008 ± 0.003 (s=476) 1.018 ± 0.004 (s=415) +0.9% .. +1.1%
Slab interpolation curved simple none 1.014 ± 0.004 (s=443) 1.023 ± 0.005 (s=443) +0.8% .. +1.0%
Spherical slab interpolation simple none 1.162 ± 0.008 (s=382) 1.166 ± 0.007 (s=394) +0.2% .. +0.5%
Slab interpolation simple curved CMS 1.057 ± 0.004 (s=428) 1.061 ± 0.004 (s=424) +0.2% .. +0.4%
Spherical slab interpolation simple CMS 1.544 ± 0.009 (s=290) 1.549 ± 0.011 (s=294) +0.1% .. +0.5%
Spherical fault interpolation simple none 1.171 ± 0.008 (s=406) 1.176 ± 0.009 (s=364) +0.2% .. +0.5%
Cartesian min max surface 2.295 ± 0.017 (s=193) 2.301 ± 0.016 (s=201) +0.0% .. +0.5%
Spherical min max surface 7.198 ± 0.022 (s=63) 7.211 ± 0.024 (s=64) -0.0% .. +0.4%

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (31e7e1e) 92.83% compared to head (e30af2a) 92.99%.
Report is 6 commits behind head on main.

❗ Current head e30af2a differs from pull request most recent head 9f41335. Consider uploading reports for the commit 9f41335 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #584      +/-   ##
==========================================
+ Coverage   92.83%   92.99%   +0.16%     
==========================================
  Files          92       98       +6     
  Lines        6474     6856     +382     
==========================================
+ Hits         6010     6376     +366     
- Misses        464      480      +16     
Files Coverage Δ
source/world_builder/parameters.cc 97.94% <100.00%> (+0.02%) ⬆️
source/world_builder/world.cc 100.00% <100.00%> (ø)
...ls/grains/random_uniform_distribution_deflected.cc 97.22% <97.22%> (ø)
...ls/grains/random_uniform_distribution_deflected.cc 97.10% <97.10%> (ø)
...ls/grains/random_uniform_distribution_deflected.cc 97.22% <97.22%> (ø)
...ls/grains/random_uniform_distribution_deflected.cc 97.22% <97.22%> (ø)
...ls/grains/random_uniform_distribution_deflected.cc 97.10% <97.10%> (ø)
source/world_builder/types/int.cc 70.58% <70.58%> (ø)

... and 4 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 31e7e1e...9f41335. Read the comment docs.

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.

I would propose merging this as is. Please make a follow up pull request with

  1. a more extensive explanation of the random number seed declare entry
  2. A test which is exactly the same, but has a different random number.

@MFraters MFraters added the ready to merge Pull request is ready to merge. May be waiting for tests to complete or other reviews. label Feb 17, 2024
@Wang-yijun
Copy link
Contributor Author

Example texture generated using random uniform distribution deflected (visualized using MTEX package in Matlab):
0 8
deflection = 0.8, random number seed = 1
0 6
deflection = 0.6, random number seed = 1
0 4
deflection = 0.4, random number seed = 1
0 2
deflection = 0.2, random number seed = 1
0 6_10
deflection = 0.6, random number seed = 10

@gassmoeller gassmoeller merged commit 2915c68 into GeodynamicWorldBuilder:main Feb 17, 2024
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull request is ready to merge. May be waiting for tests to complete or other reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants