Skip to content

Commit

Permalink
doc: Consolidate documentation for Grids
Browse files Browse the repository at this point in the history
`Grids` and `PencilGrids` have separate docstrings for different
constructor methods.  Consolidate these.
  • Loading branch information
musoke committed Apr 12, 2024
1 parent 3d70f37 commit e1ad68f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 69 deletions.
56 changes: 21 additions & 35 deletions src/grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,38 @@ Abstract type for grids containing simulation data
abstract type AbstractGrids end

"""
Grids(length, resol::Int)
Grids(length_tuple, resol_tuple::Tuple{Int, Int, Int})
struct containing grids used in a simulation
# Examples
Create an empty grid with length `length` and resolution `resol`
```jldoctest
julia> using UltraDark
julia> len = 1;
julia> length = 1;
julia> resol = 16;
julia> Grids(len, resol);
julia> Grids(length, resol);
julia> size(ans.ψx)
(16, 16, 16)
```
Create an empty `length[1]`x`length[2]`x`length[3]` grid with resolution
`resol[1]`x`resol[2]`x`resol[3]`.
```jldoctest
julia> using UltraDark
julia> Grids((1.0, 1.0, 0.5), (64, 64, 32));
julia> size(ans.ψx)
(64, 64, 32)
```
"""
struct Grids <: AbstractGrids
Expand Down Expand Up @@ -123,45 +142,12 @@ struct Grids <: AbstractGrids
end
end

"""
Grids(length, resol::Int)
Constructor for `Grids`
Create an empty grid with length `length` and resolution `resol`
# Examples
```jldoctest
julia> using UltraDark
julia> Grids(1.0, 64);
```
"""
function Grids(length, resol::Int)::Grids

Grids((length, length, length), (resol, resol, resol))

end

"""
Grids(length_tuple, resol_tuple::Tuple{Int, Int, Int})
Constructor for `Grids`
Create an empty `length[1]`x`length[2]`x`length[3]` grid with resolution
`resol[1]`x`resol[2]`x`resol[3]`.
# Examples
```jldoctest
julia> using UltraDark
julia> Grids((1.0, 1.0, 0.5), (64, 64, 32));
```
"""
function Grids(length_tuple, resol_tuple::Tuple{Int,Int,Int})::Grids

resol_tuple_realfft = (resol_tuple[1] ÷ 2 + 1, resol_tuple[2], resol_tuple[3])
Expand Down
51 changes: 17 additions & 34 deletions src/pencil_grids.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
"""
PencilGrids(length, resol)
PencilGrids(length_tuple, resol_tuple::Tuple{Int, Int, Int})
struct containing grids used in a simulation
Each grid is a `PencilArray`, allowing multiprocess FFTs.
This comes with significant overhead so is only useful when running in a multi-node environment.
# Examples
Create an empty grid with length `length` and resolution `resol`. Uses `PencilFFTs` to create `PencilArrays`.
```jldoctest
julia> using UltraDark
Expand All @@ -12,6 +19,16 @@ julia> resol = 16;
julia> PencilGrids(len, resol);
```
Create an empty `length[1]`x`length[2]`x`length[3]` grid with resolution
`resol[1]`x`resol[2]`x`resol[3]`.
```jldoctest
julia> using UltraDark
julia> PencilGrids((1.0, 1.0, 0.5), (64, 64, 32));
```
"""
struct PencilGrids{K,RX,RK,CX,CK,FFT,RFFT,M} <: AbstractGrids
Expand Down Expand Up @@ -144,46 +161,12 @@ struct PencilGrids{K,RX,RK,CX,CK,FFT,RFFT,M} <: AbstractGrids
end
end

"""
PencilGrids(length, resol)
Constructor for `PencilGrids`
Create an empty grid with length `length` and resolution `resol`. Uses `PencilFFTs` to create `PencilArrays`.
# Examples
```jldoctest
julia> using UltraDark
julia> PencilGrids(1.0, 64);
```
"""
function PencilGrids(length, resol::Int)::PencilGrids

PencilGrids((length, length, length), (resol, resol, resol))

end

"""
PencilGrids(length_tuple, resol_tuple::Tuple{Int, Int, Int})
Constructor for `PencilGrids`
Create an empty `length[1]`x`length[2]`x`length[3]` grid with resolution
`resol[1]`x`resol[2]`x`resol[3]`.
Each grid is a `PencilArray`, allowing multiprocess FFTs.
# Examples
```jldoctest
julia> using UltraDark
julia> PencilGrids((1.0, 1.0, 0.5), (64, 64, 32));
```
"""
function PencilGrids(length_tuple, resol_tuple::Tuple{Int,Int,Int})::PencilGrids

resol_tuple_realfft = (resol_tuple[1] ÷ 2 + 1, resol_tuple[2], resol_tuple[3])
Expand Down

0 comments on commit e1ad68f

Please sign in to comment.