Skip to content

Commit fed3cbe

Browse files
committed
Fixup rebase with convergence changes
1 parent 03e90aa commit fed3cbe

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

polaris/ocean/convergence/forward.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(self, component, name, subdir, refinement_factor, mesh, init,
8888
config_model=config_model)
8989

9090
self.add_input_file(
91-
filename=init_filename,
91+
filename='init.nc',
9292
work_dir_target=f'{init.path}/initial_state.nc')
9393

9494
if forcing:

polaris/ocean/tasks/drying_slope/convergence/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from polaris import Step, Task
66
from polaris.config import PolarisConfigParser
7+
from polaris.ocean.convergence import get_resolution_for_task
78
from polaris.ocean.resolution import resolution_to_subdir
89
from polaris.ocean.tasks.drying_slope.convergence.analysis import Analysis
910
from polaris.ocean.tasks.drying_slope.convergence.forward import Forward
@@ -57,12 +58,13 @@ def __init__(self, component, subdir, group_dir, config,
5758
super().__init__(component=component, name=name, subdir=subdir)
5859

5960
self.damping_coeffs = []
60-
self.resolutions = config.getlist('drying_slope_convergence',
61-
'resolutions', dtype=float)
62-
6361
analysis_dependencies: Dict[str, Dict[float, Step]] = (
6462
dict(mesh=dict(), init=dict(), forward=dict()))
65-
for resolution in self.resolutions:
63+
refinement_factors = config.getlist(
64+
'convergence', 'refinement_factors_space', dtype=float)
65+
for refinement_factor in refinement_factors:
66+
resolution = get_resolution_for_task(
67+
config, refinement_factor, refinement='both')
6668
mesh_name = resolution_to_subdir(resolution)
6769
init_dir = f'{group_dir}/barotropic/{mesh_name}/init'
6870
if init_dir in component.steps:
@@ -85,7 +87,7 @@ def __init__(self, component, subdir, group_dir, config,
8587
else:
8688
forward_step = Forward(component=component,
8789
name=f'{step_name}_{mesh_name}',
88-
resolution=resolution,
90+
refinement_factor=refinement_factor,
8991
subdir=forward_dir,
9092
init=init_step,
9193
damping_coeff=damping_coeff,
@@ -98,7 +100,6 @@ def __init__(self, component, subdir, group_dir, config,
98100

99101
self.add_step(Analysis(
100102
component=component,
101-
resolutions=self.resolutions,
102103
subdir=f'{subdir}/analysis',
103104
damping_coeff=damping_coeff,
104105
dependencies=analysis_dependencies))

polaris/ocean/tasks/drying_slope/convergence/analysis.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import xarray as xr
44
from scipy.interpolate import interp1d
55

6-
from polaris.ocean.convergence import ConvergenceAnalysis
6+
from polaris.ocean.convergence.analysis import ConvergenceAnalysis
77

88

99
class Analysis(ConvergenceAnalysis):
@@ -16,7 +16,7 @@ class Analysis(ConvergenceAnalysis):
1616
damping_coeff : float
1717
The Rayleigh damping coefficient used for the forward runs
1818
"""
19-
def __init__(self, component, resolutions, subdir, dependencies,
19+
def __init__(self, component, subdir, dependencies,
2020
damping_coeff):
2121
"""
2222
Create the step
@@ -26,9 +26,6 @@ def __init__(self, component, resolutions, subdir, dependencies,
2626
component : polaris.Component
2727
The component the step belongs to
2828
29-
resolutions : list of float
30-
The resolutions of the meshes that have been run
31-
3229
subdir : str
3330
The subdirectory that the step resides in
3431
@@ -43,7 +40,6 @@ def __init__(self, component, resolutions, subdir, dependencies,
4340
'title': 'SSH',
4441
'zidx': None}]
4542
super().__init__(component=component, subdir=subdir,
46-
resolutions=resolutions,
4743
dependencies=dependencies,
4844
convergence_vars=convergence_vars)
4945

polaris/ocean/tasks/drying_slope/convergence/forward.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import time
22

33
from polaris.mesh.planar import compute_planar_hex_nx_ny
4-
from polaris.ocean.convergence import ConvergenceForward
4+
from polaris.ocean.convergence import get_resolution_for_task
5+
from polaris.ocean.convergence.forward import ConvergenceForward
56

67

78
class Forward(ConvergenceForward):
@@ -14,8 +15,8 @@ class Forward(ConvergenceForward):
1415
resolution : float
1516
The resolution of the test case in km
1617
"""
17-
def __init__(self, component, name, resolution, subdir, init,
18-
damping_coeff, coord_type, method,
18+
def __init__(self, component, name, refinement_factor, subdir, init,
19+
damping_coeff, coord_type, method, refinement='both',
1920
drag_type='constant_and_rayleigh'):
2021
"""
2122
Create a new test case
@@ -25,9 +26,6 @@ def __init__(self, component, name, resolution, subdir, init,
2526
component : polaris.Component
2627
The component the step belongs to
2728
28-
resolution : km
29-
The resolution of the test case in km
30-
3129
subdir : str
3230
The subdirectory that the step belongs to
3331
@@ -67,14 +65,16 @@ def __init__(self, component, name, resolution, subdir, init,
6765
options['config_tidal_forcing_model'] = 'monochromatic'
6866
super().__init__(component=component,
6967
name=name, subdir=subdir,
70-
resolution=resolution, mesh=init, init=init,
68+
refinement_factor=refinement_factor,
69+
mesh=init, init=init,
7170
package='polaris.ocean.tasks.drying_slope',
7271
yaml_filename='forward.yaml',
73-
init_filename='initial_state.nc',
74-
graph_filename='culled_graph.info',
72+
graph_target=f'{init.path}/culled_graph.info',
7573
output_filename='output.nc',
7674
forcing=True, options=options,
7775
validate_vars=['layerThickness', 'normalVelocity'])
76+
self.resolution = get_resolution_for_task(
77+
self.config, self.refinement_factor, refinement=self.refinement)
7878

7979
def compute_cell_count(self):
8080
"""

polaris/ocean/tasks/drying_slope/drying_slope.cfg

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ manning_coefficient = 5.0e-2
110110
# thickness
111111
min_column_thickness = 0.05
112112

113-
# config options for drying slope convergence task
114-
[drying_slope_convergence]
115-
116-
# horizontal resolutions in km
117-
resolutions = 0.25, 0.5, 1, 2
118-
119113
[convergence]
120114

121115
# Evaluation time for convergence analysis (in hours)
@@ -127,6 +121,13 @@ convergence_thresh = -0.527
127121
# Type of error to compute
128122
error_type = l2
129123

124+
# the base mesh resolution (km) to which refinement_factors
125+
# are applied if refinement is 'space' or 'both' on a planar mesh
126+
base_resolution = 0.5
127+
128+
# refinement factors for a planar mesh applied to either space or time
129+
refinement_factors_space = 4., 2., 1., 0.5
130+
130131
# config options for convergence forward steps
131132
[convergence_forward]
132133

0 commit comments

Comments
 (0)