|
14 | 14 | @add_cartesian function δ(f::AbstractField, ω::AbstractMask, dim, I::Vararg{Integer,N}) where {N} |
15 | 15 | loc = location(f) |
16 | 16 | from = flipped(loc, dim) |
17 | | - δ(f, loc, from, ω, dim, I...) |
| 17 | + return δ(f, loc, from, ω, dim, I...) |
18 | 18 | end |
19 | 19 |
|
20 | 20 | @add_cartesian function ∂(f::AbstractField, ω::AbstractMask, grid, dim, I::Vararg{Integer,N}) where {N} |
|
23 | 23 | return ∂(f, loc, from, ω, grid, dim, I...) |
24 | 24 | end |
25 | 25 |
|
| 26 | +@add_cartesian function ∂²(f::AbstractField, ω::AbstractMask, grid, dim, I::Vararg{Integer,N}) where {N} |
| 27 | + loc = location(f) |
| 28 | + from = location(f) |
| 29 | + return ∂²(f, loc, from, ω, grid, dim, I...) |
| 30 | +end |
| 31 | + |
| 32 | +@add_cartesian function ∂k∂(f::AbstractField, k::AbstractField, ω::AbstractMask, grid, dim, I::Vararg{Integer,N}) where {N} |
| 33 | + loc = location(f) |
| 34 | + from = location(f) |
| 35 | + return ∂k∂(f, k, loc, from, ω, grid, dim, I...) |
| 36 | +end |
| 37 | + |
26 | 38 | # covariant derivatives |
| 39 | +""" |
| 40 | + divg(V::NamedTuple{names,<:NTuple{N,AbstractField}}, ω::AbstractMask{T,N}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {names,T,N} |
| 41 | +
|
| 42 | +Compute the divergence of a vector field `V` on a structured grid `grid`, using the mask `ω` to handle masked regions. |
| 43 | +This operation is performed along all dimensions of the grid. |
| 44 | +
|
| 45 | +## 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). |
| 50 | +""" |
27 | 51 | @propagate_inbounds @generated function divg(V::NamedTuple{names,<:NTuple{N,AbstractField}}, |
28 | 52 | ω::AbstractMask{T,N}, |
29 | 53 | grid::StructuredGrid{N}, |
|
40 | 64 | I::CartesianIndex{N}) where {names,T,N} |
41 | 65 | return divg(V, ω, grid, Tuple(I)...) |
42 | 66 | end |
| 67 | + |
| 68 | +""" |
| 69 | + lapl(F::AbstractField, ω::AbstractMask{T,N}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {T,N} |
| 70 | +
|
| 71 | +Compute the Laplacian of a field `F` on a structured grid `grid`. |
| 72 | +This operation is performed along all dimensions of the grid. |
| 73 | +
|
| 74 | +## 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). |
| 79 | +""" |
| 80 | +@propagate_inbounds @generated function lapl(F::AbstractField, |
| 81 | + ω::AbstractMask{T,N}, |
| 82 | + grid::StructuredGrid{N}, |
| 83 | + I::Vararg{Integer,N}) where {T,N} |
| 84 | + quote |
| 85 | + @inline |
| 86 | + Base.Cartesian.@ncall $N (+) D -> ∂²(F, ω, grid, Dim(D), I...) |
| 87 | + end |
| 88 | +end |
| 89 | + |
| 90 | +@propagate_inbounds function lapl(F::AbstractField, |
| 91 | + ω::AbstractMask{T,N}, |
| 92 | + grid::StructuredGrid{N}, |
| 93 | + I::CartesianIndex{N}) where {T,N} |
| 94 | + return lapl(F, ω, grid, Tuple(I)...) |
| 95 | +end |
| 96 | + |
| 97 | +""" |
| 98 | + divg_grad(F::AbstractField, K::AbstractField, ω::AbstractMask{T,N}, grid::StructuredGrid{N}, I::Vararg{Integer,N}) where {T,N} |
| 99 | +
|
| 100 | +Compute the divergence of the diffusion flux of a field `F` weighted by a coefficient `K` on a structured grid `grid`. |
| 101 | +This operation is performed along all dimensions of the grid. |
| 102 | +
|
| 103 | +## 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). |
| 109 | +""" |
| 110 | +@propagate_inbounds @generated function divg_grad(F::AbstractField, |
| 111 | + K::AbstractField, |
| 112 | + ω::AbstractMask{T,N}, |
| 113 | + grid::StructuredGrid{N}, |
| 114 | + I::Vararg{Integer,N}) where {T,N} |
| 115 | + quote |
| 116 | + @inline |
| 117 | + Base.Cartesian.@ncall $N (+) D -> ∂k∂(F, K, ω, grid, Dim(D), I...) |
| 118 | + end |
| 119 | +end |
| 120 | + |
| 121 | +@propagate_inbounds function divg_grad(F::AbstractField, |
| 122 | + K::AbstractField, |
| 123 | + ω::AbstractMask{T,N}, |
| 124 | + grid::StructuredGrid{N}, |
| 125 | + I::CartesianIndex{N}) where {T,N} |
| 126 | + return divg_grad(F, K, ω, grid, Tuple(I)...) |
| 127 | +end |
0 commit comments