PALEOocean functions

Helper functions for use by Reactions.

Configuring Domains and Variables

PALEOocean.Ocean.set_model_domainsFunction
set_model_domains(model::PB.Model, oceangrid, surfacegrid, floorgrid)

Set model Domain sizes and Subdomains for ocean, oceansurface, oceanfloor Domains. (Helper function for a Reaction implementing ocean transport.)

source
PALEOocean.Ocean.find_transport_varsFunction
find_transport_vars(domain::PB.AbstractDomain; transport_input_components=false) 
    -> (conc_vars, sms_vars, input_components, num_components)

Find all variables in domain with attribute :advect == true, and then use naming convention <rootname>_conc to identify <rootname>_sms Variables to add transport flux to.

If transport_input_components = true, also define input_components as <varname>_transport_input to calculate advective transport input into each cell (slow)

source

Constructing and using transport matrices

PALEOocean.Ocean.add_loop!Function
add_loop!(A::AbstractMatrix, vm::AbstractVector, L::Real, loopindices)

Add circulation with flux L to transport matrix A, around a closed loop loopindices.

Transport matrix A (s^{-1}) represents tracer transport,

dc/dt = A * c

where c is Vector of tracer concentrations

loopindices is a list of cell indices representing a closed loop, eg [2, 3, 4, 2]

Units for tracers and fluxes are:

  • Ocean / volume based:
    • c: mol m-3 tracer concentration
    • vm: m^3. volume per cell
    • L: m^3 s-1 (volume flux, cf 1 Sverdrup = 1e6 m^3 s-1)
  • Atmosphere / mass based
    • c: kg / total kg, tracer mass mixing ratio
    • vm: kg, total mass per call
    • L: kg s-1 (mass flux)
source
PALEOocean.Ocean.prepare_transportFunction
prepare_transport(m::ReactionMethod, (grid_vars, conc_components, sms_components, input_components)) -> 
    (grid_vars, conc_components, sms_components, input_components, buffer)

Add an additional buffer for do_transport. conc_components, sms_components, optional input_components are Vectors of data Arrays (as created by VarList_components from lists generated by find_transport_vars).

source
PALEOocean.Ocean.do_transportFunction
do_transport(grid_vars, conc_components, sms_components, input_components, buffer, dtm::AbstractMatrix, cr::AbstractCellRange)

Calculate transport rates.

Arguments

  • grid_vars, conc_components, sms_components, input_components: Vectors of data Arrays (created by VarList_components)
  • buffer: buffer arrays created by prepare_transport
  • dtm::AbstractMatrix: transport matrix (units yr-1)
source
PALEOocean.Ocean.do_transport_trFunction
do_transport_tr(grid_vars, conc_components, sms_components, input_components, buffer, 
    dtm_tr::SparseArrays.SparseMatrixCSC, cr::PB.AbstractCellRange)

do_transport_tr(grid_vars, conc_components, sms_components, input_components, buffer,
    colptr, rowval, (nzval1, nzval2), (wt1, wt2), cr::PB.AbstractCellRange)

Memory-bandwidth optimised version of do_transport using transposed matrix dtm_tr. This is an optimisation specifically tied to the Compressed Sparse Column storage layout (Julia SparseMatrixCSC).

If two matrices are supplied with a common sparsity pattern specified by colptr, rowptr, applies a linear combination with (wt1, wt2)

source

Optimized SIMD transport matrix x contiguous packed conc data array

source

Optimized transport using transport matrices with a common sparsity pattern

PALEOocean.Ocean.TrsptCSCType
TrsptCSC

Store multiple SparseArrays.SparseMatrixCSC with a common sparsity pattern.

This allows fast interpolation for eg a time-series of transport matrices over a seasonal cycle.

SparseMatrixCSC format, except with a Vector of nzval, ie:

  • colptr: Column j is in colptr[j]:(colptr[j+1]-1)
  • rowval: Row indices of stored values
  • nzval: Vector of Vector of non-zero values
source
PALEOocean.Ocean.create_common_sparsity_tr!Function
create_common_sparsity_tr!(a_matrices; do_transpose, TMeltype=Float64) -> TrsptCSC

Reduce a collection of matrices to common sparsity pattern, optionally transposing.

NB: a_matrices is used as workspace and contents deleted.

source

Optimized transport using SIMD packed vectors

PALEOocean.Ocean.PackedBufferType
PackedBuffer

Buffer Arrays for optimized SIMD transport using elements of type SIMD.Vec{pack_chunk_width, pack_eltype}. Creates packed_conc_array for packed and padded Variable concentrations, and an additional workspace buffer. Uses additional type parameters to allow do_transport_tr specialization on number of Variable components etc as well as SIMD chunk width.

source