Skip to content

Add new stretching transformation to mesh tools - #270

Merged
James Bruten (james-bruten-mo) merged 51 commits into
MetOffice:mainfrom
cjohnson-pi:stretching
Jun 30, 2026
Merged

Add new stretching transformation to mesh tools#270
James Bruten (james-bruten-mo) merged 51 commits into
MetOffice:mainfrom
cjohnson-pi:stretching

Conversation

@cjohnson-pi

@cjohnson-pi cjohnson-pi commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Sci/Tech Reviewer: James Kent (@jameskent-metoffice)
Code Reviewer: Ricky Wong (@mo-rickywong)

Documentation:
#270 (comment)

linked MetOffice/lfric_apps#344

Code Quality Checklist

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • All automated checks in the CI pipeline have completed successfully

Testing

  • I have tested this change locally, using the LFRic Core rose-stem suite
  • If required (e.g. API changes) I have also run the LFRic Apps test suite using this branch
  • If any tests fail (rose-stem or CI) the reason is understood and acceptable (e.g. kgo changes)
  • I have added tests to cover new functionality as appropriate (e.g. system tests, unit tests, etc.)
  • Any new tests have been assigned an appropriate amount of compute resource and have been allocated to an appropriate testing group (i.e. the developer tests are for jobs which use a small amount of compute resource and complete in a matter of minutes)

LFRic Apps Testing still to be completed.

trac.log

Test Suite Results - lfric_core - test_stretching/run20

Suite Information

Item Value
Suite Name test_stretching/run20
Suite User christine.johnson
Workflow Start 2026-06-29T15:18:53
Groups Run suite_default
Dependency Reference Main Like
lfric_core cjohnson-pi/lfric_core@stretching False
SimSys_Scripts MetOffice/SimSys_Scripts@cab3315 True

Task Information

✅ succeeded tasks - 433

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

Performance Impact

  • Performance of the code has been considered and, if applicable, suitable performance measurements have been conducted

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

Documentation

  • Where appropriate I have updated documentation related to this change and confirmed that it builds correctly

PSyclone Approval

  • If you have edited any PSyclone-related code (e.g. PSyKAl-lite, Kernel interface, optimisation scripts, LFRic data structure code) then please contact the TCD Team

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

(Please alert the code reviewer via a tag when you have approved the SR)

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • CLA compliance has been confirmed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Documentation is complete and accurate
  • Security considerations have been addressed
  • Performance impact is acceptable

@github-actions github-actions Bot added the cla-required The CLA has not yet been signed by the author of this PR - added by GA label Feb 10, 2026
@cjohnson-pi cjohnson-pi added the KGO This PR contains changes to KGO label Feb 18, 2026
@cjohnson-pi

Copy link
Copy Markdown
Contributor Author
poly_power

@cjohnson-pi

Copy link
Copy Markdown
Contributor Author

Document describing the new stretching function and its implementation stretch.pdf

@cjohnson-pi
cjohnson-pi marked this pull request as ready for review March 4, 2026 10:46
@cjohnson-pi cjohnson-pi added this to the Summer 2026 milestone Mar 4, 2026
cjohnson-pi and others added 9 commits June 26, 2026 11:55
Co-authored-by: Ricky Wong <141156427+mo-rickywong@users.noreply.github.com>
Co-authored-by: Ricky Wong <141156427+mo-rickywong@users.noreply.github.com>
Co-authored-by: Ricky Wong <141156427+mo-rickywong@users.noreply.github.com>
Co-authored-by: Ricky Wong <141156427+mo-rickywong@users.noreply.github.com>
Co-authored-by: Ricky Wong <141156427+mo-rickywong@users.noreply.github.com>
Co-authored-by: Ricky Wong <141156427+mo-rickywong@users.noreply.github.com>
@cjohnson-pi

cjohnson-pi commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

I've renamed apply_shift as recentre_high_resolution_region and added further Doxygen comments. Yes it would be possible to restructure to have an apply_shift with an argument detailing the type of offset to shift with. But I decided that it would be clearer to have these routines as separate routines.

Regarding the fine-meshes, the planar mesh needs to know about fine meshes because the stretch transform parameters are always derived using the fine mesh, and then applied to the coarse mesh.

A new issue regarding associated documentation has been added.

@mo-rickywong

Copy link
Copy Markdown
Contributor

I've renamed apply_shift as recentre_high_resolution_region and added further Doxygen comments. Yes it would be possible to restructure to have an apply_shift with an argument detailing the type of offset to shift with. But I decided that it would be clearer to have these routines as separate routines.

Regarding the fine-meshes, the planar mesh needs to know about fine meshes because the stretch transform parameters are always derived using the fine mesh, and then applied to the coarse mesh.

A new issue regarding associated documentation has been added.

I think these issues should be discussed as a follow-up issue/PR. It is all about scope and what should be aware of what.
The name recentre_high_resolution_region is specific to a particular stretching option(s), but is the code? I still don't see why the fine mesh is require by the planar mesh generation, I think there is some miscommunication going on.

Though it's something to discuss offline.

@mo-rickywong

Copy link
Copy Markdown
Contributor

Checked out the current branch and applied the upgrade macros and ran the test-suite.
The resulting changes from the upgrade macros cause validation failures (lbc_demo) and significant KGO failures in the new test task for your stretched ticket. Can you confirm? whether the KGOs/macros need updating?
image

@mo-rickywong

Copy link
Copy Markdown
Contributor

Might be best to bring up to head of main

@mo-rickywong Ricky Wong (mo-rickywong) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still some issues on the code, mainly on the documentation and comments. I'm not a fan of referencing symbols in the science paper, explanatory variable names are clearer for the reader. Though I'll settle for clearer comments due to this having become a priority.

Please see comments, The current branch has significant diffs on KGOs for the new tasks when moved to head of trunk. Please move to head and confirm when the KGOs of the new tasks are as expected.

@cjohnson-pi

cjohnson-pi commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Tests

Showing that the domain centre (the centre of the high resolution region) is correct in situations where there is more stretching on the W,S, E and N boundaries respectively.

 edge_cells_x    = 20
 edge_cells_y    = 20
 domain_centre   = 20.0, 10.0
 cell_size_inner = 0.01, 0.01
 cell_size_outer = 0.05, 0.05
 n_cells_outer_wsen   = 2, 2, 2, 5
 n_cells_stretch_wsen = 1, 1, 1, 5
 poly_power      = 3

West

n_cells_outer_wsen=5,2,2,2
n_cells_stretch_wsen=5,1,1,1
mesh_W

South

n_cells_outer_wsen=2,5,2,2
n_cells_stretch_wsen=1,5,1,1
mesh_S

East

n_cells_outer_wsen=2,2,5,2
n_cells_stretch_wsen=1,1,5,1
mesh_E

North

n_cells_outer_wsen=2,2,2,5
n_cells_stretch_wsen=1,1,1,5
mesh_N

@cjohnson-pi

Copy link
Copy Markdown
Contributor Author

Test completes (trac.log above) and I have verified that the new WSEN metadata gives the correct response. kgos were updated. (As I did them twice they could be the same! - although I'm not sure how to check with github.)

Ready for review again. Thank you.

@mo-rickywong Ricky Wong (mo-rickywong) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, James is going to take over testing. I'm happy for this to go on, There are some outstanding issues/queries that can be followed up later.

@james-bruten-mo
James Bruten (james-bruten-mo) merged commit b85ebad into MetOffice:main Jun 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The CLA has been signed as part of this PR - added by GA KGO This PR contains changes to KGO Linked Apps This PR is linked to a MetOffice/lfric_apps PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants