Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d41d463
stretching
cjohnson-pi Feb 9, 2026
58fdb32
example works
cjohnson-pi Feb 10, 2026
1d3aa30
tidy
cjohnson-pi Feb 10, 2026
73a15d5
rose
cjohnson-pi Feb 10, 2026
0765224
Update polynomial calculation
cjohnson-pi Feb 13, 2026
0f37fbe
update polynomial
cjohnson-pi Feb 13, 2026
a32d1ba
Correct for all powers
cjohnson-pi Feb 17, 2026
77bd280
tidy
cjohnson-pi Feb 17, 2026
41d57eb
correct versions
cjohnson-pi Feb 18, 2026
62467ad
use PR number
cjohnson-pi Feb 18, 2026
ba667ca
correct rose meta
cjohnson-pi Feb 18, 2026
e6b680e
unit tests run
cjohnson-pi Feb 18, 2026
c0d74c2
unit tests pass
cjohnson-pi Feb 18, 2026
5e08d60
whitespace
cjohnson-pi Feb 18, 2026
ce41044
update domain_extents
cjohnson-pi Mar 4, 2026
12eeb80
Merge remote-tracking branch 'origin/main' into stretching
cjohnson-pi Mar 5, 2026
32cb52d
minor improvements
cjohnson-pi Mar 5, 2026
2cf1072
kgo and whitespace
cjohnson-pi Mar 5, 2026
c2549a2
mesh kgo
cjohnson-pi Mar 5, 2026
75400a4
Merge branch 'main' into stretching
cjohnson-pi Mar 5, 2026
e53cb21
CLA
cjohnson-pi Mar 5, 2026
97d21eb
update versions
cjohnson-pi Mar 5, 2026
38e2537
non-symmetrical
cjohnson-pi Mar 13, 2026
dfa0f47
correct style, rose-meta and kgos
cjohnson-pi Mar 13, 2026
7a7feee
science review response
cjohnson-pi Mar 19, 2026
0cb4c83
More aligning
cjohnson-pi Mar 19, 2026
c14506e
correction
cjohnson-pi Mar 19, 2026
71def5a
response to code review
cjohnson-pi Jun 17, 2026
4554b47
nsew to wsen
cjohnson-pi Jun 17, 2026
169d7bb
nsew to wsen
cjohnson-pi Jun 17, 2026
f87be93
style
cjohnson-pi Jun 17, 2026
182add9
At least 1 stretch cell
cjohnson-pi Jun 17, 2026
26984d4
Update mesh_tools/source/support/polynomial_stretching_mod.F90
cjohnson-pi Jun 26, 2026
2e2203b
Update mesh_tools/source/support/polynomial_stretching_mod.F90
cjohnson-pi Jun 26, 2026
fabca88
Update mesh_tools/source/support/polynomial_stretching_mod.F90
cjohnson-pi Jun 26, 2026
e6f0d6f
Update mesh_tools/source/support/gen_planar_mod.F90
cjohnson-pi Jun 26, 2026
4ab8041
Update mesh_tools/rose-meta/lfric-mesh_tools/HEAD/rose-meta.conf
cjohnson-pi Jun 26, 2026
f6ef315
Update mesh_tools/source/support/gen_planar_mod.F90
cjohnson-pi Jun 26, 2026
1afd119
Update mesh_tools/source/support/gen_planar_mod.F90
cjohnson-pi Jun 26, 2026
50eb1b3
'Boundary enumeration' correction
cjohnson-pi Jun 26, 2026
01d176c
more code review response
cjohnson-pi Jun 26, 2026
fb27efb
Deal with apply_shift and apply_uniform_scaling
cjohnson-pi Jun 26, 2026
b3b7565
Merge remote-tracking branch 'upstream/main' into stretching
cjohnson-pi Jun 29, 2026
85c4d65
validate and style corrections
cjohnson-pi Jun 29, 2026
4b035cf
configuration -> config
cjohnson-pi Jun 29, 2026
ec2841a
reorder subroutines - so make build succeeds
cjohnson-pi Jun 29, 2026
0a620c4
kgos
cjohnson-pi Jun 29, 2026
87da607
removing bugs
cjohnson-pi Jun 29, 2026
4f68a1d
correction
cjohnson-pi Jun 29, 2026
cef9077
kgos
cjohnson-pi Jun 29, 2026
7556bf7
apply macros
james-bruten-mo Jun 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
| MetBenjaminWent | Benjamin Went | Met Office | 2026-01-30 |
| jcsmeto | James Cunningham-Smith | Met Office | 2026-02-06 |
| thomasmelvin | Thomas Melvin | Met Office | 2026-01-15 |
| ericaneininger | Erica Neininger | Met Office | 2026-03-02 |
| ericaneininger | Erica Neininger | Met Office | 2026-03-02 |
| cjohnson-pi | Christine Johnson | Met Office | 2026-03-05 |
19 changes: 10 additions & 9 deletions applications/lbc_demo/example/mesh_config.nml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
/

