From 416f3d165659be78d7633f1307fc1c4345a6d8c2 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 25 Jul 2023 11:28:08 +0100 Subject: [PATCH 1/5] deleted is_loopy_kernel=True arguments --- gusto/recovery/recovery_kernels.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gusto/recovery/recovery_kernels.py b/gusto/recovery/recovery_kernels.py index efc3435bd..1356ea7d6 100644 --- a/gusto/recovery/recovery_kernels.py +++ b/gusto/recovery/recovery_kernels.py @@ -58,8 +58,7 @@ def apply(self, v_out, weighting, v_in): par_loop(self._kernel, dx, {"vo": (v_out, INC), "w": (weighting, READ), - "v": (v_in, READ)}, - is_loopy_kernel=True) + "v": (v_in, READ)}) class AverageWeightings(object): @@ -103,8 +102,7 @@ def apply(self, w): lives in the continuous target space. """ par_loop(self._kernel, dx, - {"w": (w, INC)}, - is_loopy_kernel=True) + {"w": (w, INC)}) class BoundaryRecoveryExtruded(): @@ -167,7 +165,6 @@ def apply(self, x_out, x_in): par_loop(self._bot_kernel, dx, args={"x_out": (x_out, WRITE), "x_in": (x_in, READ)}, - is_loopy_kernel=True, iteration_region=ON_BOTTOM) @@ -240,7 +237,6 @@ def apply(self, x_out, x_in): par_loop(self._top_kernel, dx, args={"x_out": (x_out, WRITE), "x_in": (x_in, READ)}, - is_loopy_kernel=True, iteration_region=ON_TOP) par_loop(self._bot_kernel, dx, args={"x_out": (x_out, WRITE), @@ -521,5 +517,4 @@ def apply(self, v_DG1_old, v_DG1, act_coords, eff_coords, num_ext): "DG1": (v_DG1, WRITE), "ACT_COORDS": (act_coords, READ), "EFF_COORDS": (eff_coords, READ), - "NUM_EXT": (num_ext, READ)}, - is_loopy_kernel=True) + "NUM_EXT": (num_ext, READ)}) From 498f38ec34b73baf9ac652bfa9da1a204019d885 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 25 Jul 2023 11:44:14 +0100 Subject: [PATCH 2/5] change .split() to .subfunctions() --- gusto/fields.py | 2 +- gusto/initialisation_tools.py | 8 +++--- gusto/physics.py | 32 +++++++++++------------ gusto/preconditioners.py | 20 +++++++------- gusto/timeloop.py | 4 +-- unit-tests/fml_tests/test_replace_perp.py | 6 ++--- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/gusto/fields.py b/gusto/fields.py index cfa70cb08..1d64e9c59 100644 --- a/gusto/fields.py +++ b/gusto/fields.py @@ -34,7 +34,7 @@ def add_field(self, name, space, subfield_names=None): if len(space) > 1: assert len(space) == len(subfield_names) - for field_name, field in zip(subfield_names, value.split()): + for field_name, field in zip(subfield_names, value.subfunctions()): setattr(self, field_name, field) field.rename(field_name) self.fields.append(field) diff --git a/gusto/initialisation_tools.py b/gusto/initialisation_tools.py index 74e1126fa..f66149d9e 100644 --- a/gusto/initialisation_tools.py +++ b/gusto/initialisation_tools.py @@ -133,7 +133,7 @@ def incompressible_hydrostatic_balance(equation, b0, p0, top=False, params=None) solve(a == L, w1, bcs=bcs, solver_parameters=params) - v, pprime = w1.split() + v, pprime = w1.subfunctions() p0.project(pprime) @@ -235,13 +235,13 @@ def compressible_hydrostatic_balance(equation, theta0, rho0, exner0=None, options_prefix="exner_solver") exner_solver.solve() - v, exner = w.split() + v, exner = w.subfunctions() if exner0 is not None: exner0.assign(exner) if solve_for_rho: w1 = Function(W) - v, rho = w1.split() + v, rho = w1.subfunctions() rho.interpolate(thermodynamics.rho(parameters, theta0, exner)) v, rho = split(w1) dv, dexner = TestFunctions(W) @@ -256,7 +256,7 @@ def compressible_hydrostatic_balance(equation, theta0, rho0, exner0=None, rhosolver = NonlinearVariationalSolver(rhoproblem, solver_parameters=params, options_prefix="rhosolver") rhosolver.solve() - v, rho_ = w1.split() + v, rho_ = w1.subfunctions() rho0.assign(rho_) else: rho0.interpolate(thermodynamics.rho(parameters, theta0, exner)) diff --git a/gusto/physics.py b/gusto/physics.py index f8240d4a1..9ae262f2f 100644 --- a/gusto/physics.py +++ b/gusto/physics.py @@ -108,8 +108,8 @@ def __init__(self, equation, vapour_name='water_vapour', # Vapour and cloud variables are needed for every form of this scheme cloud_idx = equation.field_names.index(cloud_name) vap_idx = equation.field_names.index(vapour_name) - cloud_water = self.X.split()[cloud_idx] - water_vapour = self.X.split()[vap_idx] + cloud_water = self.X.subfunctions()[cloud_idx] + water_vapour = self.X.subfunctions()[vap_idx] # Indices of variables in mixed function space V_idxs = [vap_idx, cloud_idx] @@ -119,8 +119,8 @@ def __init__(self, equation, vapour_name='water_vapour', if isinstance(equation, CompressibleEulerEquations): rho_idx = equation.field_names.index('rho') theta_idx = equation.field_names.index('theta') - rho = self.X.split()[rho_idx] - theta = self.X.split()[theta_idx] + rho = self.X.subfunctions()[rho_idx] + theta = self.X.subfunctions()[theta_idx] if latent_heat: V_idxs.append(theta_idx) @@ -146,7 +146,7 @@ def __init__(self, equation, vapour_name='water_vapour', if (active_tracer.phase == Phases.liquid and active_tracer.chemical == 'H2O' and active_tracer.name != cloud_name): liq_idx = equation.field_names.index(active_tracer.name) - liquid_water += self.X.split()[liq_idx] + liquid_water += self.X.subfunctions()[liq_idx] # define some parameters as attributes self.dt = Constant(0.0) @@ -280,7 +280,7 @@ def __init__(self, equation, rain_name, domain, transport_method, self.X = Function(equation.X.function_space()) rain_idx = equation.field_names.index(rain_name) - rain = self.X.split()[rain_idx] + rain = self.X.subfunctions()[rain_idx] Vu = domain.spaces("HDiv") # TODO: there must be a better way than forcing this into the equation @@ -314,7 +314,7 @@ def __init__(self, equation, rain_name, domain, transport_method, # this advects the third moment M3 of the raindrop # distribution, which corresponds to the mean mass rho_idx = equation.field_names.index('rho') - rho = self.X.split()[rho_idx] + rho = self.X.subfunctions()[rho_idx] rho_w = Constant(1000.0) # density of liquid water # assume n(D) = n_0 * D^mu * exp(-Lambda*D) # n_0 = N_r * Lambda^(1+mu) / gamma(1 + mu) @@ -451,8 +451,8 @@ def evaluate(self, x_in, dt): """ # Update the values of internal variables self.dt.assign(dt) - self.rain.assign(x_in.split()[self.rain_idx]) - self.cloud_water.assign(x_in.split()[self.cloud_idx]) + self.rain.assign(x_in.subfunctions()[self.rain_idx]) + self.cloud_water.assign(x_in.subfunctions()[self.cloud_idx]) # Evaluate the source self.source.assign(self.source_interpolator.interpolate()) @@ -509,8 +509,8 @@ def __init__(self, equation, rain_name='rain', vapour_name='water_vapour', # Vapour and cloud variables are needed for every form of this scheme rain_idx = equation.field_names.index(rain_name) vap_idx = equation.field_names.index(vapour_name) - rain = self.X.split()[rain_idx] - water_vapour = self.X.split()[vap_idx] + rain = self.X.subfunctions()[rain_idx] + water_vapour = self.X.subfunctions()[vap_idx] # Indices of variables in mixed function space V_idxs = [rain_idx, vap_idx] @@ -520,8 +520,8 @@ def __init__(self, equation, rain_name='rain', vapour_name='water_vapour', if isinstance(equation, CompressibleEulerEquations): rho_idx = equation.field_names.index('rho') theta_idx = equation.field_names.index('theta') - rho = self.X.split()[rho_idx] - theta = self.X.split()[theta_idx] + rho = self.X.subfunctions()[rho_idx] + theta = self.X.subfunctions()[theta_idx] if latent_heat: V_idxs.append(theta_idx) @@ -543,7 +543,7 @@ def __init__(self, equation, rain_name='rain', vapour_name='water_vapour', if (active_tracer.phase == Phases.liquid and active_tracer.chemical == 'H2O' and active_tracer.name != rain_name): liq_idx = equation.field_names.index(active_tracer.name) - liquid_water += self.X.split()[liq_idx] + liquid_water += self.X.subfunctions()[liq_idx] # define some parameters as attributes self.dt = Constant(0.0) @@ -761,10 +761,10 @@ def evaluate(self, x_in, dt): interval for the scheme. """ if self.convective_feedback: - self.D.assign(x_in.split()[self.VD_idx]) + self.D.assign(x_in.subfunctions()[self.VD_idx]) if self.time_varying_saturation: self.saturation_curve.interpolate(self.saturation_computation(x_in)) if self.set_tau_to_dt: self.tau.assign(dt) - self.water_v.assign(x_in.split()[self.Vv_idx]) + self.water_v.assign(x_in.subfunctions()[self.Vv_idx]) self.source.assign(self.source_interpolator.interpolate()) diff --git a/gusto/preconditioners.py b/gusto/preconditioners.py index deee1e7b9..7bd5bcf1d 100644 --- a/gusto/preconditioners.py +++ b/gusto/preconditioners.py @@ -244,8 +244,8 @@ def _reconstruction_calls(self, split_mixed_op, split_trace_op): K_1 = Tensor(split_trace_op[(0, id1)]) # Split functions and reconstruct each bit separately - split_residual = self.broken_residual.split() - split_sol = self.broken_solution.split() + split_residual = self.broken_residual.subfunctions() + split_sol = self.broken_solution.subfunctions() g = AssembledVector(split_residual[id0]) f = AssembledVector(split_residual[id1]) sigma = split_sol[id0] @@ -316,8 +316,8 @@ def apply(self, pc, x, y): # Transfer unbroken_rhs into broken_rhs # NOTE: Scalar space is already "broken" so no need for # any projections - unbroken_scalar_data = self.unbroken_residual.split()[self.pidx] - broken_scalar_data = self.broken_residual.split()[self.pidx] + unbroken_scalar_data = self.unbroken_residual.subfunctions()[self.pidx] + broken_scalar_data = self.broken_residual.subfunctions()[self.pidx] unbroken_scalar_data.dat.copy(broken_scalar_data.dat) with timed_region("VertHybridRHS"): @@ -328,8 +328,8 @@ def apply(self, pc, x, y): # basis functions that add together to give unbroken # basis functions. - unbroken_res_hdiv = self.unbroken_residual.split()[self.vidx] - broken_res_hdiv = self.broken_residual.split()[self.vidx] + unbroken_res_hdiv = self.unbroken_residual.subfunctions()[self.vidx] + broken_res_hdiv = self.broken_residual.subfunctions()[self.vidx] broken_res_hdiv.assign(0) self.average_kernel.apply(broken_res_hdiv, self.weight, unbroken_res_hdiv) @@ -351,13 +351,13 @@ def apply(self, pc, x, y): with timed_region("VertHybridRecover"): # Project the broken solution into non-broken spaces - broken_pressure = self.broken_solution.split()[self.pidx] - unbroken_pressure = self.unbroken_solution.split()[self.pidx] + broken_pressure = self.broken_solution.subfunctions()[self.pidx] + unbroken_pressure = self.unbroken_solution.subfunctions()[self.pidx] broken_pressure.dat.copy(unbroken_pressure.dat) # Compute the hdiv projection of the broken hdiv solution - broken_hdiv = self.broken_solution.split()[self.vidx] - unbroken_hdiv = self.unbroken_solution.split()[self.vidx] + broken_hdiv = self.broken_solution.subfunctions()[self.vidx] + unbroken_hdiv = self.unbroken_solution.subfunctions()[self.vidx] unbroken_hdiv.assign(0) self.average_kernel.apply(unbroken_hdiv, self.weight, broken_hdiv) diff --git a/gusto/timeloop.py b/gusto/timeloop.py index 02d11b74a..2faa3f722 100644 --- a/gusto/timeloop.py +++ b/gusto/timeloop.py @@ -15,7 +15,7 @@ from gusto.transport_methods import TransportMethod import ufl -__all__ = ["Timestepper", "SplitPhysicsTimestepper", "SemiImplicitQuasiNewton", +__all__ = ["Timestepper", "PhysicsTimestepper", "SemiImplicitQuasiNewton", "PrescribedTransport"] @@ -210,7 +210,7 @@ def set_reference_profiles(self, reference_profiles): assert field_name in self.equation.field_names, \ f'Cannot set reference profile as field {field_name} not found' idx = self.equation.field_names.index(field_name) - X_ref = self.equation.X_ref.split()[idx] + X_ref = self.equation.X_ref.subfunctions()[idx] X_ref.assign(ref) self.reference_profiles_initialised = True diff --git a/unit-tests/fml_tests/test_replace_perp.py b/unit-tests/fml_tests/test_replace_perp.py index 967780696..91d49acb4 100644 --- a/unit-tests/fml_tests/test_replace_perp.py +++ b/unit-tests/fml_tests/test_replace_perp.py @@ -30,7 +30,7 @@ def test_replace_perp(): # make a function to replace the subject with and give it some values U1 = Function(W) - u1, _ = U1.split() + u1, _ = U1.subfunctions() x, y = SpatialCoordinate(mesh) u1.interpolate(as_vector([1, 2])) @@ -40,9 +40,9 @@ def test_replace_perp(): U2 = Function(W) solve(a == L.form, U2) - u2, _ = U2.split() + u2, _ = U2.subfunctions() U3 = Function(W) - u3, _ = U3.split() + u3, _ = U3.subfunctions() u3.interpolate(as_vector([-2, 1])) assert errornorm(u2, u3) < 1e-14 From ceb67567833744f16f39a661b6bd8b88fea99049 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 25 Jul 2023 12:24:58 +0100 Subject: [PATCH 3/5] more .split() changed to .subfunctions() --- gusto/linear_solvers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gusto/linear_solvers.py b/gusto/linear_solvers.py index 547fe99d7..68589be19 100644 --- a/gusto/linear_solvers.py +++ b/gusto/linear_solvers.py @@ -373,7 +373,7 @@ def solve(self, xrhs, dy): # Solve the hybridized system self.hybridized_solver.solve() - broken_u, rho1, _ = self.urhol0.split() + broken_u, rho1, _ = self.urhol0.subfunctions() u1 = self.u_hdiv # Project broken_u into the HDiv space @@ -387,7 +387,7 @@ def solve(self, xrhs, dy): bc.apply(u1) # Copy back into u and rho cpts of dy - u, rho, theta = dy.split()[0:3] + u, rho, theta = dy.subfunctions()[0:3] u.assign(u1) rho.assign(rho1) @@ -495,7 +495,7 @@ def trace_nullsp(T): b = TrialFunction(Vb) gamma = TestFunction(Vb) - u, p = self.up.split() + u, p = self.up.subfunctions() self.b = Function(Vb) b_eqn = gamma*(b - b_in @@ -522,8 +522,8 @@ def solve(self, xrhs, dy): with timed_region("Gusto:VelocityPressureSolve"): self.up_solver.solve() - u1, p1 = self.up.split() - u, p, b = dy.split() + u1, p1 = self.up.subfunctions() + u, p, b = dy.subfunctions() u.assign(u1) p.assign(p1) From ee1e0086c68a4d5b27a81cbed1819a0cb5400d4e Mon Sep 17 00:00:00 2001 From: Tim Andrews Date: Tue, 25 Jul 2023 14:20:26 +0100 Subject: [PATCH 4/5] SplitPhysicsTimestepper --- gusto/timeloop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gusto/timeloop.py b/gusto/timeloop.py index 2faa3f722..982dbb1ff 100644 --- a/gusto/timeloop.py +++ b/gusto/timeloop.py @@ -15,7 +15,7 @@ from gusto.transport_methods import TransportMethod import ufl -__all__ = ["Timestepper", "PhysicsTimestepper", "SemiImplicitQuasiNewton", +__all__ = ["Timestepper", "SplitPhysicsTimestepper", "SemiImplicitQuasiNewton", "PrescribedTransport"] From c92a42c0508a610bb99413b6f0099ebea22392eb Mon Sep 17 00:00:00 2001 From: Tim Andrews Date: Tue, 25 Jul 2023 15:03:19 +0100 Subject: [PATCH 5/5] removed () from subfunctions --- gusto/fields.py | 2 +- gusto/initialisation_tools.py | 8 +++--- gusto/linear_solvers.py | 10 +++---- gusto/physics.py | 32 +++++++++++------------ gusto/preconditioners.py | 20 +++++++------- gusto/timeloop.py | 2 +- unit-tests/fml_tests/test_replace_perp.py | 6 ++--- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/gusto/fields.py b/gusto/fields.py index 1d64e9c59..4d204642c 100644 --- a/gusto/fields.py +++ b/gusto/fields.py @@ -34,7 +34,7 @@ def add_field(self, name, space, subfield_names=None): if len(space) > 1: assert len(space) == len(subfield_names) - for field_name, field in zip(subfield_names, value.subfunctions()): + for field_name, field in zip(subfield_names, value.subfunctions): setattr(self, field_name, field) field.rename(field_name) self.fields.append(field) diff --git a/gusto/initialisation_tools.py b/gusto/initialisation_tools.py index f66149d9e..ad85578fb 100644 --- a/gusto/initialisation_tools.py +++ b/gusto/initialisation_tools.py @@ -133,7 +133,7 @@ def incompressible_hydrostatic_balance(equation, b0, p0, top=False, params=None) solve(a == L, w1, bcs=bcs, solver_parameters=params) - v, pprime = w1.subfunctions() + v, pprime = w1.subfunctions p0.project(pprime) @@ -235,13 +235,13 @@ def compressible_hydrostatic_balance(equation, theta0, rho0, exner0=None, options_prefix="exner_solver") exner_solver.solve() - v, exner = w.subfunctions() + v, exner = w.subfunctions if exner0 is not None: exner0.assign(exner) if solve_for_rho: w1 = Function(W) - v, rho = w1.subfunctions() + v, rho = w1.subfunctions rho.interpolate(thermodynamics.rho(parameters, theta0, exner)) v, rho = split(w1) dv, dexner = TestFunctions(W) @@ -256,7 +256,7 @@ def compressible_hydrostatic_balance(equation, theta0, rho0, exner0=None, rhosolver = NonlinearVariationalSolver(rhoproblem, solver_parameters=params, options_prefix="rhosolver") rhosolver.solve() - v, rho_ = w1.subfunctions() + v, rho_ = w1.subfunctions rho0.assign(rho_) else: rho0.interpolate(thermodynamics.rho(parameters, theta0, exner)) diff --git a/gusto/linear_solvers.py b/gusto/linear_solvers.py index 68589be19..63450add3 100644 --- a/gusto/linear_solvers.py +++ b/gusto/linear_solvers.py @@ -373,7 +373,7 @@ def solve(self, xrhs, dy): # Solve the hybridized system self.hybridized_solver.solve() - broken_u, rho1, _ = self.urhol0.subfunctions() + broken_u, rho1, _ = self.urhol0.subfunctions u1 = self.u_hdiv # Project broken_u into the HDiv space @@ -387,7 +387,7 @@ def solve(self, xrhs, dy): bc.apply(u1) # Copy back into u and rho cpts of dy - u, rho, theta = dy.subfunctions()[0:3] + u, rho, theta = dy.subfunctions[0:3] u.assign(u1) rho.assign(rho1) @@ -495,7 +495,7 @@ def trace_nullsp(T): b = TrialFunction(Vb) gamma = TestFunction(Vb) - u, p = self.up.subfunctions() + u, p = self.up.subfunctions self.b = Function(Vb) b_eqn = gamma*(b - b_in @@ -522,8 +522,8 @@ def solve(self, xrhs, dy): with timed_region("Gusto:VelocityPressureSolve"): self.up_solver.solve() - u1, p1 = self.up.subfunctions() - u, p, b = dy.subfunctions() + u1, p1 = self.up.subfunctions + u, p, b = dy.subfunctions u.assign(u1) p.assign(p1) diff --git a/gusto/physics.py b/gusto/physics.py index 9ae262f2f..1cf7562ee 100644 --- a/gusto/physics.py +++ b/gusto/physics.py @@ -108,8 +108,8 @@ def __init__(self, equation, vapour_name='water_vapour', # Vapour and cloud variables are needed for every form of this scheme cloud_idx = equation.field_names.index(cloud_name) vap_idx = equation.field_names.index(vapour_name) - cloud_water = self.X.subfunctions()[cloud_idx] - water_vapour = self.X.subfunctions()[vap_idx] + cloud_water = self.X.subfunctions[cloud_idx] + water_vapour = self.X.subfunctions[vap_idx] # Indices of variables in mixed function space V_idxs = [vap_idx, cloud_idx] @@ -119,8 +119,8 @@ def __init__(self, equation, vapour_name='water_vapour', if isinstance(equation, CompressibleEulerEquations): rho_idx = equation.field_names.index('rho') theta_idx = equation.field_names.index('theta') - rho = self.X.subfunctions()[rho_idx] - theta = self.X.subfunctions()[theta_idx] + rho = self.X.subfunctions[rho_idx] + theta = self.X.subfunctions[theta_idx] if latent_heat: V_idxs.append(theta_idx) @@ -146,7 +146,7 @@ def __init__(self, equation, vapour_name='water_vapour', if (active_tracer.phase == Phases.liquid and active_tracer.chemical == 'H2O' and active_tracer.name != cloud_name): liq_idx = equation.field_names.index(active_tracer.name) - liquid_water += self.X.subfunctions()[liq_idx] + liquid_water += self.X.subfunctions[liq_idx] # define some parameters as attributes self.dt = Constant(0.0) @@ -280,7 +280,7 @@ def __init__(self, equation, rain_name, domain, transport_method, self.X = Function(equation.X.function_space()) rain_idx = equation.field_names.index(rain_name) - rain = self.X.subfunctions()[rain_idx] + rain = self.X.subfunctions[rain_idx] Vu = domain.spaces("HDiv") # TODO: there must be a better way than forcing this into the equation @@ -314,7 +314,7 @@ def __init__(self, equation, rain_name, domain, transport_method, # this advects the third moment M3 of the raindrop # distribution, which corresponds to the mean mass rho_idx = equation.field_names.index('rho') - rho = self.X.subfunctions()[rho_idx] + rho = self.X.subfunctions[rho_idx] rho_w = Constant(1000.0) # density of liquid water # assume n(D) = n_0 * D^mu * exp(-Lambda*D) # n_0 = N_r * Lambda^(1+mu) / gamma(1 + mu) @@ -451,8 +451,8 @@ def evaluate(self, x_in, dt): """ # Update the values of internal variables self.dt.assign(dt) - self.rain.assign(x_in.subfunctions()[self.rain_idx]) - self.cloud_water.assign(x_in.subfunctions()[self.cloud_idx]) + self.rain.assign(x_in.subfunctions[self.rain_idx]) + self.cloud_water.assign(x_in.subfunctions[self.cloud_idx]) # Evaluate the source self.source.assign(self.source_interpolator.interpolate()) @@ -509,8 +509,8 @@ def __init__(self, equation, rain_name='rain', vapour_name='water_vapour', # Vapour and cloud variables are needed for every form of this scheme rain_idx = equation.field_names.index(rain_name) vap_idx = equation.field_names.index(vapour_name) - rain = self.X.subfunctions()[rain_idx] - water_vapour = self.X.subfunctions()[vap_idx] + rain = self.X.subfunctions[rain_idx] + water_vapour = self.X.subfunctions[vap_idx] # Indices of variables in mixed function space V_idxs = [rain_idx, vap_idx] @@ -520,8 +520,8 @@ def __init__(self, equation, rain_name='rain', vapour_name='water_vapour', if isinstance(equation, CompressibleEulerEquations): rho_idx = equation.field_names.index('rho') theta_idx = equation.field_names.index('theta') - rho = self.X.subfunctions()[rho_idx] - theta = self.X.subfunctions()[theta_idx] + rho = self.X.subfunctions[rho_idx] + theta = self.X.subfunctions[theta_idx] if latent_heat: V_idxs.append(theta_idx) @@ -543,7 +543,7 @@ def __init__(self, equation, rain_name='rain', vapour_name='water_vapour', if (active_tracer.phase == Phases.liquid and active_tracer.chemical == 'H2O' and active_tracer.name != rain_name): liq_idx = equation.field_names.index(active_tracer.name) - liquid_water += self.X.subfunctions()[liq_idx] + liquid_water += self.X.subfunctions[liq_idx] # define some parameters as attributes self.dt = Constant(0.0) @@ -761,10 +761,10 @@ def evaluate(self, x_in, dt): interval for the scheme. """ if self.convective_feedback: - self.D.assign(x_in.subfunctions()[self.VD_idx]) + self.D.assign(x_in.subfunctions[self.VD_idx]) if self.time_varying_saturation: self.saturation_curve.interpolate(self.saturation_computation(x_in)) if self.set_tau_to_dt: self.tau.assign(dt) - self.water_v.assign(x_in.subfunctions()[self.Vv_idx]) + self.water_v.assign(x_in.subfunctions[self.Vv_idx]) self.source.assign(self.source_interpolator.interpolate()) diff --git a/gusto/preconditioners.py b/gusto/preconditioners.py index 7bd5bcf1d..6148da642 100644 --- a/gusto/preconditioners.py +++ b/gusto/preconditioners.py @@ -244,8 +244,8 @@ def _reconstruction_calls(self, split_mixed_op, split_trace_op): K_1 = Tensor(split_trace_op[(0, id1)]) # Split functions and reconstruct each bit separately - split_residual = self.broken_residual.subfunctions() - split_sol = self.broken_solution.subfunctions() + split_residual = self.broken_residual.subfunctions + split_sol = self.broken_solution.subfunctions g = AssembledVector(split_residual[id0]) f = AssembledVector(split_residual[id1]) sigma = split_sol[id0] @@ -316,8 +316,8 @@ def apply(self, pc, x, y): # Transfer unbroken_rhs into broken_rhs # NOTE: Scalar space is already "broken" so no need for # any projections - unbroken_scalar_data = self.unbroken_residual.subfunctions()[self.pidx] - broken_scalar_data = self.broken_residual.subfunctions()[self.pidx] + unbroken_scalar_data = self.unbroken_residual.subfunctions[self.pidx] + broken_scalar_data = self.broken_residual.subfunctions[self.pidx] unbroken_scalar_data.dat.copy(broken_scalar_data.dat) with timed_region("VertHybridRHS"): @@ -328,8 +328,8 @@ def apply(self, pc, x, y): # basis functions that add together to give unbroken # basis functions. - unbroken_res_hdiv = self.unbroken_residual.subfunctions()[self.vidx] - broken_res_hdiv = self.broken_residual.subfunctions()[self.vidx] + unbroken_res_hdiv = self.unbroken_residual.subfunctions[self.vidx] + broken_res_hdiv = self.broken_residual.subfunctions[self.vidx] broken_res_hdiv.assign(0) self.average_kernel.apply(broken_res_hdiv, self.weight, unbroken_res_hdiv) @@ -351,13 +351,13 @@ def apply(self, pc, x, y): with timed_region("VertHybridRecover"): # Project the broken solution into non-broken spaces - broken_pressure = self.broken_solution.subfunctions()[self.pidx] - unbroken_pressure = self.unbroken_solution.subfunctions()[self.pidx] + broken_pressure = self.broken_solution.subfunctions[self.pidx] + unbroken_pressure = self.unbroken_solution.subfunctions[self.pidx] broken_pressure.dat.copy(unbroken_pressure.dat) # Compute the hdiv projection of the broken hdiv solution - broken_hdiv = self.broken_solution.subfunctions()[self.vidx] - unbroken_hdiv = self.unbroken_solution.subfunctions()[self.vidx] + broken_hdiv = self.broken_solution.subfunctions[self.vidx] + unbroken_hdiv = self.unbroken_solution.subfunctions[self.vidx] unbroken_hdiv.assign(0) self.average_kernel.apply(unbroken_hdiv, self.weight, broken_hdiv) diff --git a/gusto/timeloop.py b/gusto/timeloop.py index 982dbb1ff..b525fc5ae 100644 --- a/gusto/timeloop.py +++ b/gusto/timeloop.py @@ -210,7 +210,7 @@ def set_reference_profiles(self, reference_profiles): assert field_name in self.equation.field_names, \ f'Cannot set reference profile as field {field_name} not found' idx = self.equation.field_names.index(field_name) - X_ref = self.equation.X_ref.subfunctions()[idx] + X_ref = self.equation.X_ref.subfunctions[idx] X_ref.assign(ref) self.reference_profiles_initialised = True diff --git a/unit-tests/fml_tests/test_replace_perp.py b/unit-tests/fml_tests/test_replace_perp.py index 91d49acb4..4be0f993f 100644 --- a/unit-tests/fml_tests/test_replace_perp.py +++ b/unit-tests/fml_tests/test_replace_perp.py @@ -30,7 +30,7 @@ def test_replace_perp(): # make a function to replace the subject with and give it some values U1 = Function(W) - u1, _ = U1.subfunctions() + u1, _ = U1.subfunctions x, y = SpatialCoordinate(mesh) u1.interpolate(as_vector([1, 2])) @@ -40,9 +40,9 @@ def test_replace_perp(): U2 = Function(W) solve(a == L.form, U2) - u2, _ = U2.subfunctions() + u2, _ = U2.subfunctions U3 = Function(W) - u3, _ = U3.subfunctions() + u3, _ = U3.subfunctions u3.interpolate(as_vector([-2, 1])) assert errornorm(u2, u3) < 1e-14