PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Boundary Conditions Guide

This page is the detailed reference for boundary-condition authoring in case.yml. It documents what is currently supported by the Python conductor and what is currently wired in C.

1. Boundary-Condition Grammar

case.yml -> boundary_conditions is one list with 6 faces.

Face names:

  • -Xi, +Xi, -Eta, +Eta, -Zeta, +Zeta

Every block must provide all six faces exactly once.

2. Boundary Types

A face's type says what kind of boundary it is; its handler says how that boundary is computed. The type selects which handlers are legal and fixes the precedence used where faces meet at an edge.

Value Maps to
inletINLET
outletOUTLET
periodicPERIODIC
wallWALL

A symmetry plane is a free-slip wall. Across a plane of symmetry the normal velocity vanishes, the tangential velocity has zero normal gradient, and so do the scalars: exactly the conditions of a wall that exerts no shear. PICurv therefore offers it as type: wall with free_slip rather than as a boundary type of its own. The former symmetry type is retired: a case naming it is refused with that substitution, and the C type parser refuses SYMMETRY the same way.

wall

Identity. type: wall -> WALL -> priority BC_PRIORITY_WALL.

What it does. Marks a face as an impenetrable surface. Legal handlers: noslip, moving and free_slip. Everything that depends only on impenetrability (zero normal flux, the pressure solve's zero normal flux, particle reflection, the scalars' zero-gradient dummy cells, Newton Krylov's fixed wall-normal unknowns) applies to every wall. What depends on shear (the wall model, its eddy viscosity on the wall face, and the cells it writes) applies only to a wall whose handler exerts it, as BoundaryFaceHasWallShear() reports.

When to choose it. Any impermeable physical surface.

Parameters it owns. None; parameters belong to the handler.

Interactions. Wall loses to inlet and farfield at shared edges and wins over outlet. Wall functions are configured separately under physics.turbulence.wall_function.

Diagnostics. The startup banner lists the resolved type and handler per face.

Evidence. Unit verified - make unit-boundaries, including the reversed-element clip and its per-step freeze (outlet-conservation-backflow-clip, outlet-conservation-clip-frozen-per-step). Analytically verified - duct-poiseuille-picard-2026-09-18.

Limitations. MOVING_WALL is present in the C enum and accepted by the C compatibility check, but no public handler exposes it.

inlet

Identity. type: inlet -> INLET -> priority BC_PRIORITY_INLET.

What it does. Marks a face where flow enters with a prescribed condition. Legal handler: prescribed_velocity.

When to choose it. Any face where you specify what enters the domain.

Parameters it owns. None; parameters belong to the handler.

Interactions. Highest precedence, so an inlet wins at every shared edge. A domain with an inlet needs an outlet to conserve against.

Diagnostics. Startup banner reports the resolved handler and its configured values per face.

Evidence. Unit verified - make unit-boundaries. Production exercised in examples/flat_channel.

Limitations. None of its own; see the handler.

outlet

Identity. type: outlet -> OUTLET -> priority BC_PRIORITY_OUTLET.

What it does. Marks a face where flow leaves. Legal handler: conservation.

When to choose it. The downstream face of any through-flow domain.

Parameters it owns. None; parameters belong to the handler.

Interactions. Lowest precedence, so inlet and wall win at shared edges. Its flux is derived from global conservation rather than prescribed.

Diagnostics. The inlet/outlet flux balance is reported at startup.

Evidence. Unit verified - make unit-boundaries. Production exercised in examples/flat_channel. Analytically verified - duct-poiseuille-picard-2026-09-18.

Limitations. A pressure-specified outlet exists in the C enum but is not exposed; no handler implements it. What a pressure condition needs is at 6b. Pressure Boundary Conditions.

periodic

Identity. type: periodic -> PERIODIC.

What it does. Marks a face as one half of a periodic pair. Legal handlers: geometric, constant_flux, initial_flux.

When to choose it. Any statistically homogeneous direction.

Parameters it owns. None; parameters belong to the handler.

Interactions. Periodic axes are derived from paired PERIODIC conditions before DMDA creation, so both faces must declare it and the grid must satisfy the translation contract. models.domain does not accept periodic flags. Both faces of a driven pair must carry the same driven handler.

Diagnostics. The startup banner reports the derived periodic axes and each validated translation.

Evidence. Unit verified - make unit-periodic. Regression verified - make smoke-periodic. Analytically verified - tgv2d-picard-order-2026-09-18: a triply periodic Taylor-Green vortex at second order in time and space; periodic-channel-laminar-picard-2026-09-18: a channel periodic in two directions reproduces the laminar profile at second order and stays uniform along both periodic axes to 5e-12.

Limitations. Requires a matching translation between paired faces; see 2. Grid Contract. The wall-bounded pseudo-time stall once recorded here did not reproduce at current code (5.7 Known limitations); turbulent periodic channels at production resolution have not been re-characterized.

3. Supported Handlers

The table below is generated from BC_HANDLER_SPECS in picurv_cli/core.py, the validation layer that decides what a case file may actually contain. It is regenerated by make docs-inventory and checked by make audit-capability, so it cannot drift from the validator.

Value Applies to Required parameters Optional parameters
conservationOUTLETnonenone
constant_fluxPERIODICtarget_fluxapply_trim, enforce_seam_flux
free_slipWALLnonenone
geometricPERIODICnonenone
initial_fluxPERIODICnoneapply_trim, enforce_seam_flux
movingWALLnonenone
noslipWALLnonenone
prescribed_velocityINLETnonenone

Rules that apply across all handlers:

  • Unknown parameters are rejected per handler rather than ignored.
  • A driven handler (constant_flux or initial_flux) must be configured, with the same handler, on both faces of the periodic pair.
  • Velocities and fluxes are given in physical units in YAML and non-dimensionalized before reaching C. See 6. Non-Dimensionalization Before C Input.

4. Handler Entries

Each entry below follows the capability-entry contract defined in Documentation Extension Framework: what it does, when to choose it over its siblings, the parameters it owns, its interactions, how to tell it is working, the evidence behind it, and its limitations.

noslip

Identity. handler: noslip on a WALL face -> BC_HANDLER_WALL_NOSLIP -> Create_WallNoSlip.

What it does. Enforces zero relative velocity at the wall. Both the contravariant face flux and the reconstructed Cartesian velocity are driven to zero on the boundary, so no mass crosses the face and no slip is permitted along it.

When to choose it. The default for any solid stationary surface. If the wall moves, or if you intend to model the near-wall layer rather than resolve it, this is not the handler you want - but note that neither alternative is exposed yet (see Limitations).

Parameters it owns. None. noslip takes no parameters, and supplying any is a validation error.

Interactions. Wall faces participate in the boundary priority ordering (BC_PRIORITY_WALL) so that inlet and farfield conditions win at shared edges. Wall functions are configured separately under physics.turbulence.wall_function and are not part of this handler.

Diagnostics. The startup banner lists each face and its resolved handler. A wall that is silently not applied shows up as non-zero velocity in the first cell layer; LOG_FIELD_MIN_MAX on Ucat is the quickest check.

Evidence. Unit verified - make unit-boundaries exercises the handler factory and direct handler behavior in tests/c/test_boundaries.c. Production exercised in every shipped wall-bounded example. Analytically verified - duct-poiseuille-picard-2026-09-18: the walls of a laminar square duct reproduce the Poiseuille profile at second order.

Limitations. The wall is at rest; a wall moving along itself is moving.

moving

Identity. handler: moving on a WALL face, with source on the entry -> bcs parameter source_id and control options -face_source_<id>_frame, -face_source_<id>_expr_<c> -> BC_HANDLER_WALL_MOVING -> Create_WallMoving.

What it does. Sets the wall's velocity from a velocity source, in the language and at the points of prescribed_velocity, and keeps the face closed. The source lies along the wall; a slight tilt, as a straight facet of a curved wall has, is removed.

- face: "+Eta"
type: WALL
handler: moving
source: {expression: {u: "U*sin(omega*t)"}, constants: {U: 1.0, omega: 6.28}}

When to choose it. A wall driving the flow: Couette flow, a lid-driven cavity, a rotating cylinder. For a wall at rest choose noslip, and for one exerting no shear free_slip. Flow through the boundary is an inlet.

Parameters it owns. source - required: an expression source in the cartesian or curvilinear frame, named or inline. constraints - optional: scale.

Interactions. The wall's velocity enters through the boundary value its dummy cell is filled from, as for any wall, and exerts viscous shear on the flow. Newton-Krylov momentum accepts it: the velocity is fixed within a step. Particles reflect off it as off a wall at rest, taking no momentum from its motion. Refused with a wall function, which assumes a wall at rest, and with the normal frame or a data source.

Diagnostics. The face's startup line names its handler and source. A velocity with more than 5% of its magnitude through the wall stops the run naming the velocity and position.

Evidence. Unit verified - make unit-boundaries (wall-moving-along-itself in tests/c/test_boundaries.c) covers both sides of a face, the closed flux, the tilt removed and the refusal. Integration verified - tests/test_velocity_sources.py covers its resolution and refusals. Production exercised in examples/lid_driven_cavity. Analytically verified - lid-driven-cavity-re100-2026-11-06: the cavity at Re 100 converges to the Botella and Peyret (1998) centreline extrema at second order, within 3.2e-4 on 128 x 128 cells; stokes-second-problem-order-2026-11-07: a wall oscillating along itself reproduces the Stokes second problem at second order in space and time, the largest error in the cell next to the wall; couette-moving-wall-2026-11-06: Couette flow between walls moving at +1 and -1 reaches the exact linear profile to 1.6e-10 (Newton-Krylov) and 5.2e-10 (Picard) at 64 ranks, with no flux through the walls.

Limitations. No transpiration: the wall stays closed, so blowing or suction is out of reach. The grid does not move, so the wall's motion is along its own surface.

free_slip

Identity. handler: free_slip on a WALL face -> BC_HANDLER_WALL_FREE_SLIP -> Create_WallFreeSlip.

What it does. An impenetrable wall that exerts no shear. Its boundary velocity is the adjacent interior velocity less its component along the face metric, so the face flux vanishes and the dummy cell is the mirror image of the interior one: normal velocity reversed, tangential velocity kept, which is zero normal gradient. The value follows the flow, so the handler refreshes it on every boundary pass and after each projection (UpdateUbcs). The metric is the face's own normal, so the construction holds on curvilinear grids. Across the wall the eddy viscosity is mirrored too (UpdateDummyCells), and so are the edge cells where it meets another face (UpdateCornerNodes). Pressure and the scalars take zero normal gradient as on any wall.

When to choose it. At a plane of symmetry, to solve half of a symmetric problem; or at a far boundary where the flow should neither cross nor be retarded, such as the cross-stream boundaries of a temporal mixing layer. Choose noslip for a solid wall the fluid adheres to.

Parameters it owns. None.

Interactions. Particles reflect by default. A wall function configured for the case is not applied on a free-slip face, and the face takes the interior face average of the eddy viscosity rather than a wall value. Supported by every momentum solver, Newton Krylov included: its matrix-free residual reconstructs the Cartesian state from the trial vector before the boundary is applied, so the reflected boundary is a function of the trial state alone. The channel and duct spectral initial conditions accept free-slip walls, since their perturbations vanish at the wall.

Diagnostics. The startup banner lists the face as free_slip. The first-cell tangential velocity is free to be nonzero; a wall-normal velocity in the dummy cell that is not the negative of the interior one indicates the handler did not run.

Evidence. Unit verified - make unit-boundaries (tests/c/test_boundaries.c): zero face flux, the mirrored dummy cell on all six faces, the tangential projection on a tilted face, no wall model on a free-slip face, the mirrored eddy viscosity; make unit-newton-krylov: a deterministic residual and a converged solve with and without the point-block preconditioner. Integration verified - make smoke (free-slip wall is a plane of symmetry): a channel half bounded by a free-slip wall equals the corresponding half of the full no-slip channel after three steps to round-off, for laminar Picard, constant-Smagorinsky LES, and Newton Krylov with the point-block preconditioner. Integration verified - free-slip-symmetry-multirank-2026-10-22: the same comparison on 16 ranks, with the free-slip face owned by a subset of them, agrees to 5e-12 or better after 20 steps; on the bent channel a free-slip wall carries round-off normal flux.

Limitations. No moving free-slip wall. On a curvilinear grid an edge cell is mirrored along the metric of the cell it mirrors, which is exact only where the grid is orthogonal to the wall there.

prescribed_velocity

Identity. handler: prescribed_velocity on an INLET face, with source and optional constraints on the entry -> bcs parameter source_id and control options -face_source_<id>_frame, -face_source_<id>_expr_<c>, -face_source_<id>_bulk_velocity, -face_source_<id>_flow_rate, and with fluctuations -face_source_<id>_fluct* and -inflow_fluctuations -> BC_HANDLER_INLET_PRESCRIBED_VELOCITY -> Create_InletPrescribedVelocity.

What it does. Imposes the velocity of a source. An expression source is written in the shared expression language, in physical units, over x y z [m], t [s], the arc-length fractions xi eta zeta (0 at a line's negative face, 1 at its positive face, proportional to distance along the grid line), the line lengths L_xi L_eta L_zeta [m], and r, the slot's distance from the centre of the face [m], which a profile on a face reads wherever the grid places it. Its values are read in one of three frames: cartesian (u v w), curvilinear (u_xi u_eta u_zeta, each the speed through the grid face normal to its axis; omitted components are zero) or normal (one speed into the domain). Each face slot is evaluated at its face centre, with the fractions and directions of the interior cell behind it. A source without t is evaluated once; with t, once per step at the step's end time, not on every boundary pass. A data source is staged as a PICSLICE file (6.1 Prescribed Inlet Profile Files), read from a file or sliced from an earlier solution: normal speeds or Cartesian velocities, one frame or a recording that varies in time.

sources:
duct_flow:
components: curvilinear
constants: {U: 1.0}
expression: {u_zeta: "36*U*xi*(1-xi)*eta*(1-eta)"}
boundary_conditions:
- face: "-Zeta"
type: INLET
handler: prescribed_velocity
source: duct_flow # or the source mapping inline
constraints:
bulk_velocity: "U*(1 + 0.3*sin(2*pi*0.5*t))"

A uniform plug is source: {components: normal, expression: 1.5}; a parabola across two wall-bounded tangential directions is source: {components: normal, expression: "16*1.5*xi*(1-xi)*eta*(1-eta)"}, peaking at 1.5 m/s; in a pipe of radius R, source: {components: normal, expression: "2*U*(1 - r**2/R**2)", constants: {U: 1.0, R: 0.5}} is Poiseuille flow of bulk U wherever the pipe lies. The exact rectangular-duct and Womersley profiles, written with the series sum(k, lo, hi, body) and the Kelvin functions ber/bei, are in Closed-form profiles: series and special functions.

When to choose it. Every inlet. Choose an expression for any profile with a closed form and for every time-dependent profile; written in arc-length fractions it is the physical profile on a stretched or curved grid. Choose a data source for a measured profile (file) or a developed plane from a precursor run (field_slice), and a recording of such planes for turbulent inflow. The exact rectangular-duct solution is an expression (Closed-form profiles: series and special functions).

Parameters it owns. source - required: the name of an entry of the case's top-level sources:, or a mapping. An expression source takes expression (required), components (default cartesian) and constants (named numbers inlined into the expressions and the constraints). Before its own constants, a source may use the case's top-level constants: and, from properties.fluid, rho and nu (viscosity over density); each overrides the one before. A data source takes type and that type's keys:

type Required keys Optional keys Use when
file path - You already have a PICSLICE profile file
field_slice field_file, grid_file, and one of source_case or velocity_scale script, source_block, slice You are extracting a plane from an existing solution

Unknown keys are rejected with the allowed set named. output_file is refused for field_slice: picurv writes sliced profiles under <run.inputs>/inlet_profiles/. components says what each slot holds: normal (default), a nonnegative speed, or cartesian, a velocity that may be tangential or reversed. repeat: true returns to the first frame after the last. Otherwise a new run that ends past the last frame is refused, by its --dry-run plan as well as at staging, and a restart that reaches it stops there.

constraints - optional, applied in order: scale multiplies every value (for a data source the profile is multiplied as it is staged, so scale must be positive); bulk_velocity [m/s], a number or an expression in t, rescales the face each step it changes so the area-weighted mean normal speed equals it; flow_rate [m^3/s], its alternative, does so for the volumetric rate through the face, whose area need not be known. A sum of sources is added, as in the interior (p33_source): expressions in one frame, and at most one data term, which expressions in the data's own frame add to and the rescaling leaves as measured.

Interactions. The same named expression source can set the initial condition (source initial condition), so the interior and the inlet agree at the first step. bulk_velocity sums over the whole face, a collective once per step it is recomputed. A shared shape with the time dependence only in bulk_velocity is evaluated once; only the rescaling runs each step. A data source's dimensions are validated against the grid before the run starts (6.1 Prescribed Inlet Profile Files), and field_slice needs source_case or velocity_scale because a raw field carries no units of its own. Newton-Krylov momentum accepts the inlet: the velocity is fixed within a step, so every residual evaluation sees the same boundary value.

An expression may draw uniform(), in [0, 1), and normal(), from N(0, 1):

source_random_seed: 7 # top level; optional, default 12345
boundary_conditions:
- face: -Zeta
type: INLET
handler: prescribed_velocity
source:
expression: {u: "0.05*normal(1)", v: "0.05*normal(2)", w: "6*eta*(1 - eta) + 0.1*normal(3)"}
constraints: {flow_rate: 1.0}

Each face cell draws anew each step, once per stream, and keeps its value through the step's passes. A draw is a pure function of the seed, the block, the face cell's global index, the step and the stream, so it does not depend on the rank layout and needs nothing in a checkpoint. bulk_velocity and flow_rate rescale each step's draws, so the flow rate holds exactly and the noise moves flux between face cells.

fluctuations adds synthetic turbulence with a chosen Reynolds stress and spatial and temporal correlation, generated by digital filtering (Xie & Castro 2008) and scaled by the Cholesky factor of the stress (Lund, Wu & Squires 1998):

- face: -Zeta
type: INLET
handler: prescribed_velocity
source: {components: normal, expression: "U*(1 - r**2/R**2)*2", constants: {U: 1.0, R: 0.5}}
constraints: {bulk_velocity: 1.0}
fluctuations:
reynolds_stress: {uu: "0.01*(1 - r**2/R**2)", vv: 0.004, ww: 0.004, uw: -0.002} # [m^2/s^2]
length_scales: [0.1, 0.1] # [m], along the face's first and second tangential axes
time_scale: 0.05 # [s]

Each step, every face cell draws three unit normals keyed on the seed, the block, the component, the face cell and the step. They are filtered along the face's two tangential grid axes by the weights exp(-pi |k| / n) for |k| <= 2n, where n = L / h and h is the mean of the face's widest and narrowest cell along that axis, normalized to unit variance. Then the time filter psi <- psi exp(-pi dt / 2T) + filtered sqrt(1 - exp(-pi dt / T)) is applied. The result has unit variance, spatial correlation close to exp(-pi r / 2L) along each axis and temporal correlation exp(-pi tau / 2T). The velocity added is u' = A psi with A A^T = R / U_ref^2. Its components are Cartesian, and it is added after bulk_velocity or flow_rate, which rescale only the mean.

  • Stresses: reynolds_stress maps uu vv ww uv uw vw to numbers or expressions over the face variables above except t, evaluated once. An omitted component is zero. Where the tensor is not positive definite, such as zero at a wall, the rows of A it cannot fill stay zero.
  • Correlation scales: length_scales are two lengths along the face's tangential grid axes, in axis order: xi then eta on a Zeta face, xi then zeta on an Eta face, eta then zeta on a Xi face. time_scale is a time. All three must be positive.
  • Decomposition and seams: a rank computes the halo of its face cells itself, from the same keyed draws, and h comes from each cell's own width rather than a line length summed across ranks, so the fluctuation does not depend on the rank layout. Beyond a closed edge of the face the draws continue on a lattice with a fixed padding, so a draw depends only on its face cell, component, block and step, not on the filter's width; along a periodic tangential axis they wrap.
  • Restart: the filter's state is the catalogued field InflowFluctuation, held in the inlet's dummy plane and written with every checkpoint. A restart from such a checkpoint continues the sequence exactly. A checkpoint written without it, for example by a run without fluctuations, starts the filter afresh.

Diagnostics. The startup banner names the face's -face_source_<id> options, or its staged source_file. A data source logs its file, dimensions and speed range when first applied. inlet_flow.csv under <run.analysis.metrics> records each inlet's area, flow rate, mean normal speed and rescaling factor every step, then fluctuation_flow_rate, the flux of this step's fluctuations, and applied_flow_rate, the flux the face actually admitted: their sum, which equals flow_rate on an inlet without fluctuations. With debug logging the handler logs the target, the source mean and the factor each time it rescales. The applied flux is the inlet's entry in Continuity_Metrics.csv (flux_in). A value that is not finite stops the run naming the position and time; a source whose mean normal speed is zero cannot be rescaled and is refused.

Evidence. Unit verified - make unit-boundaries covers a uniform and a parabolic source on every face, a PICSLICE file, a recording of Cartesian velocities, a source in t evaluated once per step, bulk_velocity and flow_rate rescaling, and r; make unit-mpi (grid-line-fractions-follow-arc-length) checks the fractions and lengths against arc length on a stretched grid across ranks. Integration verified - tests/test_velocity_sources.py covers resolution, the emitted options, data-source staging and scaling, and the refusals; tests/test_config_regressions.py and tests/test_cli_smoke.py exercise the data-source types and the face-dimension validation. Production exercised in examples/flat_channel. Analytically verified - prescribed-velocity-duct-2026-11-08: the exact rectangular-duct series as inlet and initial condition converges at order 1.96 to 1.99 over N = 16, 32, 64 with the flow rate held to 12 digits; a constant inlet develops to the same outlet; a field_slice source and the same profile as a file source give identical runs; a two-period recording delivers the frame-linear mean to 1.8e-10; and a restart matches an uninterrupted run to 5e-15 in velocity; womersley-order-2026-11-06: a Womersley inlet on a circular pipe, written with r, converges at order 2.13 in space and 2.0 in time, its face mean within 4.9e-11 of the exact one; prescribed-recording-2026-11-06: a 50-frame recording with repeat delivers the recorded mean to 1.8e-10 every step, loops exactly, is identical at 64 and 32 ranks, and costs about 0.5% of a step; keyed-source-draws-2026-11-06: drawn noise is bit-identical across rank layouts and a restart, with the requested rms. make unit-mpi (source-draws-are-keyed-on-the-grid) compares each drawn inlet flux with the draw its global index keys, including a later step and a revisited one. Run once, not registered as measurements: a swirling Cartesian inlet whose face velocities match the source to 4e-12, and a curvilinear inlet. make unit-mpi (inlet-fluctuation-is-the-filtered-keyed-draw) rebuilds the filter from the grid spacing and compares the filter state and the inlet velocity with it at every inlet cell, at the first step and after one time-filter update, with a halo that passes the face's edges. Fluctuations, run once locally and not registered as a measurement: on a 32 x 32-node face over 200 steps at dt = T/5 the state's variance is 0.99-1.00, its lag-1 temporal correlation 0.729 against 0.730, and its one-cell spatial correlation 0.394 against 0.399; a restart from a checkpoint reproduces the state and the inlet flux bitwise. On a 40 x 36 face spanning 2 pi by 2, eight ranks split 2 x 4, 4 x 2, 1 x 4 and 4 x 1 across it give bitwise-identical state; the applied inlet flux still differs between layouts at round-off when bulk_velocity or flow_rate rescales it, through that face sum. Benchmark characterized - synthetic-inflow-channel-2026-11-08: a Re_tau 203 channel fed its own fitted mean and stresses through fluctuations receives them at the face within 1% in integral, and downstream recovers the reference skin friction within 5% from 15.1 channel half-heights and the Reynolds-shear-stress peak within 10% from 8.8, where the same inlet without fluctuations stays laminar; the inlet costs 0.04% of the step.

Limitations. Drawn noise is white: uncorrelated between face cells and between steps, so it is not a model of an inflow's turbulence. Its effect depends on dt and the grid, since a smaller step averages more draws per unit time. fluctuations imposes the stress and the correlation scales, not the spectrum or the phase structure of real turbulence, so the flow downstream of the inlet needs a development length before its statistics recover: about 15 channel half-heights for skin friction in the one channel measured, at one set of length_scales and time_scale, which that length depends on. The fluctuation's normal component changes the face's instantaneous flux: bulk_velocity and flow_rate hold the mean part, which inlet_flow.csv reports as flow_rate; the applied flux is applied_flow_rate, and in an inflow-outflow domain its swings move the bulk velocity of the whole domain, enforced by a pressure transient (boundary_pressure.csv). The filter's cost per step grows with the half-widths 2L/h, and the stresses are steady. On a multi-block case the fractions run from 0 to 1 within each block. A data source is steady; only its bulk_velocity and any expressions added to it may vary in time.

conservation

Identity. handler: conservation on an OUTLET face -> BC_HANDLER_OUTLET_CONSERVATION -> Create_OutletConservation.

What it does. Sets the outlet flux to whatever global mass conservation requires, given everything entering the domain. It is a consequence, not a prescription.

Each outlet face element starts from a zero-gradient copy: the velocity of the cell beside it, giving flux F through the element's area A. The total of those copies rarely matches the inflow, so the handler closes the gap with one uniform velocity c, giving F + c A on every element.

A uniform c can leave an element with flux into the domain. That happens when the copied flux is already reversed, or when c opposes the outflow and the element is slow. Once per time step, at the step's first boundary application, the handler checks whether F + c A would point into the domain on any element (fluxes are signed along the increasing grid index, so outward is F > 0 on a + face and F < 0 on a - face):

  • No: the uniform rule above runs, unchanged.
  • Yes: elements whose copied flux points into the domain get zero flux, and their boundary velocity loses its normal component. The other elements are multiplied by one factor, so the face still carries the total the uniform rule would have given it.

The choice of rule and the set of zeroed elements stay fixed for the rest of the step. That keeps the momentum residual smooth inside a Newton solve. The factor is re-measured on every pass, so the total stays exact. An element that starts to reverse mid-step is caught at the next step.

When to choose it. The default and currently only outlet. Because it derives its flux rather than imposing one, it pairs with any inlet without you having to match numbers by hand.

Parameters it owns. None.

Interactions. Outlet has the lowest boundary priority, so inlet and wall win at shared edges. There must be an inlet, or a driven periodic pair, for the outlet to conserve against.

Diagnostics. The inlet/outlet flux balance is reported at startup and is the first thing to check when mass appears not to be conserved. A step that zeroes reversed elements logs a warning with the face, the step, the number of elements the uniform rule would have reversed, the number zeroed, and the factor. Warnings on most steps mean the flow is reversing at the outlet. Lengthen the domain downstream of the region of interest.

Evidence. Unit verified - make unit-boundaries. Production exercised in examples/flat_channel. Analytically verified - duct-poiseuille-picard-2026-09-18: outflow matched inflow to 1e-9 in a laminar square duct.

Limitations. Zeroing reversed elements stops inflow through the outlet. It does not make a zero-gradient outlet non-reflecting: a vortex or a slow wall layer reaching the outlet still distorts the last few cells. Inflow and outflow are compared as fluxes signed along the increasing grid index, which expresses mass conservation when the inlets sit on faces of one side (all negative or all positive) and the outlets on the other. BC_HANDLER_OUTLET_PRESSURE, a pressure-specified outlet, exists in the C enum but is not exposed, and no handler implements it; see 6b. Pressure Boundary Conditions for what adding one involves.

geometric

Identity. handler: geometric on a PERIODIC face -> BC_HANDLER_PERIODIC_GEOMETRIC -> Create_PeriodicGeometric.

What it does. Makes a face pair genuinely periodic: the two faces are treated as the same location, with field values and metrics synchronized across the seam. It imposes no forcing - whatever flux the flow has, it keeps.

When to choose it. Any direction that is statistically homogeneous and needs no driving: the spanwise direction of a channel, or a decaying-turbulence box where the flow should decay rather than be sustained. If you need to sustain a flow against wall friction, you want one of the driven handlers instead.

Parameters it owns. None.

Interactions. Periodic axes are derived from paired PERIODIC boundary conditions before DMDA creation, so both faces of the pair must declare it and the grid must satisfy the translation contract. See 2. Grid Contract.

Diagnostics. The startup banner reports the BC-derived periodic axes and each validated translation.

Evidence. Unit verified - make unit-periodic. Regression verified - make smoke-periodic. Production exercised in the decaying-isotropic-turbulence example. Analytically verified - tgv2d-picard-order-2026-09-18 on a triply periodic box, periodic-channel-laminar-picard-2026-09-18 on a doubly periodic channel, and pipe-poiseuille-curvilinear-2026-09-18 across the ends of a curvilinear pipe, each at second order.

Limitations. Requires a matching translation between the paired faces; a grid that is not truly periodic is rejected rather than approximated. The wall-bounded pseudo-time stall once recorded here did not reproduce at current code (5.7 Known limitations).

constant_flux

Identity. handler: constant_flux on a PERIODIC face pair -> BC_HANDLER_PERIODIC_DRIVEN_CONSTANT_FLUX -> Create_PeriodicDrivenConstant.

What it does. Periodic in the geometric sense, plus a body force that sustains the flow at a flux you prescribe. Without it a periodic wall-bounded flow decays under wall friction.

When to choose it. When the flux is the quantity you are specifying - matching a literature bulk Reynolds number, for instance. Choose initial_flux instead when the flux you want is already present in the field you are starting from.

Parameters it owns. target_flux (required) and enforce_seam_flux (optional, default false; apply_trim is accepted as a deprecated alias).

Warning
target_flux is a volumetric flux - the bulk velocity U_b times the cross-sectional area - not a velocity. Supplying a velocity here silently produces a flow at the wrong Reynolds number.

Interactions. Both faces of the pair must carry the same driven handler. The target is re-read from the bcs file on every run, so editing it between restart segments takes effect - deliberately unlike initial_flux. enforce_seam_flux enables a second, local actuator at the seam plane; it is off by default because it can reintroduce divergence the pressure solve just removed.

Diagnostics. <run.analysis.metrics>/driven_flow.csv records one row per step: the target and measured volumetric flux, the cross-section area, the bulk velocity, the correction, and driving_acceleration, the force per unit mass the flow received that step (zero on a step whose correction was negligible). Its time average is the mean wall stress balance: u_tau^2 / h for a channel of half-height h. picurv summarize --plot driven_flow.driving_acceleration draws it. Bcs.Uch records the seam correction whether or not it is applied, so you can see whether you need it before enabling it.

Evidence. Regression verified - tests/smoke/run_driven_periodic_regression.sh and make smoke-driven-periodic. Analytically verified - periodic-channel-laminar-picard-2026-09-18: on a laminar channel the applied force matches 3 nu U_b / h^2 to 0.18% at the finest grid, the profile converges at second order, and the bulk velocity converges to the controller law below; explicit-rk4-order-2026-09-21 finds the same law under Explicit RK4.

Limitations and full treatment. The proportional controller settles below its target, at U_target / (1 + 3 nu dt / (2.7 h^2)) on a laminar channel - 10% low at dt = 1, nu = 0.1, h = 1 - so choose dt small against h^2 / nu or set the target above the flux wanted. The control law, update cadence and its consequences for both momentum solvers, the restart contract, and the worked validation cases are documented at 5. Driven Periodic Flows.

initial_flux

Identity. handler: initial_flux on a PERIODIC face pair -> BC_HANDLER_PERIODIC_DRIVEN_INITIAL_FLUX -> Create_PeriodicDrivenInitial.

What it does. The same controller as constant_flux, targeting the flux it measures from the field the run starts with, then holding it.

When to choose it. When you have seeded a field whose flux is already what you want - typically a developed field carried in from a precursor - and you want it preserved rather than restated as a number.

Parameters it owns. enforce_seam_flux only (optional, default false; apply_trim is accepted as a deprecated alias, exactly as for constant_flux). target_flux is rejected, not ignored: accepting it would make the two driven handlers indistinguishable in a case file.

Interactions. Both faces of the pair must carry the same driven handler. The measured target is written to the checkpoint and restored on restart, so a resumed run holds the original target rather than re-measuring a drifted one. Checkpoints written before that metadata existed have no entry; the controller then re-measures and says so in the log.

Diagnostics. The latched target is reported once when measured and again when restored from a checkpoint. A restart that re-measures instead of restoring is logged explicitly. Each step writes the same driven_flow.csv row as constant_flux, with the latched value as target_flux.

Evidence. Regression verified - make smoke-driven-periodic. Production exercised in the driven-channel examples. Analytically verified - periodic-channel-laminar-picard-2026-09-18: gives the same field as constant_flux with the same target, to round-off, and reproduces the laminar profile at second order; pipe-poiseuille-curvilinear-2026-09-18 drives Hagen-Poiseuille flow with it on a curvilinear pipe.

Limitations and full treatment. Shares constant_flux's controller and its shortfall below target (p44_cap_constant_flux). See 5. Driven Periodic Flows.

5. Particle Boundary Policies

boundary_conditions[].particle_policy says what a particle becomes when its walk ends beyond that face. It is independent of the flow handler: every handler states a default (noslip reflects; the inlet and outlet handlers remove; the periodic handlers wrap), and a BC entry may override it. wrap belongs to periodic faces: they accept only it, and no other face accepts it. The startup banner prints the resolved policy of all six faces on its Particle Boundary Policy line.

Value Maps to
reflectreflect
removeremove
wrapwrap

A face lies on the domain boundary when the walk's cell index is at that axis' extreme, the same test the handlers use. The walk applies a policy only when every face the particle is outside of lies on the domain boundary; outside an interior face it keeps walking along the boundary first. A pass-1 walk from the particle's previous cell that ends more than three cell sizes beyond the face is treated as blocked by a curved boundary and searched again from scratch in the same pass, before any policy applies (see Walking Search for Particle Location).

reflect

Identity. particle_policy: reflect -> particle_policy=reflect in bcs.run -> PARTICLE_BOUNDARY_REFLECT -> ReflectParticleAcrossCellFace.

What it does. Mirrors the particle about the plane of the crossed face of its boundary cell, p' = p + 2 d n, and continues the search. Psi, weight and particle ID are unchanged, so the particle count and the carried scalar are conserved at the face. An edge or corner crossing reflects about the most-crossed face first and the next one on the following walk step. After four reflections in one search the particle is placed just inside the boundary cell along the segment to its centroid (PlaceParticleInsideCell) instead of being lost.

When to choose it. An impermeable face with zero scalar flux, which is every solid wall: deleting particles there is a sink the physics does not have. Choose remove instead for a face particles genuinely leave through.

Parameters it owns. None.

Interactions. Only meaningful where the particle can reach the face; the policy is ignored on faces nothing crosses. Not allowed on periodic faces, which wrap. Analytical flows that drive particles through a reflecting face pile them up in the last cell layer.

Diagnostics. search_metrics.csv reports reflections and reflection_fallbacks per step; the console prints one INFO line per step with reflections and one WARNING line when any particle reached the cap. A nonzero reflection_fallbacks points at strongly warped boundary cells or very large steps.

Evidence. Unit verified - make unit-particles mirrors a point about a flat face, a sheared face and a two-face corner, and checks the cap fallback; make unit-runtime reflects a particle through the walking search, including after a tangential walk along the wall. Analytically verified - particle-wall-reflection-2026-10-20: wall flux 351.2 reflections per step against the analytic 351, box and near-wall distributions against their analytic references, identical counts on 1, 2 and 4 ranks, and no fallback or loss up to CFL 4; volume-seeding-fix-2026-10-20: curvilinear walls stay well mixed with no near-wall deficit.

Limitations. The face is the planar approximation the search uses, so on curved walls a mirrored point can land outside a neighbouring cell's plane and need another reflection. Particle velocity is not reset at the wall. Immersed boundaries are not seen by particles.

remove

Identity. particle_policy: remove -> particle_policy=remove in bcs.run -> PARTICLE_BOUNDARY_REMOVE -> LocateParticleOrFindMigrationTarget.

What it does. Ends the particle's search as EXITED; CheckAndRemoveLostParticles removes it after settlement and adds its Psi to the step's exited total. The particle is classified once and is not searched again in later settlement passes.

When to choose it. A face particles leave through: an outlet, an inlet when particles diffuse upstream, or a wall you deliberately treat as absorbing.

Parameters it owns. None.

Interactions. The default for the inlet and outlet handlers, and what a bcs.run without a particle_policy token means. A corner where one crossed face removes and another reflects removes the particle.

Diagnostics. search_metrics.csv reports exited, exited_cumulative and exited_psi_sum; lost counts only search failures, so a nonzero lost is a defect signal rather than outflow.

Evidence. Unit verified - make unit-mpi pins one exit across a migration pass on two ranks and checks it is counted once; make unit-runtime checks that removal tallies exits and failures separately and keeps the survivor order. Integration verified - make smoke carries 64 particles out through a channel outlet and checks, every step, that the count falls by exactly the exits, that the classified and removed exits agree, and that none is lost.

Limitations. A particle that leaves is gone; nothing re-injects it.

wrap

Identity. particle_policy: wrap -> particle_policy=wrap in bcs.run -> PARTICLE_BOUNDARY_WRAP -> LocateParticleOrFindMigrationTarget.

What it does. When the walk ends beyond a periodic face, shifts the particle by the validated seam translation (periodic_translation, the same vector the Eulerian periodic images use) into the domain, moves the walk to the cell at the other end of that axis and continues. Every periodic face crossed in one step is wrapped at once, so an edge or corner crossing of several seams lands in its final cell and needs one handoff, not one per seam. If that cell belongs to another rank, the particle is handed off there. A corner with a wall reflects after wrapping. Psi, weight and particle ID are unchanged.

When to choose it. It is the default and only policy of periodic faces; there is no alternative to choose on them.

Parameters it owns. None.

Interactions. Requires a geometric periodic pair, whose translation the grid setup validates. The dummy cell centres next to a periodic seam, which particle interpolation reads, are the translated images of the cells across the seam, including along periodic edges and at corners.

Diagnostics. search_metrics.csv reports wraps per step; the per-step INFO line counts periodic wraps. In a statistically steady flow, wraps per step should match the mean particle flux through the seam.

Evidence. Unit verified - make unit-periodic wraps a particle through each x-periodic face and through an x-y periodic corner, and checks the shifted position and landing cell. Analytically verified - periodic-particle-wrap-2026-10-20: exact conservation and wrap flux within 5e-5 of analytic on 8 to 64 ranks split along every axis, with diffusion, in a DNS channel and in a curvilinear pipe; wrap-one-handoff-owner-lookup-2026-10-21: one handoff per corner crossing, bit-identical results, at most 2 settlement passes up to 216 ranks.

Limitations. Only translational periodicity; rotational periods are not supported by the grid contract either.

6. Non-Dimensionalization Before C Input

picurv converts physical BC values to solver-scale values before writing bcs.run:

\[ v^* = \frac{v}{U_{ref}}, \qquad Q^* = \frac{Q}{U_{ref} L_{ref}^{2}}. \]

Specifically:

  • a data source's PICSLICE speeds are divided by properties.scaling.velocity_ref (and multiplied by its scale) while staging the solver-side .picslice,
  • target_flux is divided by velocity_ref * length_ref^2.

An expression source reaches C in physical units: the runtime evaluates it at physical coordinates and time and divides the velocity by velocity_ref.

6.1 Prescribed Inlet Profile Files

A data source of prescribed_velocity uses a face-scoped canonical PICSLICE file. It can be supplied directly with type: file, or sliced from an old Ucat field with type: field_slice. The Python conductor resolves the face/grid context and delegates dimensional profile writes to generators/profile.gen. Field-sliced sources may set optional script to a compatible case-relative or absolute override:

PICSLICE
<frames>
<n1> <n2> [<components> [<seconds_between_frames>]]
<value>
...

Values follow one frame after another. components is 1 by default: a nonnegative speed normal to the surface, which the handler lifts onto the signed face normal. With 3 each slot holds a Cartesian velocity u v w, in any sign. More than one frame needs the time between them; the first frame applies at t = 0, and the velocity at a time between frames is linear in time. The components key of the source must agree with the file. Every rank reads the file forward as time reaches each frame, and holds only its own slots of the two frames around the current time.

Expected dimensions follow the existing inlet face loop order:

  • -Xi/+Xi: (KM - 1, JM - 1), ordered (k, j)
  • -Eta/+Eta: (KM - 1, IM - 1), ordered (k, i)
  • -Zeta/+Zeta: (JM - 1, IM - 1), ordered (j, i)

For a case with 64 x 64 x 1024 cells, the corresponding profile dimensions are 64 x 64 for -Zeta/+Zeta, 1024 x 64 for -Xi/+Xi, and 1024 x 64 for -Eta/+Eta.

Copy-paste file-backed inlet example:

boundary_conditions:
- face: "-Zeta"
type: INLET
handler: prescribed_velocity
source:
type: file
path: profiles/inlet.picslice

Each face can reference its own .picslice; picurv stages one solver-scale file per face and writes source_file=... into the run's bcs.run.

The face selects the two transverse dimensions automatically:

  • -Xi/+Xi: (KM - 1, JM - 1), ordered (k, j)
  • -Eta/+Eta: (KM - 1, IM - 1), ordered (k, i)
  • -Zeta/+Zeta: (JM - 1, IM - 1), ordered (j, i)

For grid.mode: grid_gen, picurv run --solve generates the grid first, then reads the generated PICGRID header to size the profile. For grid.mode: file, it reads the source PICGRID header. Sliced dimensional profiles and profile.info are written under <run.inputs>/inlet_profiles/, then the staged solver-scale .picslice is referenced from bcs.run.

A recording slices a plane of a precursor run at each of its checkpoints. Slicing needs both grids as files, so the precursor and this case each use grid.mode: file or grid_gen, because a programmatic_c run stages no grid.run. An analytical precursor accepts file only. A workspace reads only its own paths, so register the precursor's files first; --mode reference records where they are without copying them:

picurv inputs import grid <precursor_run>/inputs/grid/grid.run --name precursor.run --mode reference
for step in $(seq 10000 10 20000); do
picurv inputs import reference-field \
"<precursor_run>/output/checkpoints/$(printf 'step_%012d' "$step")/eulerian/block_0000/Ucat.dat" \
--name "$(printf 'Ucat_%012d.dat' "$step")" --mode reference
done

field_files then names them by a pattern of their step numbers, and frame_interval is the time between the frames it gives:

source:
type: field_slice
components: cartesian
repeat: true
field_files:
pattern: inputs/reference_fields/Ucat_{step:012d}.dat.reference.yml
first: 10000
last: 20000
every: 10
frame_interval: 0.05
grid_file: inputs/grids/precursor.run.reference.yml
velocity_scale: 1.0 # Or source_case: a copy of the precursor's case.yml in this workspace
slice: {face: "+Zeta", orientation: opposite}

Field-sliced profiles reuse an existing Cartesian velocity field as a new inlet:

boundary_conditions:
- face: "-Zeta"
type: INLET
handler: prescribed_velocity
source:
type: field_slice
field_file: inputs/reference_fields/Ucat.dat.reference.yml # picurv inputs import reference-field <old_run>/.../Ucat.dat --mode reference
grid_file: inputs/grids/old_grid.run # picurv inputs import grid <old_run>/inputs/grid/grid.run --name old_grid.run
source_case: config/old_case.yml # A copy of the old case.yml
slice:
face: "+Zeta"
orientation: opposite
normal_tolerance: 0.99

field_slice reads old Ucat, computes source and target face normals from canonical PICGRID geometry, projects dot(Ucat, n_hat) to a scalar normal speed, and writes a dimensional .sliced.picslice. orientation: opposite means the old outward normal and new inlet outward normal must oppose each other; use orientation: same only when both outward normals should align. The extractor fails if normal compatibility or flow sign checks fail. V1 requires exact source/target slice dimension matches and does not interpolate.

7. Periodicity Consistency Rules

Validator checks:

  1. each axis pair must match periodicity:
    • (-Xi,+Xi), (-Eta,+Eta), (-Zeta,+Zeta) are both periodic or both non-periodic.
  2. a driven periodic handler (constant_flux or initial_flux) must match on both faces of a periodic pair.
  3. incomplete face sets fail validation immediately.

The C side derives periodic axes from those pairs in DeterminePeriodicity, before DMDA creation. There are no independent YAML periodic flags.

For each active axis, ValidatePeriodicGeometry also requires:

  • at least four physical nodes along the periodic direction,
  • pointwise matching opposite surfaces under one nonzero constant Cartesian translation,
  • the same translation at every point on the paired surfaces.

These rules are checked independently for mixed periodic/non-periodic cases. PETSc periodic DMDAs wrap indices; PICurv separately constructs translated coordinate images and synchronizes cell-centered, face-family, and component-staggered Eulerian fields. Particle periodic wrapping is not implemented.

8. C-Side Parsing and Dispatch

Generated bcs.run lines use:

<face> <type> <handler> key=value key=value ...

C ingestion path:

  1. ParseAllBoundaryConditions parses and broadcasts face configs.
  2. StringToBCFace, StringToBCType, StringToBCHandlerType convert tokens.
  3. ValidateBCHandlerForBCType enforces type-handler compatibility.
  4. BoundaryCondition_Create maps handler enums to concrete implementations.

The inlet handlers and both wall handlers share one application path, ApplyFaceBoundaryVelocity(). Each evaluates a Cartesian boundary velocity; the common path stores it in Ubcs and sets the face-normal Ucont component from its dot product with the local face-area metric, skipping a slot whose fluid side an immersed body blanks. The inlet modes align their speed with the signed unit metric normal; the no-slip wall is at rest; the free-slip wall takes the adjacent velocity's tangential part, whose flux is zero by construction.

ApplyBoundaryConditions runs one boundary pass (the handlers, Cartesian reconstruction, wall function, dummy, periodic and corner updates) per call, or three when some face's handler sets needs_repeat_pass or a wall function is active. A handler sets it when its Apply() reads state the same pass changes after it runs, so that a second pass can change the result: the free-slip wall and the conserving outlet copy the adjacent Ucat, which the pass refreshes after the handlers, and a driven periodic face that enforces the seam flux re-measures and adds a trim each pass. The no-slip wall, the inlets and the plain periodic faces write values the pass does not change. A new handler states which it is in its Create_*() function. In verify mode (-picurv_verify_ghost_updates) a single-pass call runs the two further passes as well and stops the run if they change Ucont, Ucat, P or the boundary values, which catches a handler that should have set the flag.

boundary_faces is the canonical in-memory representation. Do not restore or maintain duplicate persistent legacy BC arrays in UserCtx. If a future low-level integration genuinely needs a translated view, add a narrow on-demand adapter only when a concrete consumer exists.

Current factory-wired handlers include:

  • wall no-slip,
  • wall free-slip,
  • wall moving,
  • inlet prescribed velocity (expression or PICSLICE source),
  • outlet conservation,
  • periodic geometric,
  • periodic driven constant flux,
  • periodic driven initial flux.

9. Exposed vs Latent Options

Important contributor note:

  • C enums include additional BC categories and handlers (far field, characteristic),
  • but the current end-to-end user contract intentionally exposes the validated subset listed above.
  • a field_slice data source is Python-side preprocessing only: it creates the same staged source_file contract used by file-backed profiles.

If you add a new BC mode, update all three layers in one change:

  1. Python validator/writer (picurv_cli/core.py),
  2. C parser/factory/handler implementation,
  3. docs and tests (fixtures + smoke checks).

10. Authoring Examples

Uniform inlet + outlet conservation:

boundary_conditions:
- face: "-Xi"
type: INLET
handler: prescribed_velocity
source: {components: normal, expression: 1.5}
- face: "+Xi"
type: OUTLET
handler: conservation
- face: "-Eta"
type: WALL
handler: noslip
- face: "+Eta"
type: WALL
handler: noslip
- face: "-Zeta"
type: WALL
handler: noslip
- face: "+Zeta"
type: WALL
handler: noslip

Driven periodic flux on Xi:

boundary_conditions:
- face: "-Xi"
type: PERIODIC
handler: constant_flux
params: { target_flux: 0.02, enforce_seam_flux: true }
- face: "+Xi"
type: PERIODIC
handler: constant_flux
params: { target_flux: 0.02, enforce_seam_flux: true }
- face: "-Eta"
type: WALL
handler: noslip
- face: "+Eta"
type: WALL
handler: noslip
- face: "-Zeta"
type: WALL
handler: noslip
- face: "+Zeta"
type: WALL
handler: noslip

11. Common Failure Modes

  • ‘missing required key 'face’/'type'/'handler': malformed BC entry object. -Duplicate face: same face declared twice in one block. -incomplete ... Missing faces: not all 6 faces provided. -Inconsistent periodicity: one side periodic and opposite side non-periodic. -Periodic geometry validation failed: paired surfaces do not differ by one constant nonzero translation, or the periodic axis is too short. -Unknown params`: extra keys not allowed for selected handler.

12. Related Pages