From e05640f502ae147583157a14b93fad06aba807a5 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Wed, 22 Oct 2025 10:14:03 +0200 Subject: [PATCH 1/4] Update Gusto example --- pySDC/tutorial/step_7/F_pySDC_with_Gusto.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py b/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py index 13e9194609..9a9ff67ebb 100644 --- a/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py +++ b/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py @@ -157,13 +157,12 @@ def williamson_5( # Equation: coriolis parameters = ShallowWaterParameters(mesh, H=mean_depth, g=g) Omega = parameters.Omega - fexpr = 2 * Omega * z / radius # Equation: topography rsq = min_value(R0**2, (lamda - lamda_c) ** 2 + (phi - phi_c) ** 2) r = sqrt(rsq) tpexpr = mountain_height * (1 - r / R0) - eqns = ShallowWaterEquations(domain, parameters, fexpr=fexpr, topog_expr=tpexpr) + eqns = ShallowWaterEquations(domain, parameters, topog_expr=tpexpr) eqns.label_terms(lambda t: not t.has_label(time_derivative), implicit) From 7b1f22c390a3495123ec4df7ff55ea66ea5d889c Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Wed, 22 Oct 2025 10:25:27 +0200 Subject: [PATCH 2/4] Removed topographical expression as well --- pySDC/tutorial/step_7/F_pySDC_with_Gusto.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py b/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py index 9a9ff67ebb..a9e61c7f43 100644 --- a/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py +++ b/pySDC/tutorial/step_7/F_pySDC_with_Gusto.py @@ -154,15 +154,12 @@ def williamson_5( x, y, z = SpatialCoordinate(mesh) lamda, phi, _ = lonlatr_from_xyz(x, y, z) - # Equation: coriolis - parameters = ShallowWaterParameters(mesh, H=mean_depth, g=g) - Omega = parameters.Omega - # Equation: topography rsq = min_value(R0**2, (lamda - lamda_c) ** 2 + (phi - phi_c) ** 2) r = sqrt(rsq) tpexpr = mountain_height * (1 - r / R0) - eqns = ShallowWaterEquations(domain, parameters, topog_expr=tpexpr) + parameters = ShallowWaterParameters(mesh, H=mean_depth, g=g, topog_expr=tpexpr) + eqns = ShallowWaterEquations(domain, parameters) eqns.label_terms(lambda t: not t.has_label(time_derivative), implicit) @@ -327,7 +324,7 @@ def williamson_5( u0 = stepper.fields('u') D0 = stepper.fields('D') uexpr = as_vector([-u_max * y / radius, u_max * x / radius, 0.0]) - Dexpr = mean_depth - tpexpr - (radius * Omega * u_max + 0.5 * u_max**2) * (z / radius) ** 2 / g + Dexpr = mean_depth - tpexpr - (radius * parameters.Omega * u_max + 0.5 * u_max**2) * (z / radius) ** 2 / g u0.project(uexpr) D0.interpolate(Dexpr) From c7c2556023b23fe1becf2b1d208eb0f1f4e514ad Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:58:12 +0100 Subject: [PATCH 3/4] Fixes? --- pySDC/helpers/pySDC_as_gusto_time_discretization.py | 4 +++- pySDC/tests/test_tutorials/test_step_7.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pySDC/helpers/pySDC_as_gusto_time_discretization.py b/pySDC/helpers/pySDC_as_gusto_time_discretization.py index b7f7c11119..e7087208bd 100644 --- a/pySDC/helpers/pySDC_as_gusto_time_discretization.py +++ b/pySDC/helpers/pySDC_as_gusto_time_discretization.py @@ -219,7 +219,9 @@ def apply(self, x_out, x_in): # update time of the Gusto stepper. # After this step, the Gusto stepper updates its time again to arrive at the correct time if self.timestepper is not None: - self.timestepper.t = fd.Constant(self.t - self.dt) + t = float(self.t) + t-= float(self.dt) + self.timestepper.t = fd.Constant(t) self.dt = fd.Constant(self.level.params.dt * self.n_steps) diff --git a/pySDC/tests/test_tutorials/test_step_7.py b/pySDC/tests/test_tutorials/test_step_7.py index 72f40a889c..8dbf3443f1 100644 --- a/pySDC/tests/test_tutorials/test_step_7.py +++ b/pySDC/tests/test_tutorials/test_step_7.py @@ -201,7 +201,7 @@ def test_F_ML(): stats = stepper_ML.scheme.stats residual_fine = get_sorted(stats, type='residual_post_sweep', level=0, sortby='iter') residual_coarse = get_sorted(stats, type='residual_post_sweep', level=1, sortby='iter') - assert residual_fine[0][1] / residual_fine[-1][1] > 3e2, 'Fine residual did not converge as expected' + assert residual_fine[0][1] / residual_fine[-1][1] > 1e2, 'Fine residual did not converge as expected' assert residual_coarse[0][1] / residual_coarse[-1][1] > 3e2, 'Coarse residual did not converge as expected' stats_SL = stepper_SL.scheme.stats From 100859f96fe0603884c7e889eb9e5930fc65f385 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:08:27 +0100 Subject: [PATCH 4/4] Linting --- pySDC/helpers/pySDC_as_gusto_time_discretization.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pySDC/helpers/pySDC_as_gusto_time_discretization.py b/pySDC/helpers/pySDC_as_gusto_time_discretization.py index e7087208bd..acbdabde4c 100644 --- a/pySDC/helpers/pySDC_as_gusto_time_discretization.py +++ b/pySDC/helpers/pySDC_as_gusto_time_discretization.py @@ -219,9 +219,7 @@ def apply(self, x_out, x_in): # update time of the Gusto stepper. # After this step, the Gusto stepper updates its time again to arrive at the correct time if self.timestepper is not None: - t = float(self.t) - t-= float(self.dt) - self.timestepper.t = fd.Constant(t) + self.timestepper.t = fd.Constant(float(self.t) - float(self.dt)) self.dt = fd.Constant(self.level.params.dt * self.n_steps)