&planar_mesh
edge_cells_x = 30
edge_cells_y = 30
domain_size = 24.0, 22.0
domain_centre = 0.0, 0.0
periodic_x = .false.
periodic_y = .false.
create_lbc_mesh = .true.
lbc_rim_depth = 6
lbc_parent_mesh = 'primary'
edge_cells_x = 30
edge_cells_y = 30
domain_size = 24.0, 22.0
domain_centre = 0.0, 0.0
periodic_x = .false.
periodic_y = .false.
create_lbc_mesh = .true.
lbc_rim_depth = 6
lbc_parent_mesh = 'primary'
stretch_function = 'uniform'
Comment thread
mo-rickywong marked this conversation as resolved.
/

&partitions
Expand Down
30 changes: 15 additions & 15 deletions mesh_tools/example/planar_mesh_gen.nml
Comment thread
mo-rickywong marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
mesh_file_prefix = 'planar_mesh'
geometry = 'spherical'
topology = 'non_periodic'
n_meshes = 2
mesh_names = 'mesh_A','mesh_B'
mesh_maps = 'mesh_A:mesh_B'
n_meshes = 1
mesh_names = 'mesh_A'
partition_mesh = .false.
coord_sys = 'll'
rotate_mesh = .true.
rotate_mesh = .false.
/

!==================================================================
Expand All @@ -51,16 +50,16 @@
! be a factor of the other.

&planar_mesh
edge_cells_x = 48, 24
edge_cells_y = 24, 12
domain_size = 48.0, 24.0
domain_centre = 0.0, 0.0
edge_cells_x = 24
edge_cells_y = 24
domain_size = 48.0, 48.0
domain_centre = 30.0, 10.0
periodic_x = .false.
periodic_y = .false.
create_lbc_mesh = .true.
create_lbc_mesh = .false.
lbc_rim_depth = 1
lbc_parent_mesh = 'mesh_A'
apply_stretch_transform = .false.
stretch_function = 'polynomial'
/

&partitions
Expand All @@ -79,10 +78,11 @@
/

&stretch_transform
cell_size_inner = 2.0, 2.0
cell_size_outer = 3.0, 3.0
n_cells_outer = 2, 2
n_cells_stretch = 5, 5
stretching_on = 'cell_centres'
cell_size_inner = 0.0135,0.0135
cell_size_outer = 0.036,0.036
n_cells_outer_nsew = 1, 8, 5, 1
n_cells_stretch_nsew = 1, 1, 1, 1
poly_power = 3
transform_mesh = 'mesh_A'
stretching_on = 'cell_nodes'
/
72 changes: 62 additions & 10 deletions mesh_tools/rose-meta/lfric-mesh_tools/HEAD/rose-meta.conf
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,6 @@ ns=namelist/mesh/planar
sort-key=Section-A03
title=Planar

[namelist:planar_mesh=apply_stretch_transform]
compulsory=true
description=Apply stretched grid transformation.
help=Enables using a larger cell spacing in the outer region of the domain,
=compared to the inner region.
!kind=default
sort-key=Panel-D01
trigger=namelist:stretch_transform: .true.;
type=logical

[namelist:planar_mesh=create_lbc_mesh]
compulsory=true
description=Create LBC mesh
Expand Down Expand Up @@ -470,6 +460,27 @@ help=Specifies whether the topology of the mesh should be periodic in the y dire
sort-key=Panel-A10
type=logical

[namelist:planar_mesh=stretch_function]
Comment thread
mo-rickywong marked this conversation as resolved.
compulsory=true
description=Type of stretch transformation applied to the unit mesh
!enumeration=true
help=The function applied is:
= Uniform: y = ax (uniform resolution)
= The following have a low resolution outer and a high resolution
= 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
Comment thread
mo-rickywong marked this conversation as resolved.
trigger=namelist:stretch_transform: this != "'uniform'";
=namelist:stretch_transform=stretching_on: this == "'inflation'";
=namelist:stretch_transform=n_cells_outer: this == "'inflation'";
=namelist:stretch_transform=n_cells_stretch: this == "'inflation'";
=namelist:stretch_transform=poly_power: this == "'polynomial'";
=namelist:stretch_transform=n_cells_outer_nsew: this == "'polynomial'";
=namelist:stretch_transform=n_cells_stretch_nsew: this == "'polynomial'";
value-titles=uniform, inflation, polynomial
values='uniform','inflation','polynomial'

