Skip to content

Commit

Permalink
PR #518: from firedrakeproject/1D_courant_logging
Browse files Browse the repository at this point in the history
Allow logging of Courant numbers for a scalar velocity field
  • Loading branch information
tommbendall authored Jul 23, 2024
2 parents 9930f6e + c360407 commit c0e65f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions examples/shallow_water/shallow_water_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
diffusion_options=diffusion_options)

output = OutputParameters(dirname="1dsw_%s" % str(epsilon),
dumpfreq=50,
log_courant=False)
dumpfreq=50)
io = IO(domain, output)

transport_methods = [DGUpwind(eqns, "u"), DGUpwind(eqns, "v"),
Expand Down
7 changes: 6 additions & 1 deletion gusto/diagnostics/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ def setup(self, domain, state_fields):

# Set up form for DG flux
n = FacetNormal(domain.mesh)
un = 0.5*(inner(-u_expr, n) + abs(inner(-u_expr, n)))

# Check if the velocity is a vector or scalar field
if u.ufl_shape == ():
un = 0.5*(-u_expr * n[0] + abs(-u_expr * n[0]))
else:
un = 0.5*(inner(-u_expr, n) + abs(inner(-u_expr, n)))
self.cell_flux_form = 2*avg(un*test)*dS_calc + un*test*ds_calc

# Final Courant number expression
Expand Down

0 comments on commit c0e65f3

Please sign in to comment.