Skip to content

Commit

Permalink
Revert "Merge branch 'main' into mixed_fs_supg"
Browse files Browse the repository at this point in the history
This reverts commit ac03896, reversing
changes made to 62d1d49.
  • Loading branch information
atb1995 committed Nov 28, 2024
1 parent ac03896 commit 31956fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions examples/compressible_euler/mountain_hydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
TrapeziumRule, SUPGOptions, ZComponent, Perturbation,
CompressibleParameters, HydrostaticCompressibleEulerEquations,
CompressibleSolver, compressible_hydrostatic_balance, HydrostaticImbalance,
SpongeLayerParameters, MinKernel, MaxKernel, logger
SpongeLayerParameters, MinKernel, MaxKernel, remove_initial_w, logger
)

mountain_hydrostatic_defaults = {
Expand Down Expand Up @@ -243,7 +243,8 @@ def mountain_hydrostatic(

theta0.assign(theta_b)
rho0.assign(rho_b)
u0.project(as_vector([initial_wind, 0.0]), bcs=eqns.bcs['u'])
u0.project(as_vector([initial_wind, 0.0]))
remove_initial_w(u0)

stepper.set_reference_profiles([('rho', rho_b), ('theta', theta_b)])

Expand Down
24 changes: 20 additions & 4 deletions gusto/initialisation/hydrostatic_initialisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
from gusto.recovery import Recoverer, BoundaryMethod


__all__ = [
"boussinesq_hydrostatic_balance", "compressible_hydrostatic_balance",
"saturated_hydrostatic_balance", "unsaturated_hydrostatic_balance"
]
__all__ = ["boussinesq_hydrostatic_balance",
"compressible_hydrostatic_balance", "remove_initial_w",
"saturated_hydrostatic_balance", "unsaturated_hydrostatic_balance"]


def boussinesq_hydrostatic_balance(equation, b0, p0, top=False, params=None):
Expand Down Expand Up @@ -220,6 +219,23 @@ def compressible_hydrostatic_balance(equation, theta0, rho0, exner0=None,
rho0.interpolate(thermodynamics.rho(parameters, theta0, exner))


def remove_initial_w(u):
"""
Removes the vertical component of a velocity field.
Args:
u (:class:`Function`): the velocity field to be altered.
"""
Vu = u.function_space()
Vv = FunctionSpace(Vu._ufl_domain, Vu.ufl_element()._elements[-1])
bc = DirichletBC(Vu[0], 0.0, "bottom")
bc.apply(u)
uv = Function(Vv).project(u)
ustar = Function(u.function_space()).project(uv)
uin = Function(u.function_space()).assign(u - ustar)
u.assign(uin)


def saturated_hydrostatic_balance(equation, state_fields, theta_e, mr_t,
exner0=None, top=False,
exner_boundary=Constant(1.0),
Expand Down

0 comments on commit 31956fb

Please sign in to comment.