Skip to content

Commit

Permalink
Make linear continuity form correct for varying linearisation (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommbendall authored Nov 1, 2024
1 parent 950cc23 commit 6c5e752
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
22 changes: 1 addition & 21 deletions gusto/equations/common_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"kinetic_energy_form", "advection_equation_circulation_form",
"diffusion_form", "diffusion_form_1d",
"linear_advection_form", "linear_continuity_form",
"linear_continuity_form_1d",
"split_continuity_form", "tracer_conservative_form"]


Expand Down Expand Up @@ -134,26 +133,7 @@ def linear_continuity_form(test, qbar, ubar):
:class:`LabelledForm`: a labelled transport form.
"""

L = qbar*test*div(ubar)*dx
form = transporting_velocity(L, ubar)

return transport(form, TransportEquationType.conservative)


def linear_continuity_form_1d(test, qbar, ubar):
"""
The form corresponding to the linearised continuity transport operator.
Args:
test (:class:`TestFunction`): the test function.
qbar (:class:`ufl.Expr`): the variable to be transported.
ubar (:class:`ufl.Expr`): the transporting velocity.
Returns:
:class:`LabelledForm`: a labelled transport form.
"""

L = qbar*test*ubar.dx(0)*dx
L = test*div(qbar*ubar)*dx
form = transporting_velocity(L, ubar)

return transport(form, TransportEquationType.conservative)
Expand Down
4 changes: 2 additions & 2 deletions gusto/equations/shallow_water_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
advection_form, advection_form_1d, continuity_form,
continuity_form_1d, vector_invariant_form,
kinetic_energy_form, advection_equation_circulation_form, diffusion_form_1d,
linear_continuity_form, linear_continuity_form_1d
linear_continuity_form
)
from gusto.equations.prognostic_equations import PrognosticEquationSet

Expand Down Expand Up @@ -361,7 +361,7 @@ def __init__(self, domain, parameters,

# Transport term needs special linearisation
if self.linearisation_map(D_adv.terms[0]):
linear_D_adv = linear_continuity_form_1d(phi, H, u_trial)
linear_D_adv = linear_continuity_form(phi, H, u_trial)
# Add linearisation to D_adv
D_adv = linearisation(D_adv, linear_D_adv)

Expand Down
4 changes: 2 additions & 2 deletions gusto/solvers/linear_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def _setup_solver(self):
- beta_u * 0.5 * bbar * div(w*(D-Dbar)) * dx
+ beta_u * 0.5 * jump((D-Dbar)*w, n) * avg(bbar) * dS
+ inner(phi, (D - D_in)) * dx
+ beta_d * phi * Dbar * div(u) * dx
+ beta_d * phi * div(Dbar*u) * dx
)

if 'coriolis' in equation.prescribed_fields._field_names:
Expand Down Expand Up @@ -882,7 +882,7 @@ def _setup_solver(self):
inner(w, (u - u_in)) * dx
- beta_u * (D - Dbar) * div(w*g) * dx
+ inner(phi, (D - D_in)) * dx
+ beta_d * phi * Dbar * div(u) * dx
+ beta_d * phi * div(Dbar*u) * dx
)

if 'coriolis' in equation.prescribed_fields._field_names:
Expand Down

0 comments on commit 6c5e752

Please sign in to comment.