Public Documentation

Documentation for FourierFlows.jl's public interface.

See the Internals section of the manual for internal package docs covering all submodules.

FourierFlows

FourierFlows.FourierFlowsModule

Main module for FourierFlows.jl – an ecosystem for solving partial differential equations on periodic domains using Fourier-based pseudospectral methods."

Exports

source

Problem

Domain

FourierFlows.OneDGridType
struct OneDGrid{T<:AbstractFloat, Tk, Tx, Tfft, Trfft, Talias} <: AbstractGrid{T, Tk, Talias}

A one-dimensional grid.

  • nx::Int64

    number of points in x

  • nk::Int64

    number of wavenumbers in x

  • nkr::Int64

    number of positive wavenumbers in x (real Fourier transforms)

  • dx::AbstractFloat

    grid spacing in x

  • Lx::AbstractFloat

    domain extent in x

  • x::Any

    range with x-grid-points

  • k::Any

    array with x-wavenumbers

  • kr::Any

    array with positive x-wavenumbers (real Fourier transforms)

  • invksq::Any

    array with inverse squared k-wavenumbers, 1/k²

  • invkrsq::Any

    array with inverse squared kr-wavenumbers, 1/kr²

  • fftplan::Any

    the FFT plan for complex-valued fields

  • rfftplan::Any

    the FFT plan for real-valued fields

  • aliased_fraction::AbstractFloat

    the fraction of wavenumbers that are aliased (e.g., 1/3 for quadradic nonlinearities)

  • kalias::Any

    range of the indices of aliased x-wavenumbers

  • kralias::Any

    range of the indices of aliased positive x-wavenumbers (real Fourier transforms)

source
FourierFlows.OneDGridMethod
OneDGrid(nx, Lx; x0=-Lx/2, nthreads=Sys.CPU_THREADS, effort=FFTW.MEASURE, 
                  T=Float64, aliased_fraction=1/3, ArrayType=Array)

Constructs a OneDGrid object with size Lx, resolution nx, and leftmost position x0. FFT plans are generated for nthreads CPUs using FFTW flag effort. The float type is T and the array types is ArrayType. The aliased_fraction keyword determines the highest wavenubers that are being zero-ed out by dealias! function; 1/3 is the nominal value for quadratic nonlinearities.

source
FourierFlows.ThreeDGridType
struct ThreeDGrid{T<:AbstractFloat, Tk, Tx, Tfft, Trfft, Talias} <: AbstractGrid{T, Tk, Talias}

A three-dimensional grid.

  • nx::Int64

    number of points in x

  • ny::Int64

    number of points in y

  • nz::Int64

    number of points in z

  • nk::Int64

    number of wavenumbers in x

  • nl::Int64

    number of wavenumbers in y

  • nm::Int64

    number of wavenumbers in z

  • nkr::Int64

    number of positive wavenumers in x (real Fourier transforms)

  • dx::AbstractFloat

    grid spacing in x

  • dy::AbstractFloat

    grid spacing in y

  • dz::AbstractFloat

    grid spacing in z

  • Lx::AbstractFloat

    domain extent in x

  • Ly::AbstractFloat

    domain extent in y

  • Lz::AbstractFloat

    domain extent in z

  • x::Any

    range with x-grid-points

  • y::Any

    range with y-grid-points

  • z::Any

    range with z-grid-points

  • k::Any

    array with x-wavenumbers

  • l::Any

    array with y-wavenumbers

  • m::Any

    array with z-wavenumbers

  • kr::Any

    array with positive x-wavenumbers (real Fourier transforms)

  • Ksq::Any

    array with squared total wavenumbers, k²+l²+m²

  • invKsq::Any

    array with inverse squared total wavenumbers, 1/(k²+l²+m²)

  • Krsq::Any

    array with squared total wavenumbers for real Fourier transforms, kr²+l²+m²

  • invKrsq::Any

    array with inverse squared total wavenumbers for real Fourier transforms, 1/(kr²+l²+m²)

  • fftplan::Any

    the FFT plan for complex-valued fields

  • rfftplan::Any

    the FFT plan for real-valued fields

  • aliased_fraction::AbstractFloat

    the fraction of wavenumbers that are aliased (e.g., 1/3 for quadradic nonlinearities)

  • kalias::Any

    range of the indices of aliased x-wavenumbers

  • kralias::Any

    range of the indices of aliased positive x-wavenumbers (real Fourier transforms)

  • lalias::Any

    range of the indices of aliased y-wavenumbers

  • malias::Any

    range of the indices of aliased y-wavenumbers

source
FourierFlows.ThreeDGridType
ThreeDGrid(nx, Lx, ny=nx, Ly=Lx, nz=nx, Lz=Lx; x0=-Lx/2, y0=-Ly/2, z0=-Lz/2, 
nthreads=Sys.CPU_THREADS, effort=FFTW.MEASURE, T=Float64, aliased_fraction=1/3, ArrayType=Array)

Constructs a TwoDGrid object with size Lx, Ly, Lz, resolution nx, ny, nz and leftmost positions x0, y0, z0. FFT plans are generated for nthreads CPUs using FFTW flag effort. The float type is T and the array types is ArrayType. The aliased_fraction keyword determines the highest wavenubers that are being zero-ed out by dealias! function; 1/3 is the nominal value for quadratic nonlinearities.

source
FourierFlows.TwoDGridType
struct TwoDGrid{T<:AbstractFloat, Tk, Tx, Tfft, Trfft, Talias} <: AbstractGrid{T, Tk, Talias}

A two-dimensional grid.

  • nx::Int64

    number of points in x

  • ny::Int64

    number of points in y

  • nk::Int64

    number of wavenumbers in x

  • nl::Int64

    number of wavenumbers in y

  • nkr::Int64

    number of positive wavenumers in x (real Fourier transforms)

  • dx::AbstractFloat

    grid spacing in x

  • dy::AbstractFloat

    grid spacing in y

  • Lx::AbstractFloat

    domain extent in x

  • Ly::AbstractFloat

    domain extent in y

  • x::Any

    range with x-grid-points

  • y::Any

    range with y-grid-points

  • k::Any

    array with x-wavenumbers

  • l::Any

    array with y-wavenumbers

  • kr::Any

    array with positive x-wavenumbers (real Fourier transforms)

  • Ksq::Any

    array with squared total wavenumbers, k²+l²

  • invKsq::Any

    array with inverse squared total wavenumbers, 1/(k²+l²)

  • Krsq::Any

    array with squared total wavenumbers for real Fourier transforms, kr²+l²

  • invKrsq::Any

    array with inverse squared total wavenumbers for real Fourier transforms, 1/(kr²+l²)

  • fftplan::Any

    the FFT plan for complex-valued fields

  • rfftplan::Any

    the FFT plan for real-valued fields

  • aliased_fraction::AbstractFloat

    the fraction of wavenumbers that are aliased (e.g., 1/3 for quadradic nonlinearities)

  • kalias::Any

    range of the indices of aliased x-wavenumbers

  • kralias::Any

    range of the indices of aliased positive x-wavenumbers (real Fourier transforms)

  • lalias::Any

    range of the indices of aliased y-wavenumbers

source
FourierFlows.TwoDGridType
TwoDGrid(nx, Lx, ny=nx, Ly=Lx; x0=-Lx/2, y0=-Ly/2, nthreads=Sys.CPU_THREADS, 
                  effort=FFTW.MEASURE, T=Float64, aliased_fraction=1/3, ArrayType=Array)

Constructs a TwoDGrid object with size Lx, Ly, resolution nx, ny, and leftmost positions x0, y0. FFT plans are generated for nthreads CPUs using FFTW flag effort. The float type is T and the array types is ArrayType. The aliased_fraction keyword determines the highest wavenubers that are being zero-ed out by dealias! function; 1/3 is the nominal value for quadratic nonlinearities.

source
FourierFlows.gridpointsMethod
gridpoints(grid::TwoDGrid)
gridpoints(grid::ThreeDGrid)

Returns the collocation points of the grid in 2D or 3D arrays X, Y (and Z).

source

Utilities

FourierFlows.ArrayTypeMethod
ArrayType(::Device)
ArrayType(::Device, T, dim)

Returns the proper array type according to the Device chosen, i.e., Array for CPU and CuArray for GPU.

source
FourierFlows.innereltypeMethod
innereltype(x)

Recursively determine the 'innermost' type in by the collection x (which may be, for example, a collection of a collection).

source
FourierFlows.superzerosMethod
superzeros(T, A)

Returns an array like A, but full of zeros. If innereltype(A) can be promoted to T, then the innermost elements of the array will have type T.

source
FourierFlows.@devzerosMacro
@devzeros dev T dims a b c...

Create arrays of all zeros with element type T, size dims, and global names a, b, c (for example) on device dev.

source
FourierFlows.@superzerosMacro
@superzeros T a b c d...
@superzeros T dims b c d...

Generate arrays b, c, d... with the super-dimensions of a and innereltype T.

source
FourierFlows.@zerosMacro
@zeros T dims a b c...

Create arrays of all zeros with element type T, size dims, and global names a, b, c (for example). An arbitrary number of arrays may be created.

source

Diagnostics

FourierFlows.DiagnosticType
mutable struct Diagnostic{T, N} <: AbstractDiagnostic

A diagnostic that includes N elements of type T.

  • calc::Function

    function that returns the diagnostic via calc(prob)

  • prob::FourierFlows.Problem

    the relevant problem for this diagnostic

  • data::Vector{T} where T

    vector where the diagnostic time-series is saved

  • t::Vector{Float64}

    vector with the times for which the diagnostic was saved

  • steps::Vector{Int64}

    vector with the problem's step for which the diagnostic was saved

  • freq::Int64

    integer denoting how often (every how many problem.steps) to save the diagnostic

  • i::Int64

    integer denoting how many times the diagnostic.data was updated

source
FourierFlows.DiagnosticMethod
Diagnostic(calc, prob; freq=1, nsteps=100, ndata=ceil(Int, (nsteps+1)/freq))

Construct a diagnostic that stores the result of calc(prob) with frequency freq.

Keywords

  • freq: Diagnostic is saved every freq steps.
  • nsteps: The total number of steps in problem.
  • ndata: The number of diagnostics to be saved.
source

Output

FourierFlows.OutputType
struct Output

The composite type for output.

  • prob::FourierFlows.Problem

    the relevant problem for the output

  • path::String

    the path for the output file

  • fields::Dict{Symbol, Function}

    the fields to be saved; the relevant problem for this diagnostic

source
FourierFlows.OutputMethod
Output(prob, filename, fieldtuples...)

Define output for prob with fields and functions that calculate the output in the list of tuples fieldtuples = (fldname, func)....

source

Timesteppers

FourierFlows.FilteredRK4TimeStepperType
FilteredRK4TimeStepper(eq::Equation, dev::Device=CPU(); filterkwargs...)

Construct a 4th-order Runge-Kutta time stepper with spectral filtering for the equation eq.

source
FourierFlows.TimeStepperFunction
TimeStepper(stepper, equation, dt=nothing, dev=CPU(); kw...)

Instantiate the Timestepper for equation with timestep dt and on the device. The kw are passed to the timestepper constructor.

source
FourierFlows.stepforward!Method
stepforward!(prob::Problem, diags, nsteps::Int)

Step forward prob for nsteps, incrementing diags along the way. diags may be a single Diagnostic or a Vector of Diagnostics.

source

Diffusion Testbed Module

FourierFlows.Diffusion.ProblemFunction
Problem(dev::Device = CPU();
                 nx = 128,
                 Lx = 2π,
                  κ = 0,
                 dt = 0.01,
            stepper = "RK4",           
   aliased_fraction = 0,
                  T = Float64)

Construct a constant diffusivity problem.

Keyword arguments

  • dev: (required) CPU() or GPU(); computer architecture used to time-step problem.
  • nx: Number of grid points in $x$-domain.
  • Lx: Extent of the $x$-domain.
  • κ: Diffusivity coefficient.
  • dt: Time-step.
  • stepper: The extent of the $y$-domain.
  • aliased_fraction: the fraction of high-wavenubers that are zero-ed out by dealias!().
  • T: Float64 or Float32; floating point type used for problem data.
source