@@ -661,3 +661,90 @@ Prepare the matrix of horizontal coordinates with the correct type according to
661661and `domain` (e.g., `ClimaCore.Geometry.LatLongPoint`s).
662662"""
663663function hcoords_from_horizontal_space (space, domain, hpts) end
664+
665+
666+ """
667+ default_num_points(space)
668+
669+ Return a tuple with number of points that are optimally suited to interpolate the given
670+ `space`.
671+
672+ "Optimally suited" here means approximately the same as the number of points as the given
673+ `space`.
674+ """
675+ function default_num_points (
676+ space:: ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace ,
677+ )
678+ horizontal_space = ClimaCore. Spaces. horizontal_space (space)
679+ num_horz = default_num_points (horizontal_space)
680+
681+ vertical_space = ClimaCore. Spaces. FiniteDifferenceSpace (
682+ Spaces. vertical_topology (space),
683+ Spaces. staggering (space),
684+ )
685+ num_vert = default_num_points (vertical_space)
686+ return (num_horz... , num_vert... )
687+ end
688+
689+ # 2D sphere
690+ function default_num_points (
691+ space:: ClimaCore.Spaces.CubedSphereSpectralElementSpace2D ,
692+ )
693+ # A cubed sphere has 4 panels to cover the range of longitudes, each panel has
694+ # `num_elements_per_panel` elements, each with `unique_degrees_of_freedom` points. Same
695+ # for latitudes, except that we need 2 panels to cover from 0 to 180.
696+
697+ unique_degrees_of_freedom = ClimaCore. Quadratures. unique_degrees_of_freedom (
698+ ClimaCore. Grids. quadrature_style (space),
699+ )
700+ num_elements_per_panel = ClimaCore. Meshes. n_elements_per_panel_direction (
701+ ClimaCore. Spaces. topology (space). mesh,
702+ )
703+ num_lat = 2 * num_elements_per_panel * unique_degrees_of_freedom
704+ num_lon = 2 num_lat
705+ return (num_lon, num_lat)
706+ end
707+
708+ # TODO : Maybe move to ClimaCore?
709+ const RectilinearSpectralElementSpace1D =
710+ ClimaCore. Spaces. SpectralElementSpace1D{
711+ <: ClimaCore.Grids.SpectralElementGrid1D {
712+ <: ClimaCore.Topologies.IntervalTopology ,
713+ },
714+ }
715+
716+ # 1D box
717+ function default_num_points (space:: RectilinearSpectralElementSpace1D )
718+ unique_degrees_of_freedom = ClimaCore. Quadratures. unique_degrees_of_freedom (
719+ ClimaCore. Grids. quadrature_style (space),
720+ )
721+ return (
722+ unique_degrees_of_freedom *
723+ ClimaCore. Meshes. nelements (ClimaCore. Spaces. topology (space). mesh),
724+ )
725+ end
726+
727+ # 2D box
728+ function default_num_points (
729+ space:: ClimaCore.Spaces.RectilinearSpectralElementSpace2D ,
730+ )
731+ unique_degrees_of_freedom = ClimaCore. Quadratures. unique_degrees_of_freedom (
732+ ClimaCore. Grids. quadrature_style (space),
733+ )
734+
735+ return (
736+ unique_degrees_of_freedom * ClimaCore. Meshes. nelements (
737+ ClimaCore. Spaces. topology (space). mesh. intervalmesh1,
738+ ),
739+ unique_degrees_of_freedom * ClimaCore. Meshes. nelements (
740+ ClimaCore. Spaces. topology (space). mesh. intervalmesh2,
741+ ),
742+ )
743+ end
744+
745+ # Column
746+ function default_num_points (space:: Spaces.FiniteDifferenceSpace )
747+ # We always want the center space for interpolation
748+ cspace = Spaces. center_space (space)
749+ return (ClimaCore. Spaces. nlevels (cspace),)
750+ end
0 commit comments