Skip to content

Commit

Permalink
Add config option for number of inactive layers
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Jun 24, 2021
1 parent e58e239 commit 8b5bd8c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions compass/ocean/tests/global_ocean/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def configure_global_ocean(test_case, mesh, init=None):
config.get('global_ocean', 'prefix')))

if init is not None and init.with_inactive_top_cells:
config.set('vertical_grid', 'inactive_top_cells', '1')
config.set('vertical_grid', 'vert_levels', '{}'.format(
config.getint('vertical_grid', 'vert_levels')+1))

Expand Down
1 change: 1 addition & 0 deletions compass/ocean/tests/global_ocean/mesh/qu240/qu240.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ min_layer_thickness = 3.0
# The maximum layer thickness
max_layer_thickness = 500.0

inactive_top_cells = 0

# options for global ocean testcases
[global_ocean]
Expand Down
12 changes: 10 additions & 2 deletions compass/ocean/vertical/grid_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ def generate_1d_grid(config):
interfaces : numpy.ndarray
A 1D array of positive depths for layer interfaces in meters
"""
offset = 0
if config.has_option('vertical_grid', 'inactive_top_cells'):
offset = config.getint('vertical_grid', 'inactive_top_cells')

section = config['vertical_grid']
grid_type = section.get('grid_type')
if grid_type == 'uniform':
vert_levels = section.getint('vert_levels')
interfaces = _generate_uniform(vert_levels)
interfaces = _generate_uniform(vert_levels - offset)
elif grid_type == 'tanh_dz':
vert_levels = section.getint('vert_levels')
min_layer_thickness = section.getfloat('min_layer_thickness')
max_layer_thickness = section.getfloat('max_layer_thickness')
bottom_depth = section.getfloat('bottom_depth')
interfaces = _create_tanh_dz_grid(vert_levels, bottom_depth,
interfaces = _create_tanh_dz_grid(vert_levels - offset,
bottom_depth,
min_layer_thickness,
max_layer_thickness)

Expand All @@ -47,6 +52,9 @@ def generate_1d_grid(config):
# renormalize to the requested range
interfaces = (bottom_depth/interfaces[-1]) * interfaces

if config.has_option('vertical_grid', 'inactive_top_cells'):
interfaces = np.append(np.zeros((offset)),interfaces)

return interfaces


Expand Down

0 comments on commit 8b5bd8c

Please sign in to comment.