@@ -88,7 +88,7 @@ function generate_coordinate(FT, topo::AT, N, H, node_generator, coordinate_name
88
88
C = OffsetArray (on_architecture (arch, C. parent), C. offsets... )
89
89
90
90
if coordinate_name == :z
91
- return L, StaticVerticalCoordinate (F, C, Δᶠ, Δᶜ)
91
+ return L, StaticVerticalDiscretization (F, C, Δᶠ, Δᶜ)
92
92
else
93
93
return L, F, C, Δᶠ, Δᶜ
94
94
end
@@ -125,7 +125,7 @@ function generate_coordinate(FT, topo::AT, N, H, node_interval::Tuple{<:Number,
125
125
C = OffsetArray (C, - H)
126
126
127
127
if coordinate_name == :z
128
- return FT (L), StaticVerticalCoordinate (F, C, FT (Δᶠ), FT (Δᶜ))
128
+ return FT (L), StaticVerticalDiscretization (F, C, FT (Δᶠ), FT (Δᶜ))
129
129
else
130
130
return FT (L), F, C, FT (Δᶠ), FT (Δᶜ)
131
131
end
134
134
# Flat domains
135
135
function generate_coordinate (FT, :: Flat , N, H, c:: Number , coordinate_name, arch)
136
136
if coordinate_name == :z
137
- return FT (1 ), StaticVerticalCoordinate (range (FT (c), FT (c), length= N), range (FT (c), FT (c), length= N), FT (1 ), FT (1 ))
137
+ return FT (1 ), StaticVerticalDiscretization (range (FT (c), FT (c), length= N), range (FT (c), FT (c), length= N), FT (1 ), FT (1 ))
138
138
else
139
139
return FT (1 ), range (FT (c), FT (c), length= N), range (FT (c), FT (c), length= N), FT (1 ), FT (1 )
140
140
end
145
145
# FT(1), c, c, FT(1), FT(1)
146
146
function generate_coordinate (FT, :: Flat , N, H, :: Nothing , coordinate_name, arch)
147
147
if coordinate_name == :z
148
- return FT (1 ), StaticVerticalCoordinate (nothing , nothing , FT (1 ), FT (1 ))
148
+ return FT (1 ), StaticVerticalDiscretization (nothing , nothing , FT (1 ), FT (1 ))
149
149
else
150
150
return FT (1 ), nothing , nothing , FT (1 ), FT (1 )
151
151
end
152
152
end
153
+
154
+ # ####
155
+ # #### MutableVerticalDiscretization
156
+ # ####
157
+
158
+ generate_coordinate (FT, :: Periodic , N, H, :: MutableVerticalDiscretization , coordinate_name, arch, args... ) =
159
+ throw (ArgumentError (" Periodic domains are not supported for MutableVerticalDiscretization" ))
160
+
161
+ # Generate a vertical coordinate with a scaling (`σ`) with respect to a reference coordinate `r` with spacing `Δr`.
162
+ # The grid might move with time, so the coordinate includes the time-derivative of the scaling `∂t_σ`.
163
+ # The value of the vertical coordinate at `Nz+1` is saved in `ηⁿ`.
164
+ function generate_coordinate (FT, topo, size, halo, coordinate:: MutableVerticalDiscretization , coordinate_name, dim:: Int , arch)
165
+
166
+ Nx, Ny, Nz = size
167
+ Hx, Hy, Hz = halo
168
+
169
+ if dim != 3
170
+ msg = " MutableVerticalDiscretization is supported only in the third dimension (z)"
171
+ throw (ArgumentError (msg))
172
+ end
173
+
174
+ if coordinate_name != :z
175
+ msg = " MutableVerticalDiscretization is supported only for the z-coordinate"
176
+ throw (ArgumentError (msg))
177
+ end
178
+
179
+ r_faces = coordinate. cᵃᵃᶠ
180
+
181
+ Lr, rᵃᵃᶠ, rᵃᵃᶜ, Δrᵃᵃᶠ, Δrᵃᵃᶜ = generate_coordinate (FT, topo[3 ](), Nz, Hz, r_faces, :r , arch)
182
+
183
+ args = (topo, (Nx, Ny, Nz), (Hx, Hy, Hz))
184
+
185
+ σᶜᶜ⁻ = new_data (FT, arch, (Center, Center, Nothing), args... )
186
+ σᶜᶜⁿ = new_data (FT, arch, (Center, Center, Nothing), args... )
187
+ σᶠᶜⁿ = new_data (FT, arch, (Face, Center, Nothing), args... )
188
+ σᶜᶠⁿ = new_data (FT, arch, (Center, Face, Nothing), args... )
189
+ σᶠᶠⁿ = new_data (FT, arch, (Face, Face, Nothing), args... )
190
+ ηⁿ = new_data (FT, arch, (Center, Center, Nothing), args... )
191
+ ∂t_σ = new_data (FT, arch, (Center, Center, Nothing), args... )
192
+
193
+ # Fill all the scalings with one for now (i.e. z == r)
194
+ for σ in (σᶜᶜ⁻, σᶜᶜⁿ, σᶠᶜⁿ, σᶜᶠⁿ, σᶠᶠⁿ)
195
+ fill! (σ, 1 )
196
+ end
197
+
198
+ return Lr, MutableVerticalDiscretization (rᵃᵃᶠ, rᵃᵃᶜ, Δrᵃᵃᶠ, Δrᵃᵃᶜ, ηⁿ, σᶜᶜⁿ, σᶠᶜⁿ, σᶜᶠⁿ, σᶠᶠⁿ, σᶜᶜ⁻, ∂t_σ)
199
+ end
0 commit comments