Boundary conditions
Boundary condition types and the kernels that apply them to velocity, displacement, and temperature fields. See Flow boundary conditions for a narrative guide.
JustRelax.AbstractBoundaryConditions Type
AbstractBoundaryConditionsSupertype for all boundary condition types, e.g. TemperatureBoundaryConditions.
JustRelax.AbstractFlowBoundaryConditions Type
AbstractFlowBoundaryConditionsSupertype for velocity/displacement boundary condition types (VelocityBoundaryConditions, DisplacementBoundaryConditions).
JustRelax.DisplacementBoundaryConditions Type
DisplacementBoundaryConditions(; no_slip, free_slip, periodic, free_surface=false)Define 2D or 3D boundary conditions for the displacement field. Each face is controlled independently with a named tuple. Use exactly four faces in 2D (left, right, top, bot) or six in 3D (also front, back).
A face can carry at most one of no_slip, free_slip, and periodic; a face where all three are false is left for the caller to prescribe explicitly. Periodic faces must be enabled in pairs (left/right, front/back, or bot/top), and a periodic top face is incompatible with free_surface=true.
JustRelax.TemperatureBoundaryConditions Type
TemperatureBoundaryConditions(; no_flux, constant_flux, constant_value, periodic, dirichlet)Create thermal boundary conditions for 2D or 3D temperature fields.
Boundary tuples use left, right, top, and bot in 2D. In 3D they also use front and back. Omitted faces are filled with false, and the dimensionality is inferred from the longest boundary tuple that is passed: pass a complete six-face tuple for a 3D set, since the defaults are four-face 2D tuples. Tuples with any other number of faces are rejected.
The face values have the following meaning:
no_flux:truecopies the adjacent interior temperature into the ghost layer.constant_value: numeric values prescribe the boundary temperature through the ghost valueTghost = 2 * value - Tinterior.constant_flux: numeric values prescribe heat fluxes in the pseudo-transient diffusion flux kernels.periodic:truecopies the opposite interior temperature into the ghost layer.false: leaves that boundary inactive for the corresponding condition.
Periodic faces must be enabled in pairs (left/right, front/back, or bot/top) and cannot also use no_flux, constant_flux, or constant_value.
dirichlet accepts the mask-based Dirichlet forms supported by Dirichlet, for example (; constant = value, mask = mask).
Examples
TemperatureBoundaryConditions(;
no_flux = (left = true, right = true, top = false, bot = false),
constant_value = (top = 273.0, bot = 1573.0),
)
TemperatureBoundaryConditions(;
no_flux = (left = false, right = false, top = false, bot = false),
constant_value = (top = 273.0, bot = 1573.0),
periodic = (left = true, right = true, top = false, bot = false),
)JustRelax.VelocityBoundaryConditions Type
VelocityBoundaryConditions(; no_slip, free_slip, periodic, free_surface=false)Define 2D or 3D boundary conditions for the velocity field. Face names are left, right, top, and bot in 2D, with front and back added in 3D.
no_slip, free_slip, and periodic are mutually exclusive on each face. Faces where all three are false are not modified by flow_bcs!, which is how a prescribed velocity field is imposed. Periodic faces must be enabled in pairs (left/right, front/back, or bot/top), and a periodic top face is incompatible with free_surface=true.
JustRelax.check_flow_bcs Method
check_flow_bcs(no_slip, free_slip, periodic, free_surface)Throw if flow boundary conditions conflict or if a periodic direction is not paired. A boundary flagged as neither no_slip, free_slip, nor periodic is left untouched by flow_bcs!, which is how a prescribed velocity field is imposed: the caller writes the boundary and ghost values itself.
JustRelax.JustRelax2D.flow_bcs! Method
flow_bcs!(stokes, bcs::VelocityBoundaryConditions)
flow_bcs!(stokes, bcs::DisplacementBoundaryConditions)
flow_bcs!(bcs, Vx, Vy[, Vz])Apply no-slip, free-slip, and periodic flow boundary conditions to staggered velocity or displacement arrays. The array form accepts the boundary-condition object first; the stokes form accepts it second. Boundary updates are executed through ParallelStencil kernels on the selected backend.
The three conditions are applied in the order no-slip, free-slip, periodic, so a face carrying more than one of them would keep only the last. The constructors reject such combinations. Faces where all three are false are left untouched. Periodic conditions match normal components at paired boundary planes and copy opposite interior values into tangential ghost planes.
JustRelax.JustRelax2D.thermal_bcs! Method
thermal_bcs!(thermal, bcs::TemperatureBoundaryConditions)
thermal_bcs!(T::AbstractArray, bcs::TemperatureBoundaryConditions)Apply thermal ghost-cell boundary conditions to a temperature field.
thermal_bcs! applies the scalar temperature conditions stored in bcs:
constant_valuefaces are applied first usingTghost = 2 * value - Tinterior.no_fluxfaces are applied next by copying the adjacent interior temperature.periodicfaces are applied last by copying the opposite interior temperature into the ghost layer.
Faces set to false are ignored. Periodic faces must be paired by direction and cannot also carry another thermal condition. Prescribed constant_flux values are not applied here; they are consumed by the pseudo-transient heat-diffusion compute_flux! kernels.
JustRelax.JustRelax2D._bc_coordinate Method
_bc_coordinate(A, x)Materialize coordinate vector x on the same device as array A, so that background-field kernels can index it. collect is applied first because a lazy range cannot be transferred to a device array directly.
JustRelax.JustRelax2D.pureshear_bc! Method
pureshear_bc!(stokes, xci, xvi, εbg)
pureshear_bc!(stokes, xci, xvi, εbg, backend)Initialize a pure-shear background velocity field on the staggered grids. xci contains cell-center coordinates and xvi contains velocity-grid coordinates; each component is built from the vertex coordinates of its own direction. In 2D the kernels set Vx = εbg*x and Vy = -εbg*y. In 3D they set Vx = εbg*x, Vy = εbg*y, and Vz = -εbg*z. Ghost layers are left untouched so that subsequent flow boundary-condition and halo updates can set them consistently.
All field updates are performed by ParallelStencil kernels on the backend of stokes. The five-argument form remains available for compatibility; its backend argument is redundant, as the backend is inferred from stokes.
JustRelax.JustRelax3D.flow_bcs! Method
flow_bcs!(stokes, bcs::VelocityBoundaryConditions)
flow_bcs!(stokes, bcs::DisplacementBoundaryConditions)
flow_bcs!(bcs, Vx, Vy[, Vz])Apply no-slip, free-slip, and periodic flow boundary conditions to staggered velocity or displacement arrays. The array form accepts the boundary-condition object first; the stokes form accepts it second. Boundary updates are executed through ParallelStencil kernels on the selected backend.
The three conditions are applied in the order no-slip, free-slip, periodic, so a face carrying more than one of them would keep only the last. The constructors reject such combinations. Faces where all three are false are left untouched. Periodic conditions match normal components at paired boundary planes and copy opposite interior values into tangential ghost planes.
JustRelax.JustRelax3D.thermal_bcs! Method
thermal_bcs!(thermal, bcs::TemperatureBoundaryConditions)
thermal_bcs!(T::AbstractArray, bcs::TemperatureBoundaryConditions)Apply thermal ghost-cell boundary conditions to a temperature field.
thermal_bcs! applies the scalar temperature conditions stored in bcs:
constant_valuefaces are applied first usingTghost = 2 * value - Tinterior.no_fluxfaces are applied next by copying the adjacent interior temperature.periodicfaces are applied last by copying the opposite interior temperature into the ghost layer.
Faces set to false are ignored. Periodic faces must be paired by direction and cannot also carry another thermal condition. Prescribed constant_flux values are not applied here; they are consumed by the pseudo-transient heat-diffusion compute_flux! kernels.
JustRelax.JustRelax3D._bc_coordinate Method
_bc_coordinate(A, x)Materialize coordinate vector x on the same device as array A, so that background-field kernels can index it. collect is applied first because a lazy range cannot be transferred to a device array directly.
JustRelax.JustRelax3D.pureshear_bc! Method
pureshear_bc!(stokes, xci, xvi, εbg)
pureshear_bc!(stokes, xci, xvi, εbg, backend)Initialize a pure-shear background velocity field on the staggered grids. xci contains cell-center coordinates and xvi contains velocity-grid coordinates; each component is built from the vertex coordinates of its own direction. In 2D the kernels set Vx = εbg*x and Vy = -εbg*y. In 3D they set Vx = εbg*x, Vy = εbg*y, and Vz = -εbg*z. Ghost layers are left untouched so that subsequent flow boundary-condition and halo updates can set them consistently.
All field updates are performed by ParallelStencil kernels on the backend of stokes. The five-argument form remains available for compatibility; its backend argument is redundant, as the backend is inferred from stokes.