Add new stretching transformation to mesh tools#270
Conversation
|
Document describing the new stretching function and its implementation stretch.pdf |
|
Updated documentation (including non-symmetrical meshes) stretch.pdf |
James Kent (jameskent-metoffice)
left a comment
There was a problem hiding this comment.
This PR adds a new stretching transform based on polynomial stretching. I've worked through the document and I'm happy that this stretching is correct, and it has been coded correctly. There are a number of places where the "&" need to be aligned, and there is one erroneous print statement. When these are corrected I am happy this science review is approved.
|
Thank you for completing the science review. I have now completed the requested minor suggestions. |
|
Is the documentation, on the core repo. I suppose it should be for reference. Though do we have permission to do so? |
Ricky Wong (mo-rickywong)
left a comment
There was a problem hiding this comment.
Quite a lot of comments to address, mostly stemming from aligning with existing mesh_tools code and conventions on ordering.
Implementation approach is not made clear and prominent, leading to confusion when interpreting the code. There is mention in the pdf, though the code should be able to be followed it's own without the stretch.pdf.
Mesh tools sphinx documentation has not been updated. The PR documentation paper (pdf) on the approach is useful information though doesn't necessarily translate to understanding the implemented code. At present there is no details on stretching in the mesh documentation so thats not a major issue, Though the generators namelist options and usage has been completed and should be updated with changes in this PR.
I've not commented fully on polynominal stretching mod as I suspect it will change as requested changes filter down.
There are changes to unrelated test cases, though there is no mention of these on the PR. have the changes been confirmed to be negligible? checksums don't give any indication of the size of the change.
| create_lbc_mesh = .true. | ||
| lbc_rim_depth = 6 | ||
| lbc_parent_mesh = 'primary' | ||
| stretch_function = 'uniform' |
There was a problem hiding this comment.
stretch_function doesn't seem appropriate as uniform is one function that applies to the whole domain, whereas polynominal and inflation have different functions in different regions. Suggest stretch_profile is a better fit.
There was a problem hiding this comment.
Uniform, polynomial and inflation are all applied to the whole domain. I therefore suggest that keeping stretch_function is the appropriate name. Given input coordinates x, calculate new coordinates y=f(x) using the mathematical function f.
There was a problem hiding this comment.
Please do not change the example namelist except to add required entries. The example file is to try and demo a working config (with new functionality if required/possible). These changes look like they are left-over from development for this change.
| sort-key=Panel-A10 | ||
| type=logical | ||
|
|
||
| [namelist:planar_mesh=stretch_function] |
There was a problem hiding this comment.
As before, suggest alternative name &stretch_profile
| = interior, with a stretch region in between. | ||
| = Inflation: y_n = y_n-1 + dy * inflation ** stretch | ||
| = Polynomial: y = bx + ax^n where n is the power | ||
| !kind=default |
There was a problem hiding this comment.
| !kind=default | |
| help=The function applied is: | |
| = * "Uniform" | |
| = Uniform resolution mesh | |
| = y = ax | |
| = | |
| = * "Inflation" | |
| = Low resolution outer and a high resolution | |
| = interior, with a stretch region in between. | |
| = y_n = y_n-1 + dy * inflation ** stretch | |
| = | |
| = * "Polynominal" | |
| = Low resolution outer and a high resolution | |
| = interior, with a stretch region in between. | |
| = y = bx + ax^n | |
| = where n is the power. |
Format the text for better clarity, Minor duplication to keep it clean. Something like above, please check layout in Cylc-gui
| help=[n_outer_n, n_outer_s, n_outer_e, n_outer_w] | ||
| =This is the number of cells in an outer region | ||
| =near to a domain edge for the North, South, | ||
| =East and West edges. |
There was a problem hiding this comment.
| help=[n_outer_n, n_outer_s, n_outer_e, n_outer_w] | |
| =This is the number of cells in an outer region | |
| =near to a domain edge for the North, South, | |
| =East and West edges. | |
| help=[n_outer_w, n_outer_s, n_outer_e, n_outer_n] | |
| = | |
| =Number of cells in the outer region adjacent | |
| =to domain boundary. Values are ordered for | |
| =domain boundaries as West, South, East and | |
| =North. | |
| = |
Instructure arrays index locations follow the reference element, for Faces/edges it goes [W,S,E,N] so this should follow accordingly. I accept there is a conflict in naming here with the original transform namelist options, though the ordering of arrays really shouldn't be encoded into variable names. please bear this in mind. Could possibly rename these later or remove the ordering in the name if the inflation profile is deprecated.
There was a problem hiding this comment.
Surely the choice of index locations should be chosen to best help the user. The North and South boundaries will most likely have the same number of cells, as will the East and West. So grouping these together makes the most sense. And surely North always comes first. Furthermore, I think NSEW is the traditional ordering of compass directions. Therefore I strongly suggest we keep NSEW.
There was a problem hiding this comment.
I have updated the rest of the text following your suggestion, but keeping the NSEW.
| !> @param param_a Parameter a | ||
| !> @param param_b Parameter b | ||
| !> @param param_c Parameter c |
There was a problem hiding this comment.
Doxygen comments add no extra information
| !> @param param_a Parameter a | |
| !> @param param_b Parameter b | |
| !> @param param_c Parameter c | |
| !> @param param_a Parameter a, for Inner region function | |
| !> @param param_b Parameter b, for Stretch region function | |
| !> @param param_c Parameter c, for Outer region function |
There was a problem hiding this comment.
I think this is clear from the definitions in @details
| ! This enables support meshes to be created with a variable | ||
| ! resolution stretching function. | ||
| if (configuration%namelist_exists('stretch_transform')) then |
There was a problem hiding this comment.
Still not sure this was the best way to do this, leaving it as it was there before, but may need to be restructured later on with some thought
There was a problem hiding this comment.
Yes, I expect more restructuring can be done later.
| sort-key=Panel-A04 | ||
| type=integer | ||
|
|
||
| [namelist:stretch_transform=n_cells_outer_nsew] |
There was a problem hiding this comment.
Doesn't follow rest of infrastructure ordering [W,S,E,N] for edges/faces, [SW,SE,NE,NW] for nodes.
There was a problem hiding this comment.
As explained in another comment, I would prefer to leave as is.
| sort-key=Panel-A04 | ||
| type=integer | ||
|
|
||
| [namelist:stretch_transform=n_cells_stretch_nsew] |
There was a problem hiding this comment.
Similar comments as earlier with respect to the ordering encoded in the variable name
There was a problem hiding this comment.
I would prefer to keep the NSEW ordering
| !> @brief Apply a polynomial stretching transformation to a given coordinate | ||
| !> @details In inner y = b x, in stretch y = a (x - xi) ^n + b x | ||
| !! and in outer y = yo + c x | ||
| !> @param param_a Parameter a | ||
| !> @param param_b Parameter b | ||
| !> @param param_c Parameter c | ||
| !> @param x_inner Unit mesh coordinate betwen inner and stretch | ||
| !> @param x_outer Unit mesh coordinate between stretch and outer | ||
| !> @param dx Unit mesh cell size | ||
| !> @param direction North-south or East-west |
There was a problem hiding this comment.
Dyoygen comments do not match, Similar comments to on doxygen comments in in polynominal parameters
I'm not quite understanding this question. But regarding documentation, please let me know the location of any documentation that needs to be updated. I cannot find any Sphinx documentation. It may be that further documentation (in addition to the pdf that I have provided) needs to follow in a follow-on PR. |




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
Testing
LFRic Apps Testing still to be completed.
trac.log
Test Suite Results - lfric_core - test_stretching/run11
Suite Information
Task Information
✅ succeeded tasks - 390
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review