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_config
aSolverConfiguration
aux_excludes
a 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
end
TODO: Make prognostic
, auxiliary
, diffusive
, hyperdiffusive
optional
Arguments
bl
the balance lawgrid
the discontinuous spectral element gridprognostic
the global prognostic stateauxiliary
the global auxiliary statediffusive
the global diffusive state (gradient-flux)hyperdiffusive
the global hyperdiffusive statei,j
thei,j
'th nodal stack (in the horizontal directions)interp
a 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
grid
the gridbl
the balance lawt
timedirection
directionkwargs
keyword 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.