Skip to content

Commit

Permalink
generalizes MultilayerQG.Problem for Float64/Float32
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy committed Jul 1, 2019
1 parent 1cb08f6 commit 046c607
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.6.1"

[[FourierFlows]]
deps = ["FFTW", "Interpolations", "JLD2", "LinearAlgebra", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "1addb960281c1cbd44156975ebb8e21a99f79232"
deps = ["Coverage", "FFTW", "Interpolations", "JLD2", "LinearAlgebra", "Printf", "Random", "Reexport", "Statistics", "Test"]
git-tree-sha1 = "89f28ce759aadfffb3db7494e890d6511443efc4"
repo-rev = "master"
repo-url = "https://github.com/FourierFlows/FourierFlows.jl.git"
uuid = "2aec4490-903f-5c70-9b11-9bed06a700e1"
version = "0.3.0"

Expand Down
10 changes: 5 additions & 5 deletions src/multilayerqg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Problem(;
T = Float64)

grid = TwoDGrid(nx, Lx, ny, Ly; T=T)
params = Params(nlayers, g, f0, beta, rho, H, U, eta, mu, nu, nnu, grid, calcFq=calcFq)
params = Params(nlayers, T(g), T(f0), T(beta), Array{T}(rho), Array{T}(H), Array{T}(U), Array{T}(eta), T(mu), T(nu), nnu, grid, calcFq=calcFq)

This comment has been minimized.

Copy link
@navidcy

navidcy Jul 1, 2019

Author Member

@glwagner any better solution for this? It's so not elegant...

vars = calcFq == nothingfunction ? Vars(grid, params) : ForcedVars(grid, params)
eqn = linear ? LinearEquation(params, grid) : Equation(params, grid)

Expand Down Expand Up @@ -89,7 +89,7 @@ struct Params{T} <: AbstractParams
Qy::Array{T,3} # Array containing y-gradient of PV due to beta, U, and eta in each fluid layer
S::Array{T,4} # Array containing coeffients for getting PV from streamfunction
invS::Array{T,4} # Array containing coeffients for inverting PV to streamfunction
rfftplan::FFTW.rFFTWPlan{Float64,-1,false,3} # rfft plan for FFTs
rfftplan::FFTW.rFFTWPlan{T,-1,false,3} # rfft plan for FFTs
end

struct SingleLayerParams{T} <: BarotropicParams
Expand All @@ -109,7 +109,7 @@ struct SingleLayerParams{T} <: BarotropicParams
# derived params
Qx::Array{T,2} # Array containing zonal PV gradient due to beta, U, and eta in each fluid layer
Qy::Array{T,2} # Array containing meridional PV gradient due to beta, U, and eta in each fluid layer
rfftplan::FFTW.rFFTWPlan{Float64,-1,false,2} # rfft plan for FFTs
rfftplan::FFTW.rFFTWPlan{T,-1,false,2} # rfft plan for FFTs
end

function Params(nlayers, g, f0, beta, rho, H, U::Array{T,2}, eta, mu, nu, nnu, grid::AbstractGrid{T}; calcFq=nothingfunction, effort=FFTW.MEASURE) where T
Expand Down Expand Up @@ -146,10 +146,10 @@ function Params(nlayers, g, f0, beta, rho, H, U::Array{T,2}, eta, mu, nu, nnu, g
@views Qy[:, :, nlayers] = @. beta - Uyy[:, :, nlayers] - Fm[nlayers-1]*( U[:, :, nlayers-1] - U[:, :, nlayers] )
@views @. Qy[:, :, nlayers] += etay

S = Array{Float64}(undef, (nkr, nl, nlayers, nlayers))
S = Array{T}(undef, (nkr, nl, nlayers, nlayers))
calcS!(S, Fp, Fm, grid)

invS = Array{Float64}(undef, (nkr, nl, nlayers, nlayers))
invS = Array{T}(undef, (nkr, nl, nlayers, nlayers))
calcinvS!(invS, Fp, Fm, grid)

rfftplanlayered = plan_rfft(Array{T,3}(undef, grid.nx, grid.ny, nlayers), [1, 2]; flags=effort)
Expand Down

0 comments on commit 046c607

Please sign in to comment.