Skip to content

Commit a0a223e

Browse files
Merge pull request #2127 from CliMA/ck/climacoreplots
Fix plotting for columns from extruded FD fields
2 parents 58b293a + 30e287e commit a0a223e

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

lib/ClimaCorePlots/src/ClimaCorePlots.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ RecipesBase.@recipe function f(field::Fields.FiniteDifferenceField)
137137
coord_field = Fields.coordinate_field(space)
138138

139139
xdata = parent(field)[:, 1]
140-
ydata = parent(Spaces.coordinates_data(space))[:, 1]
140+
ydata = parent(Spaces.coordinates_data(space).z)[:, 1]
141141

142142
coord_symbols = propertynames(coord_field)
143143

lib/ClimaCorePlots/test/runtests.jl

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,72 @@ end
9393
@test isfile(fig_png)
9494
end
9595

96+
@testset "finitedifference" begin
97+
vdomain = ClimaCore.Domains.IntervalDomain(
98+
ClimaCore.Geometry.ZPoint(0.0),
99+
ClimaCore.Geometry.ZPoint(10e3);
100+
boundary_names = (:bottom, :top),
101+
)
102+
context = ClimaComms.context()
103+
vmesh = ClimaCore.Meshes.IntervalMesh(vdomain; nelems = 45)
104+
vtopology = ClimaCore.Topologies.IntervalTopology(context, vmesh)
105+
vspace = ClimaCore.Spaces.CenterFiniteDifferenceSpace(vtopology)
106+
coords = ClimaCore.Fields.coordinate_field(vspace)
107+
108+
u = sin.(π .* coords.z)
109+
110+
field_fig = Plots.plot(u)
111+
@test field_fig !== nothing
112+
113+
fig_png = joinpath(OUTPUT_DIR, "fd_field.png")
114+
Plots.png(field_fig, fig_png)
115+
@test isfile(fig_png)
116+
end
117+
118+
@testset "Column from extruded finitedifference" begin
119+
FT = Float64
120+
R = 6.37122e6
121+
velem = 40
122+
123+
horz_domain = ClimaCore.Domains.SphereDomain(R)
124+
horz_mesh = ClimaCore.Meshes.EquiangularCubedSphere(horz_domain, 6)
125+
horz_grid_topology = ClimaCore.Topologies.Topology2D(
126+
ClimaComms.SingletonCommsContext(),
127+
horz_mesh,
128+
)
129+
quad = ClimaCore.Quadratures.GLL{4}()
130+
horz_space =
131+
ClimaCore.Spaces.SpectralElementSpace2D(horz_grid_topology, quad)
132+
133+
vertdomain = ClimaCore.Domains.IntervalDomain(
134+
ClimaCore.Geometry.ZPoint{FT}(0),
135+
ClimaCore.Geometry.ZPoint{FT}(1000);
136+
boundary_names = (:bottom, :top),
137+
)
138+
vertmesh = ClimaCore.Meshes.IntervalMesh(vertdomain, nelems = velem)
139+
device = ClimaComms.device()
140+
vert_center_space =
141+
ClimaCore.Spaces.CenterFiniteDifferenceSpace(device, vertmesh)
142+
143+
hv_center_space = ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace(
144+
horz_space,
145+
vert_center_space,
146+
)
147+
coords = ClimaCore.Fields.coordinate_field(hv_center_space)
148+
149+
uw = map(coords) do coord
150+
sin(coord.z)
151+
end
152+
153+
colidx = ClimaCore.Fields.ColumnIndex((1, 1), 1)
154+
field_fig = Plots.plot(uw[colidx])
155+
@test field_fig !== nothing
156+
157+
fig_png = joinpath(OUTPUT_DIR, "col_from_extruded_fd_field.png")
158+
Plots.png(field_fig, fig_png)
159+
@test isfile(fig_png)
160+
end
161+
96162
@testset "spectral element 3D extruded cubed-sphere" begin
97163
FT = Float64
98164
R = 6.37122e6
@@ -104,7 +170,7 @@ end
104170
ClimaComms.SingletonCommsContext(),
105171
horz_mesh,
106172
)
107-
quad = ClimaCore.Quadratures.GLL{5}()
173+
quad = ClimaCore.Quadratures.GLL{4}()
108174
horz_space =
109175
ClimaCore.Spaces.SpectralElementSpace2D(horz_grid_topology, quad)
110176

0 commit comments

Comments
 (0)