diff --git a/src/dynamics/tendencies.jl b/src/dynamics/tendencies.jl index ce82b181a..5bbc365f1 100644 --- a/src/dynamics/tendencies.jl +++ b/src/dynamics/tendencies.jl @@ -85,14 +85,55 @@ end """ $(TYPEDSIGNATURES) Set the tendencies in `diagn` to zero.""" -function zero_tendencies!(diagn::DiagnosticVariables) +function zero_tendencies!(diagn::DiagnosticVariables{NF,Grid,Model}) where {NF,Grid,Model<:Barotropic} for layer in diagn.layers fill!(layer.tendencies.u_tend_grid,0) fill!(layer.tendencies.v_tend_grid,0) + fill!(layer.tendencies.vor_tend,0) + end +end + +""" +$(TYPEDSIGNATURES) +Set the tendencies in `diagn` to zero.""" +function zero_tendencies!(diagn::DiagnosticVariables{NF,Grid,Model}) where {NF,Grid,Model<:ShallowWater} + for layer in diagn.layers + fill!(layer.tendencies.u_tend_grid,0) + fill!(layer.tendencies.v_tend_grid,0) + fill!(layer.tendencies.vor_tend,0) + fill!(layer.tendencies.div_tend,0) + end + fill!(diagn.surface.pres_tend_grid,0) + fill!(diagn.surface.pres_tend,0) +end + +""" +$(TYPEDSIGNATURES) +Set the tendencies in `diagn` to zero.""" +function zero_tendencies!(diagn::DiagnosticVariables{NF,Grid,Model}) where {NF,Grid,Model<:PrimitiveDry} + for layer in diagn.layers + fill!(layer.tendencies.u_tend_grid,0) + fill!(layer.tendencies.v_tend_grid,0) + fill!(layer.tendencies.vor_tend,0) + fill!(layer.tendencies.div_tend,0) fill!(layer.tendencies.temp_tend_grid,0) - fill!(layer.tendencies.humid_tend_grid,0) end fill!(diagn.surface.pres_tend_grid,0) fill!(diagn.surface.pres_tend,0) - return nothing end + +""" +$(TYPEDSIGNATURES) +Set the tendencies in `diagn` to zero.""" +function zero_tendencies!(diagn::DiagnosticVariables{NF,Grid,Model}) where {NF,Grid,Model<:PrimitiveWet} + for layer in diagn.layers + fill!(layer.tendencies.u_tend_grid,0) + fill!(layer.tendencies.v_tend_grid,0) + fill!(layer.tendencies.vor_tend,0) + fill!(layer.tendencies.div_tend,0) + fill!(layer.tendencies.temp_tend_grid,0) + fill!(layer.tendencies.humid_tend_grid,0) + end + fill!(diagn.surface.pres_tend_grid,0) + fill!(diagn.surface.pres_tend,0) +end \ No newline at end of file diff --git a/src/dynamics/tendencies_dynamics.jl b/src/dynamics/tendencies_dynamics.jl index 04bde2b4b..4e3487aa5 100644 --- a/src/dynamics/tendencies_dynamics.jl +++ b/src/dynamics/tendencies_dynamics.jl @@ -402,7 +402,8 @@ function vorticity_flux_curldiv!( diagn::DiagnosticVariablesLayer, C::DynamicsConstants, G::Geometry, S::SpectralTransform; - div::Bool=true) # also calculate div of vor flux? + div::Bool=true, # also calculate div of vor flux? + add::Bool=false) # accumulate in vor/div tendencies? (;f_coriolis) = C (;coslat⁻¹) = G @@ -433,8 +434,8 @@ function vorticity_flux_curldiv!( diagn::DiagnosticVariablesLayer, spectral!(u_tend,u_tend_grid,S) spectral!(v_tend,v_tend_grid,S) - curl!(vor_tend,u_tend,v_tend,S) # ∂ζ/∂t = ∇×(u_tend,v_tend) - div && divergence!(div_tend,u_tend,v_tend,S) # ∂D/∂t = ∇⋅(u_tend,v_tend) + curl!(vor_tend,u_tend,v_tend,S;add) # ∂ζ/∂t = ∇×(u_tend,v_tend) + div && divergence!(div_tend,u_tend,v_tend,S;add) # ∂D/∂t = ∇⋅(u_tend,v_tend) return nothing end @@ -456,7 +457,7 @@ function vorticity_flux!(diagn::DiagnosticVariablesLayer,model::ShallowWater) C = model.constants G = model.geometry S = model.spectral_transform - vorticity_flux_curldiv!(diagn,C,G,S,div=true) + vorticity_flux_curldiv!(diagn,C,G,S,div=true,add=true) end """ @@ -476,7 +477,7 @@ function vorticity_flux!(diagn::DiagnosticVariablesLayer,model::Barotropic) C = model.constants G = model.geometry S = model.spectral_transform - vorticity_flux_curldiv!(diagn,C,G,S,div=false) + vorticity_flux_curldiv!(diagn,C,G,S,div=false,add=true) end """ diff --git a/src/output/output.jl b/src/output/output.jl index 8b8100f15..7f51a6372 100644 --- a/src/output/output.jl +++ b/src/output/output.jl @@ -131,10 +131,10 @@ function OutputWriter( end # default variables to output by model -default_output_vars(::Type{<:Barotropic}) = [:vor,:u] -default_output_vars(::Type{<:ShallowWater}) = [:vor,:u] -default_output_vars(::Type{<:PrimitiveDry}) = [:vor,:u,:temp,:pres] -default_output_vars(::Type{<:PrimitiveWet}) = [:vor,:u,:temp,:humid,:pres,:precip_cond,:precip_conv] +default_output_vars(::Type{<:Barotropic}) = [:vor,:u,:v] +default_output_vars(::Type{<:ShallowWater}) = [:vor,:u,:v] +default_output_vars(::Type{<:PrimitiveDry}) = [:vor,:u,:v,:temp,:pres] +default_output_vars(::Type{<:PrimitiveWet}) = [:vor,:u,:v,:temp,:humid,:pres,:precip_cond,:precip_conv] # print all fields with type <: Number function Base.show(io::IO,O::AbstractOutputWriter) diff --git a/src/utility_functions.jl b/src/utility_functions.jl index e65a0b9af..3480b76ae 100644 --- a/src/utility_functions.jl +++ b/src/utility_functions.jl @@ -82,7 +82,7 @@ function print_fields(io::IO,A,keys;arrays::Bool=false) filtered = n < length(keys) for (i,key) in enumerate(keys_filtered) last = (i == n) & ~filtered - key = keys[i] + key = keys_filtered[i] val = getfield(A,key) ~last ? println(io,"├ $key::$(typeof(val)) = $val") : print(io, "└ $key::$(typeof(val)) = $val")