From adff762bbfe7dad72e6a0eac4188b77fc054b9c8 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Tue, 3 Jun 2025 13:00:40 -0400 Subject: [PATCH 1/2] Do not reconstruct FD grid --- src/netcdf_writer_coordinates.jl | 53 +++++++++++++------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/src/netcdf_writer_coordinates.jl b/src/netcdf_writer_coordinates.jl index a072da4a..bf715458 100644 --- a/src/netcdf_writer_coordinates.jl +++ b/src/netcdf_writer_coordinates.jl @@ -503,7 +503,7 @@ function add_space_coordinates_maybe!( add_space_coordinates_maybe!(nc, horizontal_space, num_points_horiz) vertical_space = Spaces.FiniteDifferenceSpace( - Spaces.vertical_topology(space), + Spaces.grid(space).vertical_grid, Spaces.staggering(space), ) @@ -611,7 +611,7 @@ function target_coordinates( target_coordinates(Spaces.horizontal_space(space), num_points_horiz) vertical_space = Spaces.FiniteDifferenceSpace( - Spaces.vertical_topology(space), + Spaces.grid(space).vertical_grid, Spaces.staggering(space), ) vcoords = @@ -681,14 +681,12 @@ Return a tuple with number of points that are optimally suited to interpolate th "Optimally suited" here means approximately the same as the number of points as the given `space`. """ -function default_num_points( - space::ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace, -) - horizontal_space = ClimaCore.Spaces.horizontal_space(space) +function default_num_points(space::Spaces.ExtrudedFiniteDifferenceSpace) + horizontal_space = Spaces.horizontal_space(space) num_horz = default_num_points(horizontal_space) - vertical_space = ClimaCore.Spaces.FiniteDifferenceSpace( - Spaces.vertical_topology(space), + vertical_space = Spaces.FiniteDifferenceSpace( + Spaces.grid(space).vertical_grid, Spaces.staggering(space), ) num_vert = default_num_points(vertical_space) @@ -696,18 +694,16 @@ function default_num_points( end # 2D sphere -function default_num_points( - space::ClimaCore.Spaces.CubedSphereSpectralElementSpace2D, -) +function default_num_points(space::Spaces.CubedSphereSpectralElementSpace2D) # A cubed sphere has 4 panels to cover the range of longitudes, each panel has # `num_elements_per_panel` elements, each with `unique_degrees_of_freedom` points. Same # for latitudes, except that we need 2 panels to cover from 0 to 180. unique_degrees_of_freedom = ClimaCore.Quadratures.unique_degrees_of_freedom( - ClimaCore.Grids.quadrature_style(space), + Grids.quadrature_style(space), ) num_elements_per_panel = ClimaCore.Meshes.n_elements_per_panel_direction( - ClimaCore.Spaces.topology(space).mesh, + Spaces.topology(space).mesh, ) num_lat = 2 * num_elements_per_panel * unique_degrees_of_freedom num_lon = 2num_lat @@ -715,39 +711,32 @@ function default_num_points( end # TODO: Maybe move to ClimaCore? -const RectilinearSpectralElementSpace1D = - ClimaCore.Spaces.SpectralElementSpace1D{ - <:ClimaCore.Grids.SpectralElementGrid1D{ - <:ClimaCore.Topologies.IntervalTopology, - }, - } +const RectilinearSpectralElementSpace1D = Spaces.SpectralElementSpace1D{ + <:Grids.SpectralElementGrid1D{<:ClimaCore.Topologies.IntervalTopology}, +} # 1D box function default_num_points(space::RectilinearSpectralElementSpace1D) unique_degrees_of_freedom = ClimaCore.Quadratures.unique_degrees_of_freedom( - ClimaCore.Grids.quadrature_style(space), + Grids.quadrature_style(space), ) return ( unique_degrees_of_freedom * - ClimaCore.Meshes.nelements(ClimaCore.Spaces.topology(space).mesh), + ClimaCore.Meshes.nelements(Spaces.topology(space).mesh), ) end # 2D box -function default_num_points( - space::ClimaCore.Spaces.RectilinearSpectralElementSpace2D, -) +function default_num_points(space::Spaces.RectilinearSpectralElementSpace2D) unique_degrees_of_freedom = ClimaCore.Quadratures.unique_degrees_of_freedom( - ClimaCore.Grids.quadrature_style(space), + Grids.quadrature_style(space), ) return ( - unique_degrees_of_freedom * ClimaCore.Meshes.nelements( - ClimaCore.Spaces.topology(space).mesh.intervalmesh1, - ), - unique_degrees_of_freedom * ClimaCore.Meshes.nelements( - ClimaCore.Spaces.topology(space).mesh.intervalmesh2, - ), + unique_degrees_of_freedom * + ClimaCore.Meshes.nelements(Spaces.topology(space).mesh.intervalmesh1), + unique_degrees_of_freedom * + ClimaCore.Meshes.nelements(Spaces.topology(space).mesh.intervalmesh2), ) end @@ -755,5 +744,5 @@ end function default_num_points(space::Spaces.FiniteDifferenceSpace) # We always want the center space for interpolation cspace = Spaces.center_space(space) - return (ClimaCore.Spaces.nlevels(cspace),) + return (Spaces.nlevels(cspace),) end From 8a2c024d60d5a9fb54ba71f60e0e8723f954506f Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Tue, 3 Jun 2025 14:35:11 -0400 Subject: [PATCH 2/2] Bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e4154ff0..3a28dc21 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ClimaDiagnostics" uuid = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f" authors = ["Gabriele Bozzola "] -version = "0.2.14" +version = "0.2.15" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"