Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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'
/

&partitions
Expand Down
30 changes: 15 additions & 15 deletions mesh_tools/example/planar_mesh_gen.nml
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]
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
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]
compulsory=true
description=Depth (in cells) of outer region
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.
!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
Expand All @@ -605,6 +629,34 @@ range=0:
sort-key=Panel-A04
type=integer

[namelist:stretch_transform=n_cells_stretch_nsew]
compulsory=true
description=Depth (in cells) of stretch region
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.
!kind=default
length=4
range=0:
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.
!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
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
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