Skip to content

Commit 90c9b99

Browse files
committed
Propagate rework
1 parent 8e9155a commit 90c9b99

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

src/GridOperators/field_operators.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This operation is performed along all dimensions of the grid.
4545
## Arguments
4646
- `V`: The vector field represented as a named tuple of fields.
4747
- `grid`: The structured grid on which the operation is performed.
48-
- `I...`: The indices specifying the location on the grid
48+
- `I...`: The indices specifying the location on the grid.
4949
"""
5050
@propagate_inbounds @generated function divg(V::NamedTuple{names,<:NTuple{N,AbstractField}}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {names,N}
5151
quote
@@ -67,7 +67,7 @@ This operation is performed along all dimensions of the grid.
6767
## Arguments
6868
- `F`: The field whose Laplacian is to be computed.
6969
- `grid`: The structured grid on which the operation is performed.
70-
- `I...`: The indices specifying the location on the grid
70+
- `I...`: The indices specifying the location on the grid.
7171
"""
7272
@propagate_inbounds @generated function lapl(F::AbstractField, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {N}
7373
quote
@@ -90,7 +90,7 @@ This operation is performed along all dimensions of the grid.
9090
- `F`: The field whose gradient is to be computed.
9191
- `K`: The weighting field for the gradient.
9292
- `grid`: The structured grid on which the operation is performed.
93-
- `I`: The indices specifying the location on the grid.
93+
- `I...`: The indices specifying the location on the grid.
9494
"""
9595
@propagate_inbounds @generated function divg_grad(F::AbstractField, K::AbstractField, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {N}
9696
quote

src/GridOperators/masked_field_operators.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ end
3737

3838
# covariant derivatives
3939
"""
40-
divg(V::NamedTuple{names,<:NTuple{N,AbstractField}}, ω::AbstractMask{T,N}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {names,T,N}
40+
divg(V, ω, grid, I)
4141
4242
Compute the divergence of a vector field `V` on a structured grid `grid`, using the mask `ω` to handle masked regions.
4343
This operation is performed along all dimensions of the grid.
4444
4545
## Arguments:
46-
- `V::NamedTuple{names,<:NTuple{N,AbstractField}}`: The vector field represented as a named tuple of fields.
47-
- `ω::AbstractMask`: The mask for the grid.
48-
- `grid::StructuredGrid{N}`: The structured grid on which the operation is performed.
49-
- `I`: The indices specifying the location on the grid (Tuple or Cartesian indices).
46+
- `V`: The vector field represented as a named tuple of fields.
47+
- `ω`: The mask for the grid.
48+
- `grid`: The structured grid on which the operation is performed.
49+
- `I...`: The indices specifying the location on the grid.
5050
"""
5151
@propagate_inbounds @generated function divg(V::NamedTuple{names,<:NTuple{N,AbstractField}},
5252
ω::AbstractMask{T,N},
@@ -66,16 +66,16 @@ end
6666
end
6767

6868
"""
69-
lapl(F::AbstractField, ω::AbstractMask{T,N}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {T,N}
69+
lapl(F, ω, grid, I...)
7070
7171
Compute the Laplacian of a field `F` on a structured grid `grid`.
7272
This operation is performed along all dimensions of the grid.
7373
7474
## Arguments
75-
- `F::AbstractField`: The field whose Laplacian is to be computed.
76-
- `ω::AbstractMask`: The mask for the grid.
77-
- `grid::StructuredGrid{N}`: The structured grid on which the operation is performed.
78-
- `I`: The indices specifying the location on the grid (Tuple or Cartesian indices).
75+
- `F`: The field whose Laplacian is to be computed.
76+
- `ω`: The mask for the grid.
77+
- `grid`: The structured grid on which the operation is performed.
78+
- `I...`: The indices specifying the location on the grid.
7979
"""
8080
@propagate_inbounds @generated function lapl(F::AbstractField,
8181
ω::AbstractMask{T,N},
@@ -95,17 +95,17 @@ end
9595
end
9696

9797
"""
98-
divg_grad(F::AbstractField, K::AbstractField, ω::AbstractMask{T,N}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {T,N}
98+
divg_grad(F, K, ω, grid, I...)
9999
100100
Compute the divergence of the diffusion flux of a field `F` weighted by a coefficient `K` on a structured grid `grid`.
101101
This operation is performed along all dimensions of the grid.
102102
103103
## Arguments
104-
- `F::AbstractField`: The field whose gradient is to be computed.
105-
- `K::AbstractField`: The weighting field for the gradient.
106-
- `ω::AbstractMask`: The mask for the grid.
107-
- `grid::StructuredGrid{N}`: The structured grid on which the operation is performed.
108-
- `I`: The indices specifying the location on the grid (Tuple or Cartesian indices).
104+
- `F`: The field whose gradient is to be computed.
105+
- `K`: The weighting field for the gradient.
106+
- `ω`: The mask for the grid.
107+
- `grid`: The structured grid on which the operation is performed.
108+
- `I...`: The indices specifying the location on the grid.
109109
"""
110110
@propagate_inbounds @generated function divg_grad(F::AbstractField,
111111
K::AbstractField,

src/GridOperators/masked_operators.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ end
2323
@add_cartesian (f, loc, from, ω::AbstractMask, grid, dim, I::Vararg{Integer,N}) where {N} = δ(f, loc, from, ω, dim, I...) * (grid, loc, dim, I...)
2424

2525
@add_cartesian function ∂²(f, loc, from, ω::AbstractMask, grid, dim::Dim{D}, I::Vararg{Integer,N}) where {N,D}
26-
Ir = ir(flipped(loc, dim)[D], from[D], dim, I...)
27-
Il = il(flipped(loc, dim)[D], from[D], dim, I...)
26+
floc = flipped(loc, dim)
27+
Ir = ir(floc[D], from[D], dim, I...)
28+
Il = il(floc[D], from[D], dim, I...)
2829
return ((f, ω, grid, dim, Ir...) - (f, ω, grid, dim, Il...)) * (grid, loc, dim, I...)
2930
end
3031

3132
@add_cartesian function ∂k∂(f, k, loc, from, ω::AbstractMask, grid, dim::Dim{D}, I::Vararg{Integer,N}) where {N,D}
32-
Ir = ir(flipped(loc, dim)[D], from[D], dim, I...)
33-
Il = il(flipped(loc, dim)[D], from[D], dim, I...)
34-
return (lerp(k, flipped(loc, dim), grid, Ir...) * (f, ω, grid, dim, Ir...) -
35-
lerp(k, flipped(loc, dim), grid, Il...) * (f, ω, grid, dim, Il...)) *
33+
floc = flipped(loc, dim)
34+
Ir = ir(floc[D], from[D], dim, I...)
35+
Il = il(floc[D], from[D], dim, I...)
36+
return (lerp(k, floc, grid, Ir...) * (f, ω, grid, dim, Ir...) -
37+
lerp(k, floc, grid, Il...) * (f, ω, grid, dim, Il...)) *
3638
(grid, loc, dim, I...)
3739
end

0 commit comments

Comments
 (0)