• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Atmospheric-Dynamics-GUF / PinCFlow.jl / 18600325485

17 Oct 2025 05:35PM UTC coverage: 64.858% (-1.1%) from 65.961%
18600325485

Pull #117

github

web-flow
Merge 6a432eb7e into 2192c9fbf
Pull Request #117: Removed density reconstructions and fluxes in Boussinesq mode and restructured the BC functions.

60 of 152 new or added lines in 13 files covered. (39.47%)

41 existing lines in 6 files now uncovered.

4889 of 7538 relevant lines covered (64.86%)

1417695.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.7
/src/Boundaries/set_vertical_boundaries!.jl
1
"""
2
```julia
3
set_vertical_boundaries!(
4
    state::State,
5
    variables::Union{
6
        BoundaryPredictands,
7
        BoundaryReconstructions,
8
        BoundaryFluxes,
9
    },
10
)
11
```
12

13
Enforce vertical boundary conditions for predictands, reconstructions or fluxes, by dispatching to the appropriate method.
14

15
```julia
16
set_vertical_boundaries!(
17
    state::State,
18
    variables::BoundaryPredictands,
19
    model::Boussinesq,
20
)
21
```
22

23
Enforce vertical boundary conditions for predictands in Boussinesq mode.
24

25
The symmetry conditions are as follows:
26

27
  - Density fluctuations (`rhop`): point reflection (`-`)
28

29
  - Vertical velocity (`w`): point reflection (`-`) on the staggered grid
30

31
  - Horizontal velocities (`u`, `v`): line reflection (`+`)
32

33
  - Exner-pressure fluctuations (`pip`): line reflection (`+`)
34

35
```julia
36
set_vertical_boundaries!(
37
    state::State,
38
    variables::BoundaryPredictands,
39
    model::PseudoIncompressible,
40
)
41
```
42

43
Enforce vertical boundary conditions for predictands in pseudo-incompressible mode.
44

45
In contrast to Boussinesq mode, this includes the density (`rho`). Since it is offset by the background, it is point-reflected, like the density fluctuations.
46

47
```julia
48
set_vertical_boundaries!(
49
    state::State,
50
    variables::BoundaryPredictands,
51
    model::Compressible,
52
)
53
```
54

55
Enforce vertical boundary conditions for predictands in compressible mode.
56

57
In contrast to pseudo-incompressible modes, this includes the mass-weighted potential temperature (`p`), which is line-reflected.
58

59
```julia
60
set_vertical_boundaries!(
61
    state::State,
62
    variables::BoundaryReconstructions,
63
    model::Boussinesq,
64
)
65
```
66

67
Enforce vertical boundary conditions for reconstructions in Boussinesq mode.
68

69
```julia
70
set_vertical_boundaries!(
71
    state::State,
72
    variables::BoundaryReconstructions,
73
    model::Union{PseudoIncompressible, Compressible},
74
)
75
```
76

77
Enforce vertical boundary conditions for reconstructions in non-Boussinesq modes.
78

79
```julia
80
set_vertical_boundaries!(
81
    state::State,
82
    variables::BoundaryFluxes,
83
    model::Boussinesq,
84
)
85
```
86

87
Enforce vertical boundary conditions for vertical fluxes in Boussinesq mode.
88

89
```julia
90
set_vertical_boundaries!(
91
    state::State,
92
    variables::BoundaryFluxes,
93
    model::PseudoIncompressible,
94
)
95
```
96

97
Enforce vertical boundary conditions for vertical fluxes in pseudo-incompressible mode.
98

99
```julia
100
set_vertical_boundaries!(
101
    state::State,
102
    variables::BoundaryFluxes,
103
    model::Compressible,
104
)
105
```
106

107
Enforce vertical boundary conditions for vertical fluxes in compressible mode.
108

109
```julia
110
set_vertical_boundaries!(state::State, variables::AbstractWKBBoundaryVariables)
111
```
112

113
Enforce vertical boundary conditions for WKB variables by dispatching to the appropriate method.
114

115
```julia
116
set_vertical_boundaries!(
117
    state::State,
118
    variables::BoundaryWKBIntegrals,
119
    wkb_mode::Union{SteadyState, SingleColumn},
120
)
121
```
122

123
Enforce vertical boundary conditions for WKB integrals needed in `SingleColumn` and `SteadyState` configurations, using line reflection.
124

125
```julia
126
set_vertical_boundaries!(
127
    state::State,
128
    variables::BoundaryWKBIntegrals,
129
    wkb_mode::MultiColumn,
130
)
131
```
132

133
Enforce vertical boundary conditions for WKB integrals needed in `MultiColumn` configurations, using line reflection.
134

135
```julia
136
set_vertical_boundaries!(
137
    state::State,
138
    variables::BoundaryWKBTendencies,
139
    wkb_mode::Union{SteadyState, SingleColumn},
140
)
141
```
142

143
Enforce vertical boundary conditions for WKB tendencies needed in `SingleColumn` and `SteadyState` configurations, using line reflection.
144

145
```julia
146
set_vertical_boundaries!(
147
    state::State,
148
    variables::BoundaryWKBTendencies,
149
    wkb_mode::MultiColumn,
150
)
151
```
152

153
Enforce vertical boundary conditions for WKB tendencies needed in `MultiColumn` configurations, using line reflection.
154

155
# Arguments
156

157
  - `state`: Model state.
158

159
  - `variables`: Boundary-variable category.
160

161
  - `wkb_mode`: Approximations used by MSGWaM.
162

163
# See also
164

165
  - [`PinCFlow.Boundaries.set_vertical_boundaries_of_field!`](@ref)
166
"""
167
function set_vertical_boundaries! end
168

169
function set_vertical_boundaries!(
6,102✔
170
    state::State,
171
    variables::Union{
172
        BoundaryPredictands,
173
        BoundaryReconstructions,
174
        BoundaryFluxes,
175
    },
176
)
177
    (; model) = state.namelists.atmosphere
6,102✔
178
    set_vertical_boundaries!(state, variables, model)
6,102✔
179
    return
6,102✔
180
end
181

NEW
182
function set_vertical_boundaries!(
×
183
    state::State,
184
    variables::BoundaryPredictands,
185
    model::Boussinesq,
186
)
NEW
187
    (; namelists, domain) = state
×
NEW
188
    (; rhop, u, v, w, pip) = state.variables.predictands
×
189

NEW
190
    set_vertical_boundaries_of_field!(rhop, namelists, domain, -)
×
NEW
191
    set_vertical_boundaries_of_field!(u, namelists, domain, +)
×
NEW
192
    set_vertical_boundaries_of_field!(v, namelists, domain, +)
×
NEW
193
    set_vertical_boundaries_of_field!(w, namelists, domain, -; staggered = true)
×
NEW
194
    set_vertical_boundaries_of_field!(pip, namelists, domain, +)
×
195

NEW
196
    return
×
197
end
198

199
function set_vertical_boundaries!(
4,014✔
200
    state::State,
201
    variables::BoundaryPredictands,
202
    model::PseudoIncompressible,
203
)
204
    (; namelists, domain) = state
4,014✔
205
    (; rho, rhop, u, v, w, pip) = state.variables.predictands
4,014✔
206

207
    set_vertical_boundaries_of_field!(rho, namelists, domain, -)
4,014✔
208
    set_vertical_boundaries_of_field!(rhop, namelists, domain, -)
4,014✔
209
    set_vertical_boundaries_of_field!(u, namelists, domain, +)
4,014✔
210
    set_vertical_boundaries_of_field!(v, namelists, domain, +)
4,014✔
211
    set_vertical_boundaries_of_field!(w, namelists, domain, -; staggered = true)
4,014✔
212
    set_vertical_boundaries_of_field!(pip, namelists, domain, +)
4,014✔
213

214
    return
4,014✔
215
end
216

NEW
217
function set_vertical_boundaries!(
×
218
    state::State,
219
    variables::BoundaryPredictands,
220
    model::Compressible,
221
)
NEW
222
    (; namelists, domain) = state