[namelist:rotation]
compulsory=true
ns=namelist/mesh/Rotation
Expand Down Expand Up @@ -589,6 +600,19 @@ range=2:
sort-key=Panel-A04
type=integer

[namelist:stretch_transform=n_cells_outer_nsew]

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.

Doesn't follow rest of infrastructure ordering [W,S,E,N] for edges/faces, [SW,SE,NE,NW] for nodes.

@cjohnson-pi cjohnson-pi Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As explained in another comment, I would prefer to leave as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now updated to WSEN

compulsory=true
description=Depth (in cells) of outer region
Comment thread
mo-rickywong marked this conversation as resolved.
Outdated
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.
Comment thread
mo-rickywong marked this conversation as resolved.
Outdated
!kind=default
length=4
range=1:
sort-key=Panel-A04
type=integer

[namelist:stretch_transform=n_cells_stretch]
compulsory=true
description=Depth (in cells) of stretch region
Comment thread
mo-rickywong marked this conversation as resolved.
Outdated
Expand All @@ -605,6 +629,34 @@ range=0:
sort-key=Panel-A04
type=integer

[namelist:stretch_transform=n_cells_stretch_nsew]

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.

Similar comments as earlier with respect to the ordering encoded in the variable name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to keep the NSEW ordering

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now updated to WSEN

compulsory=true
description=Depth (in cells) of stretch region
Comment thread
mo-rickywong marked this conversation as resolved.
Outdated
help=[n_stretch_n, n_stretch_s, n_stretch_e, n_stretch_w]
Comment thread
cjohnson-pi marked this conversation as resolved.
Outdated
=A stretch region is defined to be the
=cells in between the inner region and an
=outer region, and where the cell size is in
=between the inner and outer cell sizes.
=i.e. cell_size_outer > size > cell_size_inner
=These are defined on the North, South, East
=and West edges of the domain.

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.

Suggested change
help=[n_stretch_n, n_stretch_s, n_stretch_e, n_stretch_w]
=A stretch region is defined to be the
=cells in between the inner region and an
=outer region, and where the cell size is in
=between the inner and outer cell sizes.
=i.e. cell_size_outer > size > cell_size_inner
=These are defined on the North, South, East
=and West edges of the domain.
help=[n_stretch_w, n_stretch_s, n_stretch_e, n_stretch_n]
=
=Number of cells in stretch region toward a given domain
=boundary. These are ordered for the West, South, East
=and North boundaries of the domain.
=
=A stretch region is defined to be the
=cells in between the inner region and an
=outer region. Cell sizes within the stretch region
=will lie between cell sizes within the inner/outer regions.
=i.e. cell_size_outer > cell_size_stretch > cell_size_inner
=

The existing help provides good background info, though focuses more on cell size and doesn't explicitly expand on the entry for number of cells.

Also earlier comment about the ordering applies here aswell

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Text has been adjusted following your suggestions. However I would prefer to keep the NSEW ordering.

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.

As with earlier conversation, please use WSEN to be consistent with reference element ordering

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now updated to WSEN

!kind=default
length=4
range=0:

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.

Is this right? a step change is allowed? with zero cells in the stretch region.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tested the code and it turns out that you do need to have at least 1 cell. So I've updated the range.

sort-key=Panel-A04
type=integer

[namelist:stretch_transform=poly_power]
compulsory=true
description=Polynomial Power
help=The polynomial stretch transform is
= y = bx + ax^n
= where n is the integer polynomial power.
Comment thread
mo-rickywong marked this conversation as resolved.
Outdated
!kind=default
range=2:
sort-key=Panel-A04
type=integer

