From 432adbebe2b7e03363c7a80a86933f4e7de6c700 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Sep 2024 10:28:51 -0500 Subject: [PATCH 01/10] Add del2 and del4 tasks --- .../tasks/manufactured_solution/__init__.py | 37 +++++++++++++++++-- .../tasks/manufactured_solution/forward.py | 31 +++++++++++++++- .../tasks/manufactured_solution/forward.yaml | 9 ++--- 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index 965fc0a9e..95da1f703 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -35,6 +35,14 @@ def add_manufactured_solution_tasks(component): component.add_task(ManufacturedSolution(component=component, config=config, refinement=refinement)) + component.add_task(ManufacturedSolution(component=component, + config=config, + refinement='space', + del2=True)) + component.add_task(ManufacturedSolution(component=component, + config=config, + refinement='space', + del4=True)) class ManufacturedSolution(Task): @@ -42,7 +50,8 @@ class ManufacturedSolution(Task): The convergence test case using the method of manufactured solutions """ - def __init__(self, component, config, refinement='both'): + def __init__(self, component, config, refinement='both', del2=False, + del4=False): """ Create the test case @@ -56,11 +65,32 @@ def __init__(self, component, config, refinement='both'): refinement : str, optional Whether to refine in space, time or both space and time + + del2 : bool + Whether to evaluate the momentum del2 operator + + del4 : bool + Whether to evaluate the momentum del4 operator """ - name = f'manufactured_solution_convergence_{refinement}' basedir = 'planar/manufactured_solution' subdir = f'{basedir}/convergence_{refinement}' + name = f'manufactured_solution_convergence_{refinement}' + if del2: + name = f'{name}_del2' + subdir = f'{subdir}/del2' + if del4: + del4 = False + print('Manufactured solution test does not currently support' + 'both del2 and del4 convergence; testing del2 alone.') + elif del4: + name = f'{name}_del4' + subdir = f'{subdir}/del4' + else: + name = f'{name}_default' + subdir = f'{subdir}/default' + config_filename = 'manufactured_solution.cfg' + super().__init__(component=component, name=name, subdir=subdir) self.set_shared_config(config, link=config_filename) @@ -108,7 +138,8 @@ def __init__(self, component, config, refinement='both'): refinement_factor=refinement_factor, name=f'forward_{mesh_name}_{timestep}s', subdir=subdir, - init=init_step) + init=init_step, + del2=del2, del4=del4) forward_step.set_shared_config( config, link=config_filename) self.add_step(forward_step, symlink=symlink) diff --git a/polaris/ocean/tasks/manufactured_solution/forward.py b/polaris/ocean/tasks/manufactured_solution/forward.py index 012bea98f..012b2a3d9 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.py +++ b/polaris/ocean/tasks/manufactured_solution/forward.py @@ -21,9 +21,18 @@ class Forward(ConvergenceForward): refinement : str Refinement type. One of 'space', 'time' or 'both' indicating both space and time + + resolution : float + The resolution of the test case in km + + del2 : bool + Whether to evaluate the momentum del2 operator + + del4 : bool + Whether to evaluate the momentum del4 operator """ def __init__(self, component, name, refinement_factor, subdir, - init, refinement='both'): + init, refinement='both', del2=False, del4=False): """ Create a new test case @@ -47,6 +56,12 @@ def __init__(self, component, name, refinement_factor, subdir, refinement : str, optional Refinement type. One of 'space', 'time' or 'both' indicating both space and time + + del2 : bool + Whether to evaluate the momentum del2 operator + + del4 : bool + Whether to evaluate the momentum del4 operator """ super().__init__(component=component, name=name, subdir=subdir, @@ -68,6 +83,8 @@ def setup(self): # TODO: remove as soon as Omega supports I/O streams if model == 'omega': self.add_input_file(filename='OmegaMesh.nc', target='init.nc') + self.del2 = del2 + self.del4 = del4 def compute_cell_count(self): """ @@ -107,5 +124,15 @@ def dynamic_model_config(self, at_setup): 'config_manufactured_solution_wavelength_x': float(exact_solution.lambda_x), 'config_manufactured_solution_wavelength_y': - float(exact_solution.lambda_y)} + float(exact_solution.lambda_y), + 'config_disable_vel_hmix': + True} + + if self.del2: + options['config_disable_vel_hmix'] = False + options['config_use_mom_del2'] = True + if self.del4: + options['config_disable_vel_hmix'] = False + options['config_use_mom_del4'] = True + self.add_model_config_options(options, config_model='mpas-ocean') diff --git a/polaris/ocean/tasks/manufactured_solution/forward.yaml b/polaris/ocean/tasks/manufactured_solution/forward.yaml index f7aefa138..b60885105 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.yaml +++ b/polaris/ocean/tasks/manufactured_solution/forward.yaml @@ -29,12 +29,11 @@ mpas-ocean: config_implicit_constant_bottom_drag_coeff: 0.0 manufactured_solution: config_use_manufactured_solution: true - debug: - config_disable_vel_hmix: true + hmix_del2: + config_mom_del2: 1000. + hmix_del4: + config_mom_del4: 1.e10 Omega: - Tendencies: - VelDiffTendencyEnable: false - VelHyperDiffTendencyEnable: false Dimension: NVertLevels: 1 From 82a7277c19df0f8ed724a375a6f999ce1c6cb063 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Fri, 20 Sep 2024 13:47:26 -0500 Subject: [PATCH 02/10] Share init steps --- polaris/ocean/tasks/manufactured_solution/__init__.py | 2 +- polaris/ocean/tasks/manufactured_solution/init.py | 5 ++--- polaris/ocean/tasks/manufactured_solution/viz.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index 95da1f703..8c3f10b2d 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -136,7 +136,7 @@ def __init__(self, component, config, refinement='both', del2=False, component=component, refinement=refinement, refinement_factor=refinement_factor, - name=f'forward_{mesh_name}_{timestep}s', + name=f'{forward_name}_{timestep}s', subdir=subdir, init=init_step, del2=del2, del4=del4) diff --git a/polaris/ocean/tasks/manufactured_solution/init.py b/polaris/ocean/tasks/manufactured_solution/init.py index d08cf15fc..09c9b49d0 100644 --- a/polaris/ocean/tasks/manufactured_solution/init.py +++ b/polaris/ocean/tasks/manufactured_solution/init.py @@ -22,7 +22,7 @@ class Init(OceanIOStep): resolution : float The resolution of the test case in km """ - def __init__(self, component, resolution, subdir): + def __init__(self, component, resolution, subdir, name): """ Create the step @@ -37,9 +37,8 @@ def __init__(self, component, resolution, subdir): taskdir : str The subdirectory that the task belongs to """ - mesh_name = resolution_to_subdir(resolution) super().__init__(component=component, - name=f'init_{mesh_name}', + name=name, subdir=subdir) self.resolution = resolution diff --git a/polaris/ocean/tasks/manufactured_solution/viz.py b/polaris/ocean/tasks/manufactured_solution/viz.py index 86d287b27..53e9d7728 100644 --- a/polaris/ocean/tasks/manufactured_solution/viz.py +++ b/polaris/ocean/tasks/manufactured_solution/viz.py @@ -109,7 +109,7 @@ def setup(self): forward = dependencies['forward'][refinement_factor] self.add_input_file( filename=f'mesh_r{refinement_factor:02g}.nc', - work_dir_target=f'{base_mesh.path}/base_mesh.nc') + work_dir_target=f'{base_mesh.path}/culled_mesh.nc') self.add_input_file( filename=f'init_r{refinement_factor:02g}.nc', work_dir_target=f'{init.path}/initial_state.nc') From 062577eb7b454b0705cea8ca299cf145f151230c Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 1 Oct 2024 09:37:49 -0500 Subject: [PATCH 03/10] fixup omega cfg options --- .../tasks/manufactured_solution/forward.py | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/forward.py b/polaris/ocean/tasks/manufactured_solution/forward.py index 012b2a3d9..1dfc3e086 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.py +++ b/polaris/ocean/tasks/manufactured_solution/forward.py @@ -72,6 +72,8 @@ def __init__(self, component, name, refinement_factor, subdir, graph_target=f'{init.path}/culled_graph.info', output_filename='output.nc', validate_vars=['layerThickness', 'normalVelocity']) + self.del2 = del2 + self.del4 = del4 def setup(self): """ @@ -83,8 +85,6 @@ def setup(self): # TODO: remove as soon as Omega supports I/O streams if model == 'omega': self.add_input_file(filename='OmegaMesh.nc', target='init.nc') - self.del2 = del2 - self.del4 = del4 def compute_cell_count(self): """ @@ -119,20 +119,25 @@ def dynamic_model_config(self, at_setup): super().dynamic_model_config(at_setup=at_setup) exact_solution = ExactSolution(self.config) - options = {'config_manufactured_solution_amplitude': - float(exact_solution.eta0), - 'config_manufactured_solution_wavelength_x': - float(exact_solution.lambda_x), - 'config_manufactured_solution_wavelength_y': - float(exact_solution.lambda_y), - 'config_disable_vel_hmix': - True} - + mpas_options = {'config_manufactured_solution_amplitude': + float(exact_solution.eta0), + 'config_manufactured_solution_wavelength_x': + float(exact_solution.lambda_x), + 'config_manufactured_solution_wavelength_y': + float(exact_solution.lambda_y)} + shared_options = {} if self.del2: - options['config_disable_vel_hmix'] = False - options['config_use_mom_del2'] = True - if self.del4: - options['config_disable_vel_hmix'] = False - options['config_use_mom_del4'] = True - - self.add_model_config_options(options, config_model='mpas-ocean') + mpas_options['config_disable_vel_hmix'] = False + shared_options['config_use_mom_del2'] = True + shared_options['config_use_mom_del4'] = False + elif self.del4: + mpas_options['config_disable_vel_hmix'] = False + shared_options['config_use_mom_del2'] = False + shared_options['config_use_mom_del4'] = True + else: + mpas_options['config_disable_vel_hmix'] = True + shared_options['config_use_mom_del2'] = False + shared_options['config_use_mom_del4'] = False + + self.add_model_config_options(mpas_options, config_model='mpas-ocean') + self.add_model_config_options(shared_options, config_model='ocean') From 70f3b97e3125e1bb7c965dd2b0de65ea1660f3e6 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 1 Oct 2024 14:10:21 -0500 Subject: [PATCH 04/10] Add manufactured tests to convergence suite --- polaris/ocean/suites/convergence.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polaris/ocean/suites/convergence.txt b/polaris/ocean/suites/convergence.txt index 9a92ef47e..af9940a77 100644 --- a/polaris/ocean/suites/convergence.txt +++ b/polaris/ocean/suites/convergence.txt @@ -1,5 +1,7 @@ ocean/planar/inertial_gravity_wave/convergence_both -ocean/planar/manufactured_solution/convergence_both +ocean/planar/manufactured_solution/convergence_both/default +ocean/planar/manufactured_solution/convergence_both/del2 +ocean/planar/manufactured_solution/convergence_both/del4 ocean/spherical/icos/correlated_tracers_2d cached: icos_base_mesh_60km icos_base_mesh_120km icos_base_mesh_240km icos_base_mesh_480km ocean/spherical/qu/correlated_tracers_2d From d3abf4dd3cd6330e0320196240e3474a773d770a Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 1 Oct 2024 14:17:00 -0500 Subject: [PATCH 05/10] Update docs --- .../ocean/tasks/manufactured_solution.md | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/users_guide/ocean/tasks/manufactured_solution.md b/docs/users_guide/ocean/tasks/manufactured_solution.md index 866f2d85d..3d58a1ae8 100644 --- a/docs/users_guide/ocean/tasks/manufactured_solution.md +++ b/docs/users_guide/ocean/tasks/manufactured_solution.md @@ -16,9 +16,9 @@ Currently, the there is only one task, the convergence test from These tasks support both MPAS-Ocean and Omega. -(ocean-manufactured-solution-convergence)= +(ocean-manufactured-solution-default)= -## convergence +## default ### description @@ -127,3 +127,22 @@ conv_thresh = 1.8 The number of cores is determined according to the config options ``max_cells_per_core`` and ``goal_cells_per_core``. + +(ocean-manufactured-solution-del2)= + +## del2 + +### description + +All settings are the same as the {ref}`ocean-manufactured-solution-default` case +except laplacian viscosity is turned on. + +(ocean-manufactured-solution-del4)= + +## del4 + +### description + +All settings are the same as the {ref}`ocean-manufactured-solution-default` case +except hyperviscosity is turned on. The expected convergence should not be +significantly different from the {ref}`ocean-manufactured-solution-default` case. From fd98b1813b58fce56dd3836c900ffccafa18596b Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Sun, 8 Dec 2024 09:47:08 -0600 Subject: [PATCH 06/10] Fixup rebase onto convergence changes --- polaris/ocean/tasks/manufactured_solution/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index 8c3f10b2d..bdf6a0059 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -37,11 +37,11 @@ def add_manufactured_solution_tasks(component): refinement=refinement)) component.add_task(ManufacturedSolution(component=component, config=config, - refinement='space', + refinement='both', del2=True)) component.add_task(ManufacturedSolution(component=component, config=config, - refinement='space', + refinement='both', del4=True)) @@ -116,7 +116,7 @@ def __init__(self, component, config, refinement='both', del2=False, init_step = component.steps[subdir] else: init_step = Init(component=component, resolution=resolution, - subdir=subdir) + name=f'init_{mesh_name}', subdir=subdir) init_step.set_shared_config(self.config, link=config_filename) if resolution not in resolutions: self.add_step(init_step, symlink=symlink) @@ -136,7 +136,7 @@ def __init__(self, component, config, refinement='both', del2=False, component=component, refinement=refinement, refinement_factor=refinement_factor, - name=f'{forward_name}_{timestep}s', + name=f'forward_{mesh_name}_{timestep}s', subdir=subdir, init=init_step, del2=del2, del4=del4) From e2c8782aee2a172bd6bd789c7c09c7fe0b4010bc Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Dec 2024 15:23:44 -0600 Subject: [PATCH 07/10] Add manufactured solution test suite --- polaris/ocean/suites/manufactured_solution.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 polaris/ocean/suites/manufactured_solution.txt diff --git a/polaris/ocean/suites/manufactured_solution.txt b/polaris/ocean/suites/manufactured_solution.txt new file mode 100644 index 000000000..ff95dcc96 --- /dev/null +++ b/polaris/ocean/suites/manufactured_solution.txt @@ -0,0 +1,5 @@ +ocean/planar/manufactured_solution/convergence_space/default +# ocean/planar/manufactured_solution/convergence_time/default +ocean/planar/manufactured_solution/convergence_both/default +ocean/planar/manufactured_solution/convergence_both/del2 +ocean/planar/manufactured_solution/convergence_both/del4 From 686658914de2f79fa526c45ab85438cbe09de9be Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Dec 2024 15:24:39 -0600 Subject: [PATCH 08/10] Fixup forward step paths --- .../ocean/tasks/manufactured_solution/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/__init__.py b/polaris/ocean/tasks/manufactured_solution/__init__.py index bdf6a0059..b6cac98c2 100644 --- a/polaris/ocean/tasks/manufactured_solution/__init__.py +++ b/polaris/ocean/tasks/manufactured_solution/__init__.py @@ -75,19 +75,20 @@ def __init__(self, component, config, refinement='both', del2=False, basedir = 'planar/manufactured_solution' subdir = f'{basedir}/convergence_{refinement}' name = f'manufactured_solution_convergence_{refinement}' + if del2: - name = f'{name}_del2' - subdir = f'{subdir}/del2' + test_name = 'del2' if del4: del4 = False print('Manufactured solution test does not currently support' 'both del2 and del4 convergence; testing del2 alone.') elif del4: - name = f'{name}_del4' - subdir = f'{subdir}/del4' + test_name = 'del4' else: - name = f'{name}_default' - subdir = f'{subdir}/default' + test_name = 'default' + + name = f'{name}_{test_name}' + subdir = f'{subdir}/{test_name}' config_filename = 'manufactured_solution.cfg' @@ -127,7 +128,7 @@ def __init__(self, component, config, refinement='both', del2=False, timestep = ceil(timestep) timesteps.append(timestep) - subdir = f'{basedir}/forward/{mesh_name}_{timestep}s' + subdir = f'{basedir}/{test_name}/forward/{mesh_name}_{timestep}s' symlink = f'forward/{mesh_name}_{timestep}s' if subdir in component.steps: forward_step = component.steps[subdir] From 9e8fbe6890e5adeccf1a0cbfde8a6804da1e3d3c Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 19 Dec 2024 16:02:32 -0600 Subject: [PATCH 09/10] Fixup linting --- polaris/ocean/tasks/manufactured_solution/init.py | 1 - 1 file changed, 1 deletion(-) diff --git a/polaris/ocean/tasks/manufactured_solution/init.py b/polaris/ocean/tasks/manufactured_solution/init.py index 09c9b49d0..fa820b727 100644 --- a/polaris/ocean/tasks/manufactured_solution/init.py +++ b/polaris/ocean/tasks/manufactured_solution/init.py @@ -5,7 +5,6 @@ from polaris.mesh.planar import compute_planar_hex_nx_ny from polaris.ocean.model import OceanIOStep -from polaris.ocean.resolution import resolution_to_subdir from polaris.ocean.tasks.manufactured_solution.exact_solution import ( ExactSolution, ) From b2fdb660fb4e9f711b36edbb780c35eda4ad182d Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 2 Jan 2025 10:42:37 -0600 Subject: [PATCH 10/10] Remove all omega yaml options from manufactured soln --- polaris/ocean/tasks/manufactured_solution/forward.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/polaris/ocean/tasks/manufactured_solution/forward.yaml b/polaris/ocean/tasks/manufactured_solution/forward.yaml index b60885105..d5ca98c31 100644 --- a/polaris/ocean/tasks/manufactured_solution/forward.yaml +++ b/polaris/ocean/tasks/manufactured_solution/forward.yaml @@ -33,7 +33,3 @@ mpas-ocean: config_mom_del2: 1000. hmix_del4: config_mom_del4: 1.e10 - -Omega: - Dimension: - NVertLevels: 1