×
NEW
223
    (; rho, rhop, u, v, w, pip, p) = state.variables.predictands
×
224

NEW
225
    set_vertical_boundaries_of_field!(rho, namelists, domain, -)
×
NEW
226
    set_vertical_boundaries_of_field!(rhop, namelists, domain, -)
×
UNCOV
227
    set_vertical_boundaries_of_field!(u, namelists, domain, +)
×
UNCOV
228
    set_vertical_boundaries_of_field!(v, namelists, domain, +)
×
NEW
229
    set_vertical_boundaries_of_field!(w, namelists, domain, -; staggered = true)
×
UNCOV
230
    set_vertical_boundaries_of_field!(pip, namelists, domain, +)
×
NEW
231
    set_vertical_boundaries_of_field!(p, namelists, domain, +)
×
232

NEW
233
    return
×
234
end
235

NEW
236
function set_vertical_boundaries!(
×
237
    state::State,
238
    variables::BoundaryReconstructions,
239
    model::Boussinesq,
240
)
NEW
241
    (; namelists, domain) = state
×
NEW
242
    (; reconstructions) = state.variables
×
243

NEW
244
    for field in (:rhoptilde, :utilde, :vtilde, :wtilde)
×
NEW
245
        set_vertical_boundaries_of_field!(
×
246
            getfield(reconstructions, field),
247
            namelists,
248
            domain,
249
        )
NEW
250
    end
×
251

UNCOV
252
    return
×
253
end
254

255
function set_vertical_boundaries!(
1,044✔
256
    state::State,
257
    variables::BoundaryReconstructions,
258
    model::Union{PseudoIncompressible, Compressible},
259
)
260
    (; namelists, domain) = state
1,044✔
261
    (; reconstructions) = state.variables
1,044✔
262

263
    for field in fieldnames(Reconstructions)
1,044✔
264
        set_vertical_boundaries_of_field!(
5,220✔
265
            getfield(reconstructions, field),
266
            namelists,
267
            domain,
268
        )
269
    end
5,220✔
270

271
    return
1,044✔
272
end
273

NEW
274
function set_vertical_boundaries!(
×
275
    state::State,
276
    variables::BoundaryFluxes,
277
    model::Boussinesq,
278
)
UNCOV
279
    (; zz_size, nzz, ko, k0, k1) = state.domain
×
UNCOV
280
    (; fluxes) = state.variables
×
281

NEW
282
    @ivy if ko == 0
×
NEW
283
        for field in (:phirhop, :phiu, :phiv, :phitheta)
×
NEW
284
            getfield(fluxes, field)[:, :, k0 - 1, 3] .= 0.0
×
NEW
285
        end
×
NEW
286
        fluxes.phiw[:, :, k0 - 2, 3] .= 0.0
×
287
    end
288

NEW
289
    @ivy if ko + nzz == zz_size
×
NEW
290
        for field in (:phirhop, :phiu, :phiv, :phiw, :phitheta)
×
NEW
291
            getfield(fluxes, field)[:, :, k1, 3] .= 0.0
×
NEW
292
        end
×
293
    end
294

NEW
295
    return
×
296
end
297

298
function set_vertical_boundaries!(
1,044✔
299
    state::State,
300
    variables::BoundaryFluxes,
301
    model::PseudoIncompressible,
302
)
303
    (; zz_size, nzz, ko, k0, k1) = state.domain
1,044✔
304
    (; fluxes) = state.variables
1,044✔
305

306
    @ivy if ko == 0
203,328✔
307
        for field in (:phirho, :phirhop, :phiu, :phiv, :phitheta)
1,044✔
308
            getfield(fluxes, field)[:, :, k0 - 1, 3] .= 0.0
1,016,640✔
309
        end
6,264✔
310
        fluxes.phiw[:, :, k0 - 2, 3] .= 0.0
203,328✔
311
    end
312

313
    @ivy if ko + nzz == zz_size
2,088✔
314
        for field in (:phirho, :phirhop, :phiu, :phiv, :phiw, :phitheta)
