Boundary Conditions
Boundary condition primitives and helpers for staggered C-grid fields.
BC Atoms (1-D)
finitevolx.Dirichlet1D
Bases: Module
Apply a Dirichlet value on one domain face.
The boundary value is imposed at the physical wall between the first interior cell and the ghost cell:
phi_boundary = 0.5 * (phi_interior + phi_ghost)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
value
|
float
|
Target boundary value. |
required |
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one Dirichlet ghost face updated.
Source code in finitevolx/_src/boundary/bc_1d.py
finitevolx.Neumann1D
Bases: Module
Apply an outward-normal gradient on one domain face.
The gradient is interpreted as dphi/dn along the outward normal,
evaluated over the half-cell distance between the first interior cell and
the ghost cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
value
|
float
|
Outward-normal gradient. Defaults to |
required |
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one Neumann ghost face updated.
Source code in finitevolx/_src/boundary/bc_1d.py
finitevolx.Periodic1D
Bases: Module
Apply periodic wrapping on one domain face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one periodic ghost face updated.
Source code in finitevolx/_src/boundary/bc_1d.py
finitevolx.Reflective1D
Bases: Module
Apply an even-symmetry reflective boundary on one face.
This mirrors the nearest interior values into the ghost cells, which is appropriate for scalar tracers or tangential components with reflective symmetry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one reflective ghost face updated.
Source code in finitevolx/_src/boundary/bc_1d.py
finitevolx.Slip1D
Bases: Module
Slip boundary condition for tangential velocity at a solid wall.
Controls the tangential velocity at the wall via a slip coefficient
a in [0, 1]:
a = 1.0— free-slip: ghost = +interior (zero gradient, frictionless wall).a = 0.0— no-slip: ghost = -interior (zero tangential velocity at wall).0 < a < 1— partial-slip: linear interpolation between the two.
The ghost cell is set using:
phi_ghost = (2*a - 1) * phi_interior
so that the extrapolated wall value
phi_wall = 0.5 * (phi_ghost + phi_interior) = a * phi_interior
smoothly varies from zero (no-slip) to the interior value (free-slip).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
coefficient
|
float
|
Slip parameter |
required |
Examples:
Free-slip on the west wall (tangential velocity preserved):
No-slip on the north wall (tangential velocity -> 0):
Partial-slip on the south wall:
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one slip ghost face updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
Float[Array, 'Ny Nx']
|
Input array with ghost-cell ring. |
required |
dx
|
float
|
Grid spacing in x (unused, kept for interface consistency). |
required |
dy
|
float
|
Grid spacing in y (unused, kept for interface consistency). |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'Ny Nx']
|
Field with the ghost face set according to the slip coefficient. |
Source code in finitevolx/_src/boundary/bc_1d.py
finitevolx.Outflow1D
Bases: Module
Apply a one-face outflow boundary condition.
Outflow is modelled here as a zero-gradient copy from the nearest interior cell into the ghost ring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one outflow ghost face updated.
Source code in finitevolx/_src/boundary/bc_1d.py
finitevolx.Sponge1D
Bases: Module
Relax one ghost face toward a background value.
The ghost cells are updated as:
phi_ghost = (1 - weight) * phi_interior + weight * background
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
Literal['south', 'north', 'west', 'east']
|
Domain face to update. |
required |
background
|
float
|
Background state toward which the ghost cells relax. |
required |
weight
|
float
|
Relaxation weight in |
required |
Source code in finitevolx/_src/boundary/bc_1d.py
__call__(field, dx, dy)
Return field with one sponge ghost face updated.
Source code in finitevolx/_src/boundary/bc_1d.py
BC Composition
finitevolx.BoundaryConditionSet
Bases: Module
Apply a different boundary condition on each domain face.
The application order is south, north, west, then east, so west/east updates overwrite the corner values written by south/north updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
south
|
BoundaryCondition1D | None
|
Boundary condition for the south ghost row. |
required |
north
|
BoundaryCondition1D | None
|
Boundary condition for the north ghost row. |
required |
west
|
BoundaryCondition1D | None
|
Boundary condition for the west ghost column. |
required |
east
|
BoundaryCondition1D | None
|
Boundary condition for the east ghost column. |
required |
Source code in finitevolx/_src/boundary/bc_set.py
__call__(field, dx, dy)
Return field with all configured ghost faces updated.
Boundary conditions are applied in south, north, west, east order, so west/east updates overwrite the corner values written by south/north.
Source code in finitevolx/_src/boundary/bc_set.py
open()
classmethod
Return a zero-gradient boundary-condition set on all faces.
Source code in finitevolx/_src/boundary/bc_set.py
periodic()
classmethod
Return a fully periodic boundary-condition set.
Source code in finitevolx/_src/boundary/bc_set.py
finitevolx.FieldBCSet
Bases: Module
Dispatch per-face boundary conditions across multiple fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bc_map
|
dict[str, BoundaryConditionSet]
|
Mapping from state-variable name to per-face boundary conditions. |
required |
default
|
BoundaryConditionSet | None
|
Boundary-condition set used when a variable is not present in
|
required |
Source code in finitevolx/_src/boundary/bc_field.py
__call__(state, dx, dy)
Return a new state dictionary with boundary conditions applied.
Source code in finitevolx/_src/boundary/bc_field.py
Helpers
finitevolx.enforce_periodic(field)
Fill the ghost-cell ring with periodic boundary conditions.
Copies the last interior row/column into the opposite ghost row/column::
ghost south <- last interior row (row Ny-2)
ghost north <- first interior row (row 1 )
ghost west <- last interior col (col Nx-2)
ghost east <- first interior col (col 1 )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
Float[Array, 'Ny Nx']
|
Input array of shape [Ny, Nx]. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'Ny Nx']
|
Array with periodic ghost cells. |
Source code in finitevolx/_src/boundary/boundary.py
finitevolx.pad_interior(field, mode='edge')
Extract physical interior and re-pad to original size.
Strips the ghost-cell ring, then re-pads using the requested mode. Useful for enforcing boundary conditions by re-filling the ghost ring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
Float[Array, 'Ny Nx']
|
Input array of shape [Ny, Nx]. |
required |
mode
|
str
|
Padding mode passed to |
'edge'
|
Returns:
| Type | Description |
|---|---|
Float[Array, 'Ny Nx']
|
Array of shape [Ny, Nx] with ghost cells re-filled. |
Examples: