Skip to content

Commit 9839ac7

Browse files
Mv ncolumns to Spaces, define nlevels on fields (#2199)
* Mv ncolumns to Spaces, define nlevels on fields * Update src/Spaces/Spaces.jl Co-authored-by: Gabriele Bozzola <[email protected]> --------- Co-authored-by: Gabriele Bozzola <[email protected]>
1 parent f535f25 commit 9839ac7

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

src/Fields/Fields.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ..Topologies
2121
import ..Quadratures
2222
import ..Grids: ColumnIndex, local_geometry_type
2323
import ..Spaces: Spaces, AbstractSpace, AbstractPointSpace, cuda_synchronize
24+
import ..Spaces: nlevels, ncolumns
2425
import ..Geometry: Geometry, Cartesian12Vector
2526
import ..Utilities: PlusHalf, half, UnrolledFunctions
2627

src/Fields/indices.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,17 @@ bycolumn(
107107

108108
"""
109109
ncolumns(::Field)
110-
ncolumns(::Space)
111110
112-
Number of columns in a given space.
111+
Number of columns in the field's space.
113112
"""
114113
ncolumns(field::Field) = ncolumns(axes(field))
115114

116-
ncolumns(space::Spaces.ExtrudedFiniteDifferenceSpace) =
117-
ncolumns(Spaces.horizontal_space(space))
115+
"""
116+
nlevels(::Field)
118117
119-
function ncolumns(space::Spaces.SpectralElementSpace1D)
120-
Nh = Topologies.nlocalelems(space)
121-
Nq = Quadratures.degrees_of_freedom(Spaces.quadrature_style(space))
122-
return Nh * Nq
123-
end
124-
function ncolumns(space::Spaces.SpectralElementSpace2D)
125-
Nh = Topologies.nlocalelems(space)
126-
Nq = Quadratures.degrees_of_freedom(Spaces.quadrature_style(space))
127-
return Nh * Nq * Nq
128-
end
118+
Number of levels in the field's space.
119+
"""
120+
nlevels(field::Field) = nlevels(axes(field))
129121

130122
# potential TODO:
131123
# - define a ColumnIndices type, make it work with https://github.com/JuliaFolds/FLoops.jl

src/Spaces/Spaces.jl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ ClimaComms.array_type(space::AbstractSpace) =
141141
142142
The domain maximum along the z-direction.
143143
"""
144-
function z_max(space::Spaces.AbstractSpace)
145-
mesh = Topologies.mesh(Spaces.vertical_topology(space))
144+
function z_max(space::AbstractSpace)
145+
mesh = Topologies.mesh(vertical_topology(space))
146146
domain = Topologies.domain(mesh)
147147
return Domains.z_max(domain)
148148
end
@@ -152,10 +152,30 @@ end
152152
153153
The domain minimum along the z-direction.
154154
"""
155-
function z_min(space::Spaces.AbstractSpace)
156-
mesh = Topologies.mesh(Spaces.vertical_topology(space))
155+
function z_min(space::AbstractSpace)
156+
mesh = Topologies.mesh(vertical_topology(space))
157157
domain = Topologies.domain(mesh)
158158
return Domains.z_min(domain)
159159
end
160160

161+
"""
162+
ncolumns(space::AbstractSpace)
163+
164+
Number of columns in a given `space` on the local processor.
165+
"""
166+
ncolumns(space::ExtrudedFiniteDifferenceSpace) =
167+
ncolumns(horizontal_space(space))
168+
169+
function ncolumns(space::SpectralElementSpace1D)
170+
Nh = Topologies.nlocalelems(space)
171+
Nq = Quadratures.degrees_of_freedom(quadrature_style(space))
172+
return Nh * Nq
173+
end
174+
function ncolumns(space::SpectralElementSpace2D)
175+
Nh = Topologies.nlocalelems(space)
176+
Nq = Quadratures.degrees_of_freedom(quadrature_style(space))
177+
return Nh * Nq * Nq
178+
end
179+
180+
161181
end # module

0 commit comments

Comments
 (0)