1,044✔
315
            getfield(fluxes, field)[:, :, k1, 3] .= 0.0
1,219,968✔
316
        end
7,308✔
317
    end
318

319
    return
1,044✔
320
end
321

NEW
322
function set_vertical_boundaries!(
×
323
    state::State,
324
    variables::BoundaryFluxes,
325
    model::Compressible,
326
)
NEW
327
    (; zz_size, nzz, ko, k0, k1) = state.domain
×
NEW
328
    (; fluxes) = state.variables
×
329

NEW
330
    @ivy if ko == 0
×
NEW
331
        for field in (:phirho, :phirhop, :phiu, :phiv, :phitheta, :phip)
×
NEW
332
            getfield(fluxes, field)[:, :, k0 - 1, 3] .= 0.0
×
NEW
333
        end
×
NEW
334
        fluxes.phiw[:, :, k0 - 2, 3] .= 0.0
×
335
    end
336

NEW
337
    @ivy if ko + nzz == zz_size
×
NEW
338
        for field in fieldnames(Fluxes)
×
NEW
339
            getfield(fluxes, field)[:, :, k1, 3] .= 0.0
×
NEW
340
        end
×
341
    end
342

UNCOV
343
    return
×
344
end
345

346
function set_vertical_boundaries!(
78✔
347
    state::State,
348
    variables::AbstractWKBBoundaryVariables,
349
)
350
    (; wkb_mode) = state.namelists.wkb
78✔
351
    set_vertical_boundaries!(state, variables, wkb_mode)
156✔
352
    return
78✔
353
end
354

355
function set_vertical_boundaries!(
×
356
    state::State,
357
    variables::BoundaryWKBIntegrals,
358
    wkb_mode::Union{SteadyState, SingleColumn},
359
)
360
    (; namelists, domain) = state
×
361
    (; integrals) = state.wkb
×
362

363
    for field in (:uw, :vw, :e)
×
364
        set_vertical_boundaries_of_field!(
×
365
            getfield(integrals, field),
366
            namelists,
367
            domain,
368
            +;
369
            layers = (1, 1, 1),
370
        )
371
    end
×
372

373
    return
×
374
end
375

376
function set_vertical_boundaries!(
26✔
377
    state::State,
378
    variables::BoundaryWKBIntegrals,
379
    wkb_mode::MultiColumn,
380
)
381
    (; namelists, domain) = state
26✔
382
    (; integrals) = state.wkb
26✔
383

384
    for field in (:uu, :uv, :uw, :vv, :vw, :utheta, :vtheta, :e)
26✔
385
        set_vertical_boundaries_of_field!(
208✔
386
            getfield(integrals, field),
387
            namelists,
388
            domain,
389
            +;
390
            layers = (1, 1, 1),
391
        )
392
    end
234✔
393

394
    return
26✔
395
end
396

UNCOV
397
function set_vertical_boundaries!(
×
398
    state::State,
399
    variables::BoundaryWKBTendencies,
400
    wkb_mode::Union{SteadyState, SingleColumn},
401
)
402
    (; namelists, domain) = state
×
403
    (; tendencies) = state.wkb
×
404

405
    for field in (:dudt, :dvdt)
×
406
        set_vertical_boundaries_of_field!(
×
407
            getfield(tendencies, field),
408
            namelists,
409
            domain,
410
            +,
411
        )
412
    end
×
413

414
    return
×
415
end
416

417
function set_vertical_boundaries!(
52✔
418
    state::State,
419
    variables::BoundaryWKBTendencies,
420
    wkb_mode::MultiColumn,
421
)
422
    (; namelists, domain) = state
52✔
423
    (; tendencies) = state.wkb
52✔
424

425
    for field in (:dudt, :dvdt, :dthetadt)
52✔
426
        set_vertical_boundaries_of_field!(
156✔
427
            getfield(tendencies, field),
428
            namelists,
429
            domain,
430
            +,
431
        )
432
    end
208✔
433

434
    return
52✔
435
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc