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
21 changes: 10 additions & 11 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
edge_cells_x = 48,24
edge_cells_y = 24,12
domain_size = 48.0, 24.0
domain_centre = 0.0, 0.0
periodic_x = .false.
periodic_y = .false.
create_lbc_mesh = .true.
lbc_rim_depth = 1
lbc_parent_mesh = 'mesh_A'
apply_stretch_transform = .false.
stretch_function = 'polynomial'
/

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

&stretch_transform
cell_size_inner = 2.0, 2.0
cell_size_outer = 3.0, 3.0
n_cells_outer = 2, 2
cell_size_inner = 0.0135,0.0135
cell_size_outer = 0.036,0.036
n_cells_outer = 5, 5
n_cells_stretch = 5, 5
stretching_on = 'cell_centres'
poly_power = 3
transform_mesh = 'mesh_A'
/
38 changes: 28 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,23 @@ 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=poly_power: this == "'polynomial'";
value-titles=uniform, inflation, polynomial
values='uniform','inflation','polynomial'

[namelist:rotation]
compulsory=true
ns=namelist/mesh/Rotation
Expand Down Expand Up @@ -605,6 +612,17 @@ 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 vn30_t270(MacroUpgrade):
# Upgrade macro for <TICKET> by <Author>

BEFORE_TAG = "vn3.0"
AFTER_TAG = "vn3.0_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
14 changes: 7 additions & 7 deletions mesh_tools/source/planar_mesh_generator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,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 @@ -257,7 +255,7 @@ program planar_mesh_generator
call nml_obj%get_value( 'create_lbc_mesh', create_lbc_mesh )
call nml_obj%get_value( 'lbc_rim_depth', lbc_rim_depth )
call nml_obj%get_value( 'lbc_parent_mesh', lbc_parent_mesh )
call nml_obj%get_value( 'apply_stretch_transform', apply_stretch_transform )
call nml_obj%get_value( 'stretch_function', stretch_function )
end if

if (configuration%namelist_exists('stretch_transform')) then
Expand Down Expand Up @@ -418,9 +416,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 @@ -753,6 +751,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 @@ -789,6 +788,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