Single Stack Utils
Functions
ClimateMachine.SingleStackUtils.get_vars_from_nodal_stack — Functionget_vars_from_nodal_stack(
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
vars;
vrange::UnitRange = 1:size(Q, 3),
i::Int = 1,
j::Int = 1,
exclude::Vector{String} = String[],
interp = false,
) where {T, dim, N}Return a dictionary whose keys are the flattenednames() of the variables specified in vars (as returned by e.g. vars_state), and whose values are arrays of the values for that variable along the vertical dimension in Q. Only a single element is expected in the horizontal as this is intended for the single stack configuration and i and j identify the horizontal nodal coordinates.
Variables listed in exclude are skipped.
ClimateMachine.SingleStackUtils.get_vars_from_element_stack — Functionget_vars_from_element_stack(
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
vars;
vrange::UnitRange = 1:size(Q, 3),
exclude::Vector{String} = String[],
interp = false,
) where {T, dim, N}Return an array of get_vars_from_nodal_stack()s whose dimensions are the number of nodal points per element in the horizontal plane.
Variables listed in exclude are skipped.
ClimateMachine.SingleStackUtils.get_horizontal_mean — Functionget_horizontal_mean(
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
vars;
vrange::UnitRange = 1:size(Q, 3),
exclude::Vector{String} = String[],
interp = false,
) where {T, dim, N}Return a dictionary whose keys are the flattenednames() of the variables specified in vars (as returned by e.g. vars_state), and whose values are arrays of the horizontal averages for that variable along the vertical dimension in Q. Only a single element is expected in the horizontal as this is intended for the single stack configuration.
Variables listed in exclude are skipped.
ClimateMachine.SingleStackUtils.get_horizontal_variance — Functionget_horizontal_variance(
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
vars;
vrange::UnitRange = 1:size(Q, 3),
exclude::Vector{String} = String[],
interp = false,
) where {T, dim, N}Return a dictionary whose keys are the flattenednames() of the variables specified in vars (as returned by e.g. vars_state), and whose values are arrays of the horizontal variance for that variable along the vertical dimension in Q. Only a single element is expected in the horizontal as this is intended for the single stack configuration.
Variables listed in exclude are skipped.
ClimateMachine.SingleStackUtils.reduce_nodal_stack — Functionreduce_nodal_stack(
op::Function,
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
vars::NamedTuple,
var::String;
vrange::UnitRange = 1:size(Q, 3),
) where {T, dim, N}Reduce var from vars within Q over all nodal points in the specified vrange of elements with op. Return a tuple (result, z) where result is the final value returned by op and z is the index within vrange where the result was determined.
ClimateMachine.SingleStackUtils.reduce_element_stack — Functionreduce_element_stack(
op::Function,
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
vars::NamedTuple,
var::String;
vrange::UnitRange = 1:size(Q, 3),
) where {T, dim, N}Reduce var from vars within Q over all nodal points in the specified vrange of elements with op. Return a tuple (result, z) where result is the final value returned by op and z is the index within vrange where the result was determined.
ClimateMachine.SingleStackUtils.horizontally_average! — Functionhorizontally_average!(
grid::DiscontinuousSpectralElementGrid{T, dim, N},
Q::MPIStateArray,
i_vars,
) where {T, dim, N}Horizontally average variables, from variable indexes i_vars, in MPIStateArray Q.
These are not proper horizontal averages– the main purpose of this method is to ensure that there are no horizontal fluxes for a single stack configuration.
ClimateMachine.SingleStackUtils.dict_of_nodal_states — Functiondict_of_nodal_states(
solver_config,
state_types = (Prognostic(), Auxiliary());
aux_excludes = [],
interp = false,
)A dictionary of single stack prognostic and auxiliary variables at the i=1,j=1 node given
solver_configaSolverConfigurationaux_excludesa vector of strings containing the variables to exclude from the auxiliary state.
ClimateMachine.SingleStackUtils.NodalStack — TypeNodalStack(
bl::BalanceLaw,
grid::DiscontinuousSpectralElementGrid,
prognostic,
auxiliary,
diffusive,
hyperdiffusive;
i = 1,
j = 1,
interp = true,
)A struct whose iterate(::NodalStack) traverses the nodal stack and returns a NamedTuple of point-wise fields (Vars).
Example
for state_local in NodalStack(
bl,
grid,
prognostic, # global field along nodal stack
auxiliary,
diffusive,
hyperdiffusive
)
prog = state_local.prog # point-wise field along nodal stack
endTODO: Make prognostic, auxiliary, diffusive, hyperdiffusive optional
Arguments
blthe balance lawgridthe discontinuous spectral element gridprognosticthe global prognostic stateauxiliarythe global auxiliary statediffusivethe global diffusive state (gradient-flux)hyperdiffusivethe global hyperdiffusive statei,jthei,j'th nodal stack (in the horizontal directions)interpa bool indicating whether to interpolate the duplicate Gauss-Lebotto points at the element faces.
Before iterating, the data is transferred from the device (GPU) to the host (CPU), as this is intended for debugging / diagnostics usage.
ClimateMachine.SingleStackUtils.single_stack_diagnostics — Functionsingle_stack_diagnostics(
grid::DiscontinuousSpectralElementGrid,
bl::BalanceLaw,
t::Real,
direction;
kwargs...,
)Arguments
gridthe gridblthe balance lawttimedirectiondirectionkwargskeyword arguments, passed toNodalStack.
An array of nested NamedTuples, containing results of
z- altitudeprog- the prognostic stateaux- the auxiliary state∇flux- the gradient-flux (diffusive) statehyperdiff- the hyperdiffusive state
and all the nested NamedTuples, merged together, from the precompute methods.