Skip to content

Commit ac616b7

Browse files
bors[bot]simonbyrnecharleskawczynski
authored
Merge #1258
1258: reduce parameter size for finite difference operators r=charleskawczynski a=simonbyrne Fixes #1257 - [x] Code follows the [style guidelines](https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/) OR N/A. - [x] Unit tests are included OR N/A. - [x] Code is exercised in an integration test OR N/A. - [x] Documentation has been added/updated OR N/A. Co-authored-by: Simon Byrne <simonbyrne@gmail.com> Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
2 parents 982d61f + 0042f2c commit ac616b7

File tree

9 files changed

+744
-478
lines changed

9 files changed

+744
-478
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClimaCore"
22
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
33
authors = ["CliMA Contributors <clima-software@caltech.edu>"]
4-
version = "0.10.35"
4+
version = "0.10.36"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

bors.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
status = [
22
"test-os (ubuntu-20.04)",
33
"test-os (windows-latest)",
4-
"test-os (macos-latest)",
4+
# "test-os (macos-latest)",
55
"lib-climacore-vtk",
66
"lib-climacore-makie",
77
"lib-climacore-plots",

examples/column/hydrostatic_ekman.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function tendency!(dY, Y, _, t)
131131
# TODO!: Undesirable casting to vector required
132132
@. dρθ = -∂c(w * If(ρθ)) + ρ * ∂c* ∂f(ρθ / ρ))
133133

134-
uv_1 = Operators.getidx(uv, Operators.Interior(), 1)
134+
uv_1 = Operators.getidx(axes(uv), uv, Operators.Interior(), 1)
135135
u_wind = LinearAlgebra.norm(uv_1)
136136

137137
A = Operators.AdvectionC2C(

src/DataLayouts/DataLayouts.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ end
491491
@inline function Base.getindex(data::IFH{S}, i, _, _, _, h) where {S}
492492
@inbounds get_struct(parent(data), S, Val(2), CartesianIndex(i, 1, h))
493493
end
494+
@inline function Base.getindex(data::IFH{S}, I::CartesianIndex{5}) where {S}
495+
i, _, _, _, h = I.I
496+
@inbounds get_struct(parent(data), S, Val(2), CartesianIndex(i, 1, h))
497+
end
494498
@inline function Base.setindex!(data::IFH{S}, val, i, _, _, _, h) where {S}
495499
@inbounds set_struct!(
496500
parent(data),
@@ -499,6 +503,19 @@ end
499503
CartesianIndex(i, 1, h),
500504
)
501505
end
506+
@inline function Base.setindex!(
507+
data::IFH{S},
508+
val,
509+
I::CartesianIndex{5},
510+
) where {S}
511+
i, _, _, _, h = I.I
512+
@inbounds set_struct!(
513+
parent(data),
514+
convert(S, val),
515+
Val(3),
516+
CartesianIndex(i, 1, h),
517+
)
518+
end
502519

503520
# ======================
504521
# Data0D DataLayout
@@ -1291,6 +1308,19 @@ end
12911308
CartesianIndex(v, i, 1, h),
12921309
)
12931310
end
1311+
@inline function Base.setindex!(
1312+
data::VIFH{S},
1313+
val,
1314+
I::CartesianIndex{5},
1315+
) where {S}
1316+
i, _, _, v, h = I.I
1317+
@inbounds set_struct!(
1318+
parent(data),
1319+
convert(S, val),
1320+
Val(3),
1321+
CartesianIndex(v, i, 1, h),
1322+
)
1323+
end
12941324

12951325
# =========================================
12961326
# Special DataLayouts for regular gridding

src/Operators/common.jl

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,50 @@ end
6969

7070
# Functions for CUDASpectralStyle
7171
struct PlaceholderSpace <: Spaces.AbstractSpace end
72+
struct CenterPlaceholderSpace <: Spaces.AbstractSpace end
73+
struct FacePlaceholderSpace <: Spaces.AbstractSpace end
74+
7275

7376
placeholder_space(current_space::T, parent_space::T) where {T} =
7477
PlaceholderSpace()
7578
placeholder_space(current_space, parent_space) = current_space
76-
77-
reconstruct_placeholder_space(::PlaceholderSpace, parent_space) = parent_space
78-
reconstruct_placeholder_space(current_space, parent_space) = current_space
79+
placeholder_space(
80+
current_space::Spaces.CenterFiniteDifferenceSpace,
81+
parent_space::Spaces.FaceFiniteDifferenceSpace,
82+
) = CenterPlaceholderSpace()
83+
placeholder_space(
84+
current_space::Spaces.CenterExtrudedFiniteDifferenceSpace,
85+
parent_space::Spaces.FaceExtrudedFiniteDifferenceSpace,
86+
) = CenterPlaceholderSpace()
87+
placeholder_space(
88+
current_space::Spaces.FaceFiniteDifferenceSpace,
89+
parent_space::Spaces.CenterFiniteDifferenceSpace,
90+
) = FacePlaceholderSpace()
91+
placeholder_space(
92+
current_space::Spaces.FaceExtrudedFiniteDifferenceSpace,
93+
parent_space::Spaces.CenterExtrudedFiniteDifferenceSpace,
94+
) = FacePlaceholderSpace()
95+
96+
@inline reconstruct_placeholder_space(::PlaceholderSpace, parent_space) =
97+
parent_space
98+
@inline reconstruct_placeholder_space(
99+
::CenterPlaceholderSpace,
100+
parent_space::Spaces.FaceFiniteDifferenceSpace,
101+
) = Spaces.CenterFiniteDifferenceSpace(parent_space)
102+
@inline reconstruct_placeholder_space(
103+
::CenterPlaceholderSpace,
104+
parent_space::Spaces.FaceExtrudedFiniteDifferenceSpace,
105+
) = Spaces.CenterExtrudedFiniteDifferenceSpace(parent_space)
106+
@inline reconstruct_placeholder_space(
107+
::FacePlaceholderSpace,
108+
parent_space::Spaces.CenterFiniteDifferenceSpace,
109+
) = Spaces.FaceFiniteDifferenceSpace(parent_space)
110+
@inline reconstruct_placeholder_space(
111+
::FacePlaceholderSpace,
112+
parent_space::Spaces.CenterExtrudedFiniteDifferenceSpace,
113+
) = Spaces.FaceExtrudedFiniteDifferenceSpace(parent_space)
114+
@inline reconstruct_placeholder_space(current_space, parent_space) =
115+
current_space
79116

80117

81118
strip_space(obj, parent_space) = obj

0 commit comments

Comments
 (0)