Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Boundary Conditions

Authors
Affiliations
University of Valencia

The discrete operators of the previous chapter read one cell beyond each field point. At the edge of the domain that neighbour lies outside the physical region — it is a ghost cell, and what we write into it is the boundary condition. This chapter shows how finitevolX frames the interior with a ghost halo and how the standard boundary types — periodic, Dirichlet, Neumann, reflective, outflow — are each just a rule for filling those ghosts LeVeque (2002)Durran (2010).

What you will learn

  • How ghost cells turn a boundary condition into a local array update

  • The five canonical 1-D boundary types and their ghost-fill rules

  • How to compose per-face conditions with BoundaryConditionSet

  • The enforce_periodic shortcut somax models use most

Ghost cells: the boundary as an array update

Recall from the C-grid chapter that finitevolX stores an nx×nyn_x\times n_y interior inside an (nx+2)×(ny+2)(n_x{+}2)\times(n_y{+}2) array. The outermost ring is the ghost halo. A stencil at the first interior cell, say the xx-difference (1) reused here as

(∂xh)j, 12≈hj,1−hj,0Δx,\big(\partial_x h\big)_{j,\,\frac12} \approx \frac{h_{j,1} - h_{j,0}}{\Delta x},

reads the ghost value hj,0h_{j,0}. Choosing hj,0h_{j,0} is choosing the boundary condition — no special-cased edge stencils are needed, which keeps the operators uniform across the whole grid. Each boundary type below is simply a different formula for the ghost value in terms of the interior.

The canonical boundary types

Table 1 lists the ghost-fill rules finitevolX implements as 1-D boundary objects. Let ϕint\phi_{\text{int}} be the first interior value adjacent to the boundary and ϕghost\phi_{\text{ghost}} the ghost value to fill.

Table 1:Canonical boundary types and their ghost-fill rules. ϕint\phi_{\text{int}} is the adjacent interior value; hh is the cell spacing normal to the boundary.

Type

finitevolX class

Ghost-fill rule

Physical meaning

Periodic

Periodic1D

ϕghost=ϕopposite interior\phi_{\text{ghost}} = \phi_{\text{opposite interior}}

domain wraps (channel, doubly-periodic box)

Dirichlet

Dirichlet1D

ϕghost=2c−ϕint\phi_{\text{ghost}} = 2c - \phi_{\text{int}}

fixed boundary value cc (e.g. no-slip wall u=0u=0)

Neumann

Neumann1D

ϕghost=ϕint+g h\phi_{\text{ghost}} = \phi_{\text{int}} + g\,h

fixed normal gradient gg (e.g. zero flux)

Reflective

Reflective1D

ϕghost=−ϕint\phi_{\text{ghost}} = -\phi_{\text{int}}

mirror / free-slip symmetry

Outflow

Outflow1D

ϕghost=ϕint\phi_{\text{ghost}} = \phi_{\text{int}}

zero-gradient open boundary

The Dirichlet rule is worth a second look: setting the ghost to 2c−ϕint2c-\phi_{\text{int}} makes the average of the ghost and interior cells equal cc, so the interpolated value at the boundary face is exactly the prescribed cc — the right way to impose a wall value on a cell-centred field.

watermark extension not installed; skipping reproducibility readout.

Periodic boundaries: the enforce_periodic shortcut

Most somax models run on a doubly-periodic box and call the convenience enforce_periodic, which copies each interior edge into the opposite ghost ring. We can see it directly: fill the interior with a ramp, then check that the ghost row mirrors the opposite interior row.

periodic wrap: ghost row 0 == interior row -2 ? True

Composing per-face conditions with BoundaryConditionSet

Real basins mix conditions: a zonal channel is periodic east–west but walled north–south. BoundaryConditionSet assigns an independent 1-D condition to each of the four faces and applies them in one call. Here we build the channel configuration — periodic in xx, Dirichlet walls in yy.

channel: east-west periodic ? True
channel: south wall face value ~ 0 ? True

Visualising the boundary effect

Figure 1 contrasts the two configurations on the same interior field. Under fully periodic boundaries the ghost ring (outer frame) carries the wrapped opposite edge; under the channel configuration the north/south ghosts are the wall reflection while east/west still wrap.

<Figure size 1800x500 with 3 Axes>
The same interior field (left, ghosts zeroed) with periodic ghosts filled by
enforce_periodic (centre) and with the channel BoundaryConditionSet
(right; periodic in x, Dirichlet walls in y). The thin black frame marks
the interior/ghost boundary.

Figure 1:The same interior field (left, ghosts zeroed) with periodic ghosts filled by enforce_periodic (centre) and with the channel BoundaryConditionSet (right; periodic in xx, Dirichlet walls in yy). The thin black frame marks the interior/ghost boundary.

How somax models use boundary conditions

Each somax model implements apply_boundary_conditions(state), which the time integrator calls before every right-hand-side evaluation so the operators always read boundary-consistent ghosts. A doubly-periodic model maps enforce_periodic over each state field; a walled model applies the appropriate wall (Dirichlet / reflective) condition per field and face. The boundary type is therefore part of the model’s physical specification, not an afterthought — it is enforced at every step, never skipped.

Summary

  • A boundary condition is a rule for filling the ghost cells the stencils read ((1)); no special edge stencils are required.

  • The five canonical types — periodic, Dirichlet, Neumann, reflective, outflow — are distinct ghost-fill formulas (Table 1).

  • enforce_periodic handles the common doubly-periodic case; BoundaryConditionSet composes independent per-face conditions (Figure 1).

  • somax models enforce their boundary conditions inside apply_boundary_conditions, called before every RHS evaluation.

This completes the Phase 0 foundations — grids, operators, and boundary conditions. The model chapters build on these primitives to assemble the shallow-water and quasi-geostrophic dynamics.

References

References
  1. LeVeque, R. J. (2002). Finite Volume Methods for Hyperbolic Problems. Cambridge University Press. 10.1017/CBO9780511791253
  2. Durran, D. R. (2010). Numerical Methods for Fluid Dynamics: With Applications to Geophysics (2nd ed., Vol. 32). Springer. 10.1007/978-1-4419-6412-0