Domains

SawyerEliassenSolver.Domains.GridType
struct Grid{T<:Union{Float32, Float64}}

The physical grid. $x$ is uniformly spaced and periodic with the left boundary at $x[1]$ and the right boundary at $x[NX + 1] = x[1]$ as is standard for DFTs. $z$ is a standard DCT/DST type II grid – uniformly spaced interior points with the boundaries at $z[1/2]$ and $z[NZ + 1/2]$. The float type of the grid determines the float point precision of the simulation and since we use FFTW is restriced to Float32 or Float64.

Fields

  • NX::Int64: Number of grid points in $x$

  • NZ::Int64: Number of grid points in $z$

  • x_bounds::Tuple{T, T} where T<:Union{Float32, Float64}: Lower and upper $x$ bounds: $[x₀,x₁)$

  • z_bounds::Tuple{T, T} where T<:Union{Float32, Float64}: Lower and upper $z$ bounds: $[z₀,z₁]$

source
SawyerEliassenSolver.Domains.GridMethod
Grid(FT, NX, NZ, x_bounds, z_bounds) -> Grid

Create a physical Grid with float type FT and (NX,NZ) points. The lateral bounds, [x₀,x₁) are set with a 2-tuple x_bounds or a single number LX which is equivalent to passing (0, LX). Similarly, the vertical bounds [z₀,z₁] are set by the 2-tuple z_bounds or a height LZ equivalent to (-LZ, 0).

Examples

julia> grid = Grid(256,128,(-1000,1000),(-1,1))
Grid{Float64}:
  ├── NX: 256
  ├── NZ: 128
  ├─── x: [-1000,1000)
  └─── z: [-1,1]
julia> grid = Grid(Float32,256,128,(-1000,1000),10)
Grid{Float32}:
  ├── NX: 256
  ├── NZ: 128
  ├─── x: [-1000,1000)
  └─── z: [-10,0]
source
SawyerEliassenSolver.Domains.gridpointsMethod
gridpoints(
    grid::Grid
) -> Tuple{Union{Base.ReshapedArray{Float32, 2, LinRange{Float32, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, LinRange{Float64, Int64}, Tuple{}}}, Union{Base.ReshapedArray{Float32, 2, LinRange{Float32, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, LinRange{Float64, Int64}, Tuple{}}}}

Get both the $x$ and $z$ gridpoints, reshaped to size (NX,1) and (1,NZ) ready for broadcasting.

source
SawyerEliassenSolver.Domains.DomainType
struct Domain{T<:Union{Float32, Float64}}

The domain, both physical and spectral, on which a problem is defined. This struct also stores the FFTW plans for transforming between the physical and spectral representations of variables.

source
SawyerEliassenSolver.Domains.DomainMethod
Domain(grid::Grid{T}; dealias_x, dealias_z) -> Domain

Construct a domain from a grid. To dealias the products with the background flow a number of the higher wavenumbers can be zeroed out. The number of retained wavenumbers are CNX = grid.NX ÷ 2 - dealias_x and CNZ = grid.NZ - 1 - dealias_z Note that we already drop the Nyquist wavenumber in $x$ as well as the zeroth (barotropic) cosine mode / highest sine mode.

Examples

Build an domain with no dealiasing.

julia> grid = Grid(16,8,1,1);

julia> domain = Domain(grid)
Domain:
  ├─────────── grid: Grid with eltype Float64 and size (16, 8)
  ├─────── spectral: Spectral domain of size (9, 8) and spectral resolution (8, 7)
  └───── transforms: FFTW transforms: rfft, type II DST and type II DCT.

A domain with dealising in the vertical.

julia> grid = Grid(16,8,1,1);

julia> domain = Domain(grid, dealias_z=2)
Domain:
  ├─────────── grid: Grid with eltype Float64 and size (16, 8)
  ├─────── spectral: Spectral domain of size (9, 8) and spectral resolution (8, 5)
  └───── transforms: FFTW transforms: rfft, type II DST and type II DCT.
source
SawyerEliassenSolver.Domains.gridpointsMethod
gridpoints(
    domain::Domain
) -> Tuple{Union{Base.ReshapedArray{Float32, 2, LinRange{Float32, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, LinRange{Float64, Int64}, Tuple{}}}, Union{Base.ReshapedArray{Float32, 2, LinRange{Float32, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, LinRange{Float64, Int64}, Tuple{}}}}
source
SawyerEliassenSolver.Domains.wavenumbersMethod
wavenumbers(
    domain::Domain
) -> Tuple{Union{Base.ReshapedArray{Float32, 2, StepRangeLen{Float32, Float64, Float64, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Tuple{}}}, Union{Base.ReshapedArray{Float32, 2, StepRangeLen{Float32, Float64, Float64, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Tuple{}}}}

Resolved $k_x$ and $k_z$ reshaped to size (CNX,1) and (1,CNZ) ready for broadcasting.

source
SawyerEliassenSolver.Domains.wavenumbers_fullMethod
wavenumbers_full(
    domain::Domain
) -> Tuple{Union{Base.ReshapedArray{Float32, 2, StepRangeLen{Float32, Float64, Float64, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Tuple{}}}, Union{Base.ReshapedArray{Float32, 2, StepRangeLen{Float32, Float64, Float64, Int64}, Tuple{}}, Base.ReshapedArray{Float64, 2, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Tuple{}}}}

$k_x$ and $k_z$ including unresolved zeroed-out wavenumbers reshaped to size (NX ÷ 2 + 1,1) and (1,NZ) ready for broadcasting.

source
SawyerEliassenSolver.Domains.xwavenumbersMethod
xwavenumbers(
    domain::Domain
) -> Union{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}

The resolved $x$ wavenumbers $k_x$.

source
SawyerEliassenSolver.Domains.xwavenumbers_fullMethod
xwavenumbers_full(
    domain::Domain
) -> Union{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}

The $x$ wavenumbers $k_x$ including unresolved zeroed-out wavenumbers.

source
SawyerEliassenSolver.Domains.zwavenumbersMethod
zwavenumbers(
    domain::Domain
) -> Union{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}

The resolved $z$ wavenumbers $k_z$.

source
SawyerEliassenSolver.Domains.zwavenumbers_fullMethod
zwavenumbers_full(
    domain::Domain
) -> Union{StepRangeLen{Float32, Float64, Float64, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}

The $z$ wavenumbers $k_z$ including unresolved zeroed-out wavenumbers.

source