Skip to content

Commit

Permalink
name -> name_label
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Oct 27, 2023
1 parent 6c437fe commit d8ddf0b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
12 changes: 7 additions & 5 deletions gusto/equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ def __init__(self, domain, parameters, Omega=None, sponge=None,
raise NotImplementedError('Only mixing ratio tracers are implemented')
theta_v = theta / (Constant(1.0) + tracer_mr_total)

pressure_gradient_form = name(subject(prognostic(
pressure_gradient_form = name_label(subject(prognostic(
cp*(-div(theta_v*w)*exner*dx
+ jump(theta_v*w, n)*avg(exner)*dS_v), 'u'), self.X), "pressure_gradient")

Expand Down Expand Up @@ -1044,7 +1044,7 @@ def __init__(self, domain, parameters, Omega=None, sponge=None,
mubar*sin((pi/2.)*(z-zc)/(H-zc))**2)
self.mu = self.prescribed_fields("sponge", W_DG).interpolate(muexpr)

residual += name(subject(prognostic(
residual += name_label(subject(prognostic(
self.mu*inner(w, domain.k)*inner(u, domain.k)*dx, 'u'), self.X), "sponge")

if diffusion_options is not None:
Expand Down Expand Up @@ -1149,7 +1149,7 @@ def __init__(self, domain, parameters, Omega=None, sponge=None,

k = self.domain.k
u = split(self.X)[0]
self.residual += name(
self.residual += name_label(
subject(
prognostic(
-inner(k, self.tests[0]) * inner(k, u) * dx, "u"),
Expand Down Expand Up @@ -1314,8 +1314,10 @@ def __init__(self, domain, parameters, Omega=None,
# The p features here so that the div(u) evaluated in the "forcing" step
# replaces the whole pressure field, rather than merely providing an
# increment to it.
divergence_form = name(subject(prognostic(phi*(p-div(u))*dx, 'p'), self.X),
"incompressibility")
divergence_form = name_label(
subject(prognostic(phi*(p-div(u))*dx, 'p'), self.X),
"incompressibility"
)

residual = (mass_form + adv_form + divergence_form
+ pressure_gradient_form + gravity_form)
Expand Down
18 changes: 12 additions & 6 deletions gusto/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,39 @@ def __init__(self, equation, alpha):

# the explicit forms are multiplied by (1-alpha) and moved to the rhs
L_explicit = -(1-alpha)*dt*residual.label_map(
lambda t: t.has_label(time_derivative) or t.get(name) in implicit_terms or t.get(name) == "hydrostatic_form",
lambda t:
t.has_label(time_derivative)
or t.get(name_label) in implicit_terms
or t.get(name_label) == "hydrostatic_form",
drop,
replace_subject(self.x0))

# the implicit forms are multiplied by alpha and moved to the rhs
L_implicit = -alpha*dt*residual.label_map(
lambda t: t.has_label(time_derivative) or t.get(name) in implicit_terms or t.get(name) == "hydrostatic_form",
lambda t:
t.has_label(time_derivative)
or t.get(name_label) in implicit_terms
or t.get(name_label) == "hydrostatic_form",
drop,
replace_subject(self.x0))

# now add the terms that are always fully implicit
if any(t.get(name) in implicit_terms for t in residual):
if any(t.get(name_label) in implicit_terms for t in residual):
L_implicit -= dt*residual.label_map(
lambda t: t.get(name) in implicit_terms,
lambda t: t.get(name_label) in implicit_terms,
replace_subject(self.x0),
drop)

# the hydrostatic equations require some additional forms:
if any([t.has_label(hydrostatic) for t in residual]):

L_explicit += residual.label_map(
lambda t: t.get(name) == "hydrostatic_form",
lambda t: t.get(name_label) == "hydrostatic_form",
replace_subject(self.x0),
drop)

L_implicit -= residual.label_map(
lambda t: t.get(name) == "hydrostatic_form",
lambda t: t.get(name_label) == "hydrostatic_form",
replace_subject(self.x0),
drop)

Expand Down

0 comments on commit d8ddf0b

Please sign in to comment.