[namelist:stretch_transform=stretching_on]
compulsory=true
description=Locations to map stretching function
Expand Down
30 changes: 30 additions & 0 deletions mesh_tools/rose-meta/lfric-mesh_tools/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,33 @@ def upgrade(self, config, meta_config=None):
# Add settings
return config, self.reports
"""

class vn31_t270(MacroUpgrade):
# Upgrade macro for #270 by cjohnson-pi

BEFORE_TAG = "vn3.1"
AFTER_TAG = "vn3.1_t270"

def upgrade(self, config, meta_config=None):
# Add settings
nml = "namelist:planar_mesh"
apply_stretch_transform = self.get_setting_value(
config, [nml, "apply_stretch_transform"])

if apply_stretch_transform == ".true.":
self.add_setting(
config,
[nml, "stretch_function"],
"'inflation'",
)
else:
self.add_setting(
config,
[nml, "stretch_function"],
"'uniform'",
)
self.remove_setting(
config, [nml, "apply_stretch_transform"]
)

return config, self.reports
Comment thread
mo-rickywong marked this conversation as resolved.
39 changes: 21 additions & 18 deletions mesh_tools/source/planar_mesh_generator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ program planar_mesh_generator
key_from_geometry
use rotation_config_mod, only: ROTATION_TARGET_NULL_ISLAND, &
ROTATION_TARGET_NORTH_POLE
use planar_mesh_config_mod, &
only: STRETCH_FUNCTION_INFLATION, &
STRETCH_FUNCTION_POLYNOMIAL

implicit none

Expand Down Expand Up @@ -171,11 +174,9 @@ program planar_mesh_generator
logical :: periodic_y
logical :: create_lbc_mesh
integer(i_def) :: lbc_rim_depth
integer(i_def) :: stretch_function

character(str_def) :: lbc_parent_mesh

logical :: apply_stretch_transform

character(str_def) :: transform_mesh

type(local_mesh_collection_type) :: local_mesh_collection
Expand Down Expand Up @@ -231,17 +232,16 @@ program planar_mesh_generator
topology = config%mesh%topology()
geometry = config%mesh%geometry()

edge_cells_x = config%planar_mesh%edge_cells_x()
edge_cells_y = config%planar_mesh%edge_cells_y()
periodic_x = config%planar_mesh%periodic_x()
periodic_y = config%planar_mesh%periodic_y()
domain_size = config%planar_mesh%domain_size()
domain_centre = config%planar_mesh%domain_centre()
create_lbc_mesh = config%planar_mesh%create_lbc_mesh()
lbc_rim_depth = config%planar_mesh%lbc_rim_depth()
lbc_parent_mesh = config%planar_mesh%lbc_parent_mesh()

apply_stretch_transform = config%planar_mesh%apply_stretch_transform()
edge_cells_x = config%planar_mesh%edge_cells_x()
edge_cells_y = config%planar_mesh%edge_cells_y()
periodic_x = config%planar_mesh%periodic_x()
periodic_y = config%planar_mesh%periodic_y()
domain_size = config%planar_mesh%domain_size()
domain_centre = config%planar_mesh%domain_centre()
create_lbc_mesh = config%planar_mesh%create_lbc_mesh()
lbc_rim_depth = config%planar_mesh%lbc_rim_depth()
lbc_parent_mesh = config%planar_mesh%lbc_parent_mesh()
stretch_function = config%planar_mesh%stretch_function()

if (partition_mesh) then
max_stencil_depth = config%partitions%max_stencil_depth()
Expand All @@ -256,7 +256,8 @@ program planar_mesh_generator
target_null_island = config%rotation%target_null_island()
end if

if (apply_stretch_transform) then
if (stretch_function == STRETCH_FUNCTION_INFLATION .or. &
stretch_function == STRETCH_FUNCTION_POLYNOMIAL) then
transform_mesh = config%stretch_transform%transform_mesh()
end if

Expand Down Expand Up @@ -413,9 +414,9 @@ program planar_mesh_generator
call log_event( log_scratch_space, LOG_LEVEL_ERROR )
end if

if (apply_stretch_transform) then
! This enables support meshes to be created with a variable
! resolution stretching function.
! This enables support meshes to be created with a variable
! resolution stretching function.
if (configuration%namelist_exists('stretch_transform')) then
Comment thread
mo-rickywong marked this conversation as resolved.
Outdated
do j=1, n_meshes
if (trim(mesh_names(j)) == trim(transform_mesh)) then
fine_mesh_edge_cells_x = edge_cells_x(j)
Expand Down Expand Up @@ -748,6 +749,7 @@ program planar_mesh_generator
periodic_y = periodic_y, &
domain_size = domain_size, &
domain_centre = domain_centre, &
stretch_function = stretch_function, &
rotate_mesh = rotate_mesh, &
target_north_pole = set_north_pole, &
target_null_island = set_null_island )
Expand Down Expand Up @@ -784,6 +786,7 @@ program planar_mesh_generator
fine_mesh_edge_cells_y, &
periodic_x, periodic_y, &
domain_size, domain_centre, &
stretch_function = stretch_function, &
target_mesh_names = target_mesh_names, &
target_edge_cells_x = target_edge_cells_x, &
target_edge_cells_y = target_edge_cells_y, &
Expand Down
Loading
Loading