Mercurial > repos > public > sbplib_julia
changeset 1347:08f06bfacd5c refactor/grids
Fix typos and formatting of documentation
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 18 May 2023 22:53:31 +0200 |
parents | c2012db881cb |
children | 279179677040 |
files | Notes.md docs/src/grids_and_grid_functions.md src/Grids/equidistant_grid.jl src/Grids/grid.jl src/Grids/tensor_grid.jl src/SbpOperators/boundaryops/boundary_restriction.jl src/SbpOperators/boundaryops/normal_derivative.jl src/SbpOperators/volumeops/derivatives/dissipation.jl src/SbpOperators/volumeops/derivatives/first_derivative.jl src/SbpOperators/volumeops/derivatives/second_derivative.jl src/SbpOperators/volumeops/inner_products/inner_product.jl src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl src/SbpOperators/volumeops/laplace/laplace.jl |
diffstat | 13 files changed, 60 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/Notes.md Mon May 15 22:54:32 2023 +0200 +++ b/Notes.md Thu May 18 22:53:31 2023 +0200 @@ -207,7 +207,7 @@ * use `Base.splat((x,y)->x*y)` with the single argument `map`/`lmap`. * implement a kind of `unzip` function to get iterators for each component, which can then be used with the multiple-iterators-version of `map`/`lmap`. -* Inspect the function in the `map`/`lmap` function to determine which mathches. +* Inspect the function in the `map`/`lmap` function to determine which matches. Below is a partial implementation of `lmap` with some ideas ```julia
--- a/docs/src/grids_and_grid_functions.md Mon May 15 22:54:32 2023 +0200 +++ b/docs/src/grids_and_grid_functions.md Thu May 18 22:53:31 2023 +0200 @@ -1,6 +1,6 @@ # Grids and grid functions -The submodule `Grids` aims to provide types and logic for all types of grids that are useful for implementing summation-by-parts difference methods. It provides an abstract top level type `Grid` which defines a broad interface for how a general grid is supposed to work. Currently only equidistant grids are supported, but the basic structure supports implementations of curvilinear grids, multi-block grids, peridic grids and much more. +The submodule `Grids` aims to provide types and logic for all types of grids that are useful for implementing summation-by-parts difference methods. It provides an abstract top level type `Grid` which defines a broad interface for how a general grid is supposed to work. Currently only equidistant grids are supported, but the basic structure supports implementations of curvilinear grids, multi-block grids, periodic grids and much more. The module also has functionality for creating and working with grid functions.
--- a/src/Grids/equidistant_grid.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/Grids/equidistant_grid.jl Thu May 18 22:53:31 2023 +0200 @@ -53,8 +53,8 @@ """ refine(g::EquidistantGrid, r::Int) -Refines `grid` by a factor `r`. The factor is applied to the number of -intervals which is 1 less than the size of the grid. +The grid where `g` is refined by the factor `r`. The factor is applied to the number of +intervals, i.e., 1 less than the size of `g`. See also: [`coarsen`](@ref) """ @@ -64,10 +64,10 @@ end """ - coarsen(grid::EquidistantGrid, r::Int) + coarsen(g::EquidistantGrid, r::Int) -Coarsens `grid` by a factor `r`. The factor is applied to the number of -intervals which is 1 less than the size of the grid. If the number of +The grid where `g` is coarsened by the factor `r`. The factor is applied to the number of +intervals, i.e., 1 less than the size of `g`. If the number of intervals are not divisible by `r` an error is raised. See also: [`refine`](@ref) @@ -94,7 +94,7 @@ `limit_upper=(1,2)` the domain is defined as `(-1,1)x(0,2)`. The side lengths of the grid are not allowed to be negative. -The number of equidistantly spaced points in each coordinate direction are given +The number of equispaced points in each coordinate direction are given by the tuple `size`. Note: If `limit_lower` and `limit_upper` are integers and `size` would allow a @@ -127,9 +127,9 @@ """ - change_length(::AbstractRange, n) + change_length(r::AbstractRange, n) -Change the length of a range to `n`, keeping the same start and stop. +Change the length of `r` to `n`, keeping the same start and stop. """ function change_length end
--- a/src/Grids/grid.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/Grids/grid.jl Thu May 18 22:53:31 2023 +0200 @@ -14,7 +14,7 @@ ## Note Importantly a grid does not have to be an `AbstractArray`. The reason is to -allow flexible handling of special types of grids like multiblock-grids, or +allow flexible handling of special types of grids like multi-block grids, or grids with special indexing. """ abstract type Grid{T,D} end @@ -23,17 +23,17 @@ Base.eltype(::Type{<:Grid{T}}) where T = T """ - coordinate_size(grid) + coordinate_size(g) -The lenght of the coordinate vector for the given grid. +The lenght of the coordinate vector of `Grid` `g`. """ coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T) coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?! """ - component_type(grid) + component_type(g) -The type of the components of the coordinate vector. +The type of the components of the coordinate vector of `Grid` `g`. """ component_type(::Type{<:Grid{T}}) where T = eltype(T) component_type(g::Grid) = component_type(typeof(g)) @@ -41,7 +41,7 @@ """ refine(g::Grid, r) -`g` refined by the factor `r`. +The grid where `g` is refined by the factor `r`. See also: [`coarsen`](@ref). """ @@ -50,7 +50,7 @@ """ coarsen(g::Grid, r) -`g` coarsened by the factor `r`. +The grid where `g` is coarsened by the factor `r`. See also: [`refine`](@ref). """ @@ -64,9 +64,9 @@ function boundary_identifiers end """ - boundary_grid(g::Grid, bid::BoundaryIdentifier) + boundary_grid(g::Grid, id::BoundaryIdentifier) -The grid for the specified boundary. +The grid for the boundary specified by `id`. """ function boundary_grid end # TBD: Can we implement a version here that accepts multiple ids and grouped boundaries? Maybe we need multiblock stuff? @@ -78,7 +78,7 @@ with each coordinate as an argument, or on the form `f(x̄)` taking a coordinate vector. -If the goal is a concrete array `map(f,g)` can be used instead. +For concrete array grid functions `map(f,g)` can be used instead. """ eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) function eval_on(g::Grid, f, ::Base.HasShape)
--- a/src/Grids/tensor_grid.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/Grids/tensor_grid.jl Thu May 18 22:53:31 2023 +0200 @@ -57,9 +57,9 @@ boundary_id(::TensorGridBoundary{N, BID}) where {N, BID} = BID() """ - boundary_identifiers(::TensorGrid) + boundary_identifiers(g::TensorGrid) -Returns a tuple containing the boundary identifiers for the grid. +Returns a tuple containing the boundary identifiers of `g`. """ function boundary_identifiers(g::TensorGrid) per_grid = map(eachindex(g.grids)) do i @@ -70,13 +70,13 @@ """ - boundary_grid(grid::TensorGrid, id::TensorGridBoundary) + boundary_grid(g::TensorGrid, id::TensorGridBoundary) -The grid for the boundary specified by `id`. +The grid for the boundary of `g` specified by `id`. """ -function boundary_grid(g::TensorGrid, bid::TensorGridBoundary) - local_boundary_grid = boundary_grid(g.grids[grid_id(bid)], boundary_id(bid)) - new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(bid)) +function boundary_grid(g::TensorGrid, id::TensorGridBoundary) + local_boundary_grid = boundary_grid(g.grids[grid_id(id)], boundary_id(id)) + new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id)) return TensorGrid(new_grids...) end
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/boundaryops/boundary_restriction.jl Thu May 18 22:53:31 2023 +0200 @@ -5,8 +5,8 @@ Creates boundary restriction operators `e` as `LazyTensor`s on `boundary` -`e` is the restriction of a grid function to `boundary` using the 'e' stencil -in the guven stencil set. `e'` is the prolongation of a grid function on +`e` restricts a grid function on `g` to `boundary` using the 'e' stencil +in `stencil_set`. `e'` prolongates a grid function on `boundary` to the whole grid using the same stencil. On a one-dimensional grid, `e` is a `BoundaryOperator`. On a multi-dimensional grid, `e` is the inflation of a `BoundaryOperator`.
--- a/src/SbpOperators/boundaryops/normal_derivative.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/boundaryops/normal_derivative.jl Thu May 18 22:53:31 2023 +0200 @@ -5,11 +5,11 @@ Creates the normal derivative boundary operator `d` as a `LazyTensor` -`d` computes the normal derivative of a grid function on `boundary` using the -'d1' stencil in the given stencil_set. `d'` is the prolongation of the normal -derivative of a grid function to the whole grid using the same stencil. On a -one-dimensional `grid`, `d` is a `BoundaryOperator`. On a multi-dimensional -`grid`, `d` is the inflation of a `BoundaryOperator`. +`d` computes the normal derivative at `boundary` of a grid function on `g` using the +'d1' stencil in `stencil_set`. `d'` is the prolongation of the normal +derivative of a grid function to the whole of `g` using the same stencil. On a +one-dimensional grid, `d` is a `BoundaryOperator`. On a multi-dimensional +grid, `d` is the inflation of a `BoundaryOperator`. See also: [`BoundaryOperator`](@ref), [`LazyTensors.inflate`](@ref). """
--- a/src/SbpOperators/volumeops/derivatives/dissipation.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/volumeops/derivatives/dissipation.jl Thu May 18 22:53:31 2023 +0200 @@ -3,10 +3,10 @@ undivided_skewed04(g::EquidistantGrid, p) Undivided difference operators approximating the `p`th derivative. The -operators do not satisfy any SBP-property and are meant to be used for +operators do not satisfy any SBP property and are meant to be used for building artificial dissipation terms. -The operators and how they are used to create accurate artifical dissipation +The operators and how they are used to create accurate artificial dissipation is described in "K. Mattsson, M. Svärd, and J. Nordström, “Stable and Accurate Artificial Dissipation,” Journal of Scientific Computing, vol. 21, no. 1, pp. 57–79, Aug. 2004"
--- a/src/SbpOperators/volumeops/derivatives/first_derivative.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/volumeops/derivatives/first_derivative.jl Thu May 18 22:53:31 2023 +0200 @@ -1,7 +1,7 @@ """ first_derivative(g, ..., [direction]) -The first-derivative operator `D1` as a `LazyTensor` on the given grid. +The first derivative operator `D1` as a `LazyTensor` on the given grid. `D1` approximates the first-derivative d/dξ on `g` along the coordinate dimension specified by `direction`. @@ -19,10 +19,10 @@ end """ - first_derivative(g::EquidistantGrid, stencil_set) + first_derivative(g::EquidistantGrid, stencil_set::StencilSet) -The first derivative operator on a `EquidistantGrid` given a -`StencilSet`. Uses the `D1` stencil in the stencil set. +The first derivative operator on an `EquidistantGrid`. +Uses the `D1` stencil in `stencil_set`. """ function first_derivative(g::EquidistantGrid, stencil_set::StencilSet) inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"]) @@ -31,10 +31,10 @@ end """ - first_derivative(g::EquidistantGrid, inner_stencil, closure_stencils) + first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) -The first derivative operator on a `EquidistantGrid` given an -`inner_stencil` and a`closure_stencils`. +The first derivative operator on an `EquidistantGrid` given an +`inner_stencil` and `closure_stencils`. """ function first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) h⁻¹ = inverse_spacing(g)
--- a/src/SbpOperators/volumeops/derivatives/second_derivative.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/volumeops/derivatives/second_derivative.jl Thu May 18 22:53:31 2023 +0200 @@ -1,7 +1,7 @@ """ second_derivative(g::EquidistantGrid, stencil_set, direction) -Creates the second-derivative operator `D2` as a `LazyTensor` +Creates the second derivative operator `D2` as a `LazyTensor` `D2` approximates the second-derivative d²/dξ² on `g` along the coordinate dimension specified by `direction`. @@ -14,10 +14,10 @@ end """ - second_derivative(g, stencil_set) + second_derivative(g::EquidistantGrid, stencil_set::::StencilSet) -Creates a `second_derivative` operator on a 1D `g` given a `stencil_set`. Uses -the `D2` stencil in the stencil set. +The second derivative operator on an `EquidistantGrid`. +Uses the `D2` stencil in `stencil_set`. """ function second_derivative(g::EquidistantGrid, stencil_set::StencilSet) inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) @@ -26,9 +26,9 @@ end """ - second_derivative(g, inner_stencil, closure_stencils) + second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) -Creates a `second_derivative` operator on a 1D `g` given `inner_stencil` and +The second derivative operator on an `EquidistantGrid`, given `inner_stencil` and `closure_stencils`. """ function second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils)
--- a/src/SbpOperators/volumeops/inner_products/inner_product.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/volumeops/inner_products/inner_product.jl Thu May 18 22:53:31 2023 +0200 @@ -9,8 +9,8 @@ """ inner_product(tg::TensorGrid, stencil_set::StencilSet) -The inner product on the given tensor grid which is the tensor product of the -individual grids' inner products. +The inner product on `tg`, i.e., the tensor product of the +individual grids' inner products, using weights `H` from `stencil_set`. """ function inner_product(tg::TensorGrid, stencil_set::StencilSet) return mapreduce(g->inner_product(g,stencil_set), ⊗, tg.grids) @@ -19,7 +19,7 @@ """ inner_product(g::EquidistantGrid, stencil_set::StencilSet) -The inner product using weights `H` from `stencil_set`. +The inner product on `g` using weights `H` from `stencil_set`. See also: [`ConstantInteriorScalingOperator`](@ref). """ @@ -46,7 +46,7 @@ The identity tensor with the correct type parameters. -Implemented to simplify 1D code for sbp-operators. +Implemented to simplify 1D code for SBP operators. """ inner_product(g::ZeroDimGrid, stencil_set::StencilSet) = IdentityTensor{component_type(g)}()
--- a/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl Thu May 18 22:53:31 2023 +0200 @@ -9,8 +9,8 @@ """ inverse_inner_product(tg::TensorGrid, stencil_set::StencilSet) -The inverse inner product on the given tensor grid which is the tensor product of the -individual grids' inner products. +The inverse of inner product on `tg`, i.e., the tensor product of the +individual grids' inverse inner products, using weights `H` from `stencil_set`. """ function inverse_inner_product(tg::TensorGrid, stencil_set::StencilSet) return mapreduce(g->inverse_inner_product(g,stencil_set), ⊗, tg.grids) @@ -19,7 +19,7 @@ """ inverse_inner_product(g::EquidistantGrid, stencil_set::StencilSet) -The inverse inner product using weights `H` from `stencil_set`. +The inverse of the inner product on `g` using weights `H` from `stencil_set`. See also: [`ConstantInteriorScalingOperator`](@ref). """ @@ -46,6 +46,6 @@ The identity tensor with the correct type parameters. -Implemented to simplify 1D code for sbp-operators. +Implemented to simplify 1D code for SBP operators. """ inverse_inner_product(g::ZeroDimGrid, stencil_set::StencilSet) = IdentityTensor{component_type(g)}()
--- a/src/SbpOperators/volumeops/laplace/laplace.jl Mon May 15 22:54:32 2023 +0200 +++ b/src/SbpOperators/volumeops/laplace/laplace.jl Thu May 18 22:53:31 2023 +0200 @@ -10,9 +10,9 @@ end """ - Laplace(grid::Equidistant, stencil_set) + Laplace(g::Grid, stencil_set::StencilSet) -Creates the `Laplace` operator `Δ` on `grid` given a `stencil_set`. +Creates the `Laplace` operator `Δ` on `g` given `stencil_set`. See also [`laplace`](@ref). """ @@ -31,7 +31,7 @@ """ laplace(g::Grid, stencil_set) -Creates the Laplace operator operator `Δ` as a `LazyTensor` on the given grid. +Creates the Laplace operator operator `Δ` as a `LazyTensor` on `g`. `Δ` approximates the Laplace operator ∑d²/xᵢ² , i = 1,...,`Dim` on `g`. The approximation depends on the type of grid and the stencil set.