Skip to content

Commit

Permalink
update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
youwuyou committed Jun 17, 2024
1 parent 0c4e3ee commit d599e6a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Distributed/exchange_halo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,26 @@ function exchange_halo!(arch::DistributedArchitecture, grid::StructuredGrid{N},
return
end

# Adapter for BoundaryConditions
function BoundaryConditions.bc!(side::Side, dim::Dim,
"""
BoundaryConditions.bc!(side::Side, dim::Dim,
arch::DistributedArchitecture,
grid::StructuredGrid,
batch::ExchangeBatch; kwargs...)
Apply boundary conditions on a distrbuted grid with halo exchange performed internally.
# Arguments
- `side`: The side of the grid where the halo exchange is performed.
- `dim`: The dimension along which the halo exchange is performed.
- `arch`: The distributed architecture used for communication.
- `grid`: The structured grid on which the halo exchange is performed.
- `batch`: The batch set to apply boundary conditions to.
"""
function BoundaryConditions.bc!(side::Side,
dim::Dim,
arch::DistributedArchitecture,
grid::StructuredGrid,
batch::ExchangeBatch; kwargs...)
exchange_halo!(side, dim, arch, grid, batch.fields...; kwargs...)
return
end
end
7 changes: 7 additions & 0 deletions src/Fields/field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ end

_expand(rng::AbstractUnitRange, h) = (first(rng)-h):(last(rng)+h)

"""
interior(f::Field; with_halo=false)
Displays the field on the interior of the grid on which it is defined on.
One could optionally specify to display the halo regions on the grid with
`with_halo=true`.
"""
function interior(f::Field; with_halo=false)
ax = with_halo ? _expand.(axes(f), halo(f)) : axes(f)
indices = broadcast(.+, 2 .* halo(f), ax)
Expand Down
22 changes: 22 additions & 0 deletions src/Grids/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ Abstract type representing a location in a grid cell.
"""
abstract type Location end

"""
struct Center <: Location
The `Center` struct represents a location at the center along a dimension of a grid cell.
"""
struct Center <: Location end

"""
struct Vertex <: Location
The `Vertex` struct represents a location at the vertex along a dimension of a grid cell.
"""
struct Vertex <: Location end

Base.@assume_effects :total flip(::Center) = Vertex()
Expand Down Expand Up @@ -53,7 +64,18 @@ include("uniform_axis.jl")
include("function_axis.jl")
include("structured_grid.jl")

"""
Δ
Alias for the `spacing` method that returns the spacing between grid points.
"""
const Δ = spacing

"""
Alias for the `inv_spacing` method that returns the reciprocal of the spacing between grid points.
"""
const= inv_spacing

end # module Grids
17 changes: 17 additions & 0 deletions src/Grids/structured_grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,25 @@ direction(::SG, ::Val{:x}) = Dim(1)
direction(::SG, ::Val{:y}) = Dim(2)
direction(::SG, ::Val{:z}) = Dim(3)

"""
axes_names(::SG{1})
Returns the names of the axes for a 1-dimensional structured grid.
"""
axes_names(::SG{1}) = (:x,)

"""
axes_names(::SG{2})
Returns the names of the axes for a 2-dimensional structured grid.
"""
axes_names(::SG{2}) = (:x, :y)

"""
axes_names(::SG{3})
Returns the names of the axes for a 3-dimensional structured grid.
"""
axes_names(::SG{3}) = (:x, :y, :z)

# cell volumes
Expand Down

0 comments on commit d599e6a

Please sign in to comment.