Skip to content

Commit

Permalink
Merge CliMA#1864
Browse files Browse the repository at this point in the history
1864: Move precompute method to balance law r=charleskawczynski a=charleskawczynski

### Description

This should have been incorporated in CliMA#1850, we want `precompute` to be a `BalanceLaw` method, so that we can inherit/modularize its use across different models.



Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
bors[bot] and charleskawczynski authored Dec 15, 2020
2 parents 19da615 + 4e17b10 commit 6979716
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/APIs/BalanceLaws/BalanceLaws.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ AbstractTendencyType
TendencyDef
eq_tends
prognostic_vars
precompute
fluxes
sources
show_tendencies
Expand Down
1 change: 1 addition & 0 deletions src/Atmos/Model/AtmosModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import ..BalanceLaws:
source!,
eq_tends,
flux,
precompute,
source,
wavespeed,
boundary_conditions,
Expand Down
1 change: 1 addition & 0 deletions src/BalanceLaws/BalanceLaws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using ..VariableTemplates
export BalanceLaw,
vars_state,
number_states,
precompute,
init_state_prognostic!,
init_state_auxiliary!,
compute_gradient_flux!,
Expand Down
13 changes: 12 additions & 1 deletion src/BalanceLaws/tendency_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

export PrognosticVariable
export FirstOrder, SecondOrder
export Flux, Source
export AbstractTendencyType, Flux, Source
export TendencyDef

"""
Expand Down Expand Up @@ -121,3 +121,14 @@ function fluxes(bl::BalanceLaw, order::O) where {O <: AbstractOrder}
tend = filter(x -> x nothing, tend)
return Tuple(Iterators.flatten(tend))
end

"""
precompute(bl, args, ::AbstractTendencyType)
A nested NamedTuple of precomputed (cached) values
and or objects. This is useful for "expensive"
point-wise quantities that are used in multiple
tendency terms. For example, computing a quantity
that requires iteration.
"""
precompute(bl, args, ::AbstractTendencyType) = NamedTuple()

0 comments on commit 6979716

Please sign in to comment.