GridTools.jl

GridTools.FieldType
Field(dims::Tuple, data::Array, broadcast_dims::Tuple)

Examples

julia> new_field = Field((Cell, K), fill(1.0, (3,2)))
3x2  Field with dims (Main.GridTools.Cell_(), Main.GridTools.K_()) and broadcasted_dims (Main.GridTools.Cell_(), Main.GridTools.K_()):
 1.0  1.0
 1.0  1.0
 1.0  1.0
source
GridTools.ConnectivityType
Connectivity(data::Array, source::Tuple, target::Tuple, dims::Int)

Examples

julia> new_connectivity = Connectivity(fill(1, (3,2)), Cell, (Edge, E2C), 2)
3x2  Field with dims (Main.GridTools.Cell_(), Main.GridTools.K_()) and broadcasted_dims (Main.GridTools.Cell_(), Main.GridTools.K_()):
 1  1
 1  1
 1  1
source
GridTools.whereFunction
where(mask::Field, true, false)

The 'where' loops over each entry of the mask and returns values corresponding to the same indexes of either the true or the false branch.

Arguments

  • mask::Field: a field with eltype Boolean
  • true: a tuple, a field, or a scalar
  • false: a tuple, a field, or a scalar

Examples

julia> mask = Field((Cell, K), rand(Bool, (3,3)))
3x3  Field with dims (Cell_(), K_()) and broadcasted_dims (Cell_(), K_()):
 1  0  0
 0  1  0
 1  1  1
julia> a = Field((Cell, K), fill(1.0, (3,3)));
julia> b = Field((Cell, K), fill(2.0, (3,3)));
julia> where(mask, a, b)
3x3  Field with dims (Cell_(), K_()) and broadcasted_dims (Cell_(), K_()):
 1.0  2.0  2.0
 2.0  1.0  2.0
 1.0  1.0  1.0

The where function builtin also allows for nesting of tuples. In this scenario, it will first perform an unrolling: where(mask, ((a, b), (b, a)), ((c, d), (d, c))) –> where(mask, (a, b), (c, d)) and where(mask, (b, a), (d, c)) and then combine results to match the return type:

source
GridTools.neighbor_sumFunction
neighbor_sum(f::Field; axis::Dimension)

Sums along the axis dimension. Outputs a field with dimensions size(f.dims)-1.

source