Skip to content

Commit adff762

Browse files
Do not reconstruct FD grid
1 parent ca17dd2 commit adff762

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

src/netcdf_writer_coordinates.jl

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ function add_space_coordinates_maybe!(
503503
add_space_coordinates_maybe!(nc, horizontal_space, num_points_horiz)
504504

505505
vertical_space = Spaces.FiniteDifferenceSpace(
506-
Spaces.vertical_topology(space),
506+
Spaces.grid(space).vertical_grid,
507507
Spaces.staggering(space),
508508
)
509509

@@ -611,7 +611,7 @@ function target_coordinates(
611611
target_coordinates(Spaces.horizontal_space(space), num_points_horiz)
612612

613613
vertical_space = Spaces.FiniteDifferenceSpace(
614-
Spaces.vertical_topology(space),
614+
Spaces.grid(space).vertical_grid,
615615
Spaces.staggering(space),
616616
)
617617
vcoords =
@@ -681,79 +681,68 @@ Return a tuple with number of points that are optimally suited to interpolate th
681681
"Optimally suited" here means approximately the same as the number of points as the given
682682
`space`.
683683
"""
684-
function default_num_points(
685-
space::ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace,
686-
)
687-
horizontal_space = ClimaCore.Spaces.horizontal_space(space)
684+
function default_num_points(space::Spaces.ExtrudedFiniteDifferenceSpace)
685+
horizontal_space = Spaces.horizontal_space(space)
688686
num_horz = default_num_points(horizontal_space)
689687

690-
vertical_space = ClimaCore.Spaces.FiniteDifferenceSpace(
691-
Spaces.vertical_topology(space),
688+
vertical_space = Spaces.FiniteDifferenceSpace(
689+
Spaces.grid(space).vertical_grid,
692690
Spaces.staggering(space),
693691
)
694692
num_vert = default_num_points(vertical_space)
695693
return (num_horz..., num_vert...)
696694
end
697695

698696
# 2D sphere
699-
function default_num_points(
700-
space::ClimaCore.Spaces.CubedSphereSpectralElementSpace2D,
701-
)
697+
function default_num_points(space::Spaces.CubedSphereSpectralElementSpace2D)
702698
# A cubed sphere has 4 panels to cover the range of longitudes, each panel has
703699
# `num_elements_per_panel` elements, each with `unique_degrees_of_freedom` points. Same
704700
# for latitudes, except that we need 2 panels to cover from 0 to 180.
705701

706702
unique_degrees_of_freedom = ClimaCore.Quadratures.unique_degrees_of_freedom(
707-
ClimaCore.Grids.quadrature_style(space),
703+
Grids.quadrature_style(space),
708704
)
709705
num_elements_per_panel = ClimaCore.Meshes.n_elements_per_panel_direction(
710-
ClimaCore.Spaces.topology(space).mesh,
706+
Spaces.topology(space).mesh,
711707
)
712708
num_lat = 2 * num_elements_per_panel * unique_degrees_of_freedom
713709
num_lon = 2num_lat
714710
return (num_lon, num_lat)
715711
end
716712

717713
# TODO: Maybe move to ClimaCore?
718-
const RectilinearSpectralElementSpace1D =
719-
ClimaCore.Spaces.SpectralElementSpace1D{
720-
<:ClimaCore.Grids.SpectralElementGrid1D{
721-
<:ClimaCore.Topologies.IntervalTopology,
722-
},
723-
}
714+
const RectilinearSpectralElementSpace1D = Spaces.SpectralElementSpace1D{
715+
<:Grids.SpectralElementGrid1D{<:ClimaCore.Topologies.IntervalTopology},
716+
}
724717

725718
# 1D box
726719
function default_num_points(space::RectilinearSpectralElementSpace1D)
727720
unique_degrees_of_freedom = ClimaCore.Quadratures.unique_degrees_of_freedom(
728-
ClimaCore.Grids.quadrature_style(space),
721+
Grids.quadrature_style(space),
729722
)
730723
return (
731724
unique_degrees_of_freedom *
732-
ClimaCore.Meshes.nelements(ClimaCore.Spaces.topology(space).mesh),
725+
ClimaCore.Meshes.nelements(Spaces.topology(space).mesh),
733726
)
734727
end
735728

736729
# 2D box
737-
function default_num_points(
738-
space::ClimaCore.Spaces.RectilinearSpectralElementSpace2D,
739-
)
730+
function default_num_points(space::Spaces.RectilinearSpectralElementSpace2D)
740731
unique_degrees_of_freedom = ClimaCore.Quadratures.unique_degrees_of_freedom(
741-
ClimaCore.Grids.quadrature_style(space),
732+
Grids.quadrature_style(space),
742733
)
743734

744735
return (
745-
unique_degrees_of_freedom * ClimaCore.Meshes.nelements(
746-
ClimaCore.Spaces.topology(space).mesh.intervalmesh1,
747-
),
748-
unique_degrees_of_freedom * ClimaCore.Meshes.nelements(
749-
ClimaCore.Spaces.topology(space).mesh.intervalmesh2,
750-
),
736+
unique_degrees_of_freedom *
737+
ClimaCore.Meshes.nelements(Spaces.topology(space).mesh.intervalmesh1),
738+
unique_degrees_of_freedom *
739+
ClimaCore.Meshes.nelements(Spaces.topology(space).mesh.intervalmesh2),
751740
)
752741
end
753742

754743
# Column
755744
function default_num_points(space::Spaces.FiniteDifferenceSpace)
756745
# We always want the center space for interpolation
757746
cspace = Spaces.center_space(space)
758-
return (ClimaCore.Spaces.nlevels(cspace),)
747+
return (Spaces.nlevels(cspace),)
759748
end

0 commit comments

Comments
 (0)