WVGeometryDoublyPeriodic
A domain periodic in both x and y.
Overview
The WVGeometryDoublyPeriodic encapsulates the transformations and logic necessary for computing Fourier transforms and spectral derivatives in a doubly periodic domain.
The class primarily converts between two different data structures for representing functions of (k,l): what we call the “DFT” grid, and the “WV” grid. The DFT grid is appropriate for many FFT algorithms, while the WV grid is ideal for the vertical mode matrix multiplications in the WaveVortexModel, as it contains no redundant coefficients.
The DFT layout is the the matrix structure used by many modern FFT algorithms. For real-valued functions, this format contains twice as much information as necessary, due to Hermitian conjugacy. Additionally, we often want to restrict ourselves to wavenumbers that do not alias with quadratic multiplication (the two-thirds rule). In two dimensions, this means that 4/9ths of the available wavenumbers are aliased. The WV layout thus does not include either the Hermitian conjugates nor the aliased modes.
The basic usage of the indices is as follows: assume wvMatrix and dftMatrix are shaped as
size(wvMatrix) == [Nkl_wv 1];
size(dftMatrix) == [Nk_dft Nl_dft]; % (equivalently [Nx Ny]
then to transform data from the DFT matrix to the WV matrix,
wvMatrix = dftMatrix(dftPrimaryIndices);
and the reverse is
dftMatrix(dftPrimaryIndices) = wvMatrix;
dftMatrix(dftConjugateIndices) = conj(wvMatrix(wvConjugateIndex));
Topics
- Initialization
WVGeometryDoublyPeriodic
create a geometry for a doubly periodic domain
- Domain attributes
- Spatial grid
- DFT grid
Nk_dft
length of the k-wavenumber dimension on the DFT gridNl_dft
length of the l-wavenumber dimension on the DFT gridconjugateDimension
assumed conjugate dimensionkMode_dft
k mode-number on the DFT gridk_dft
k wavenumber dimension on the DFT gridlMode_dft
l mode-number on the DFT gridl_dft
l wavenumber dimension on the DFT grid
- WV grid
Nkl_wv
length of the combined kl-wavenumber dimension on the WV griddftConjugateIndices
index into the DFT grid of the conjugate of each WV modedftPrimaryIndices
index into the DFT grid of each WV modekMode_wv
k mode number on the WV gridkRadial_wv
radial (k,l) wavenumber on the WV gridk_wv
k-wavenumber dimension on the WV gridlMode_wv
l mode number on the WV gridl_wv
l-wavenumber dimension on the WV gridshouldAntialias
whether the WV grid includes quadratically aliased wavenumbersshouldExcludeNyquist
whether the WV grid includes Nyquist wavenumbersshouldExludeConjugates
whether the WV grid includes wavenumbers that are Hermitian conjugates
- Operations
- Grid transformation
transformFromDFTGridToWVGrid
convert from DFT to WV gridtransformFromWVGridToDFTGrid
convert from a WV to DFT grid
- Fourier transformation
transformFromSpatialDomain
transform from \((x,y,z)\) to \((k,l,z)\) on the DFT gridtransformToSpatialDomain
transform from \((k,l,z)\) on the DFT grid to \((x,y,z)\)transformToSpatialDomainAtPosition
transform from \((k,l)\) on the DFT grid to \((x,y)\) at any position
- Differentiation
- Grid transformation
- Index gymnastics
indicesFromDFTGridToWVGrid
indices to convert from DFT to WV gridindicesFromWVGridToDFTGrid
indices to convert from WV to DFT gridisValidConjugateWVModeNumber
return a boolean indicating whether (k,l) is a valid conjugate WV mode numberisValidPrimaryWVModeNumber
return a boolean indicating whether (k,l) is a valid primary (non-conjugate) WV mode numberisValidWVModeNumber
return a boolean indicating whether (k,l) is a valid WV mode numbermodeNumberFromWVIndex
return mode number from a linear index into a WV matrixprimaryModeNumberFromWVModeNumber
takes any valid WV mode number and returns the primary mode numberwvIndexFromModeNumber
return the linear index into k_wv and l_wv from a mode number
- Masks
maskForAliasedModes
returns a mask with locations of modes that will alias with a quadratic multiplication.maskForConjugateFourierCoefficients
a mask indicate the components that are redundant conjugatesmaskForNyquistModes
returns a mask with locations of modes that are not fully resolved
- Utility function
degreesOfFreedomForComplexMatrix
a matrix with the number of degrees-of-freedom at each entrydegreesOfFreedomForRealMatrix
a matrix with the number of degrees-of-freedom at each entryindicesOfFourierConjugates
a matrix of linear indices of the conjugateisHermitian
Check if the matrix is Hermitian. Report errors.setConjugateToUnity
set the conjugate of the wavenumber (iK,iL) to 1