API Reference

This page documents the primary exported API and practical constructor notes.

1. Pressure Gauges

  • PinPressureGauge(; index=nothing): pin one pressure DOF.
  • MeanPressureGauge(): enforce active-volume weighted zero mean pressure.

Gauge is required for all model families.

2. Layout Types

  • StokesLayout{N} for monophasic/moving mono systems.
  • StokesLayoutTwoPhase{N} for fixed-interface two-phase systems.

3. Model Constructors

StokesModelMono

Required:

  • gridp, body, mu, rho

Key keywords:

  • bc_u, bc_p, bc_cut, force, gauge, strong_wall_bc, geom_method

MovingStokesModelMono

Required:

  • gridp, body, mu, rho

Key keywords:

  • bc_u, bc_p, bc_cut_u, force, gauge, strong_wall_bc, geom_method

StokesModelTwoPhase

Required:

  • gridp, body, mu1, mu2

Key keywords:

  • rho1, rho2, force1, force2, interface_force, bc_u, bc_p, gauge, strong_wall_bc, geom_method, check_interface

4. Assembly and Solve Entry Points

  • assemble_steady!, assemble_unsteady!
  • assemble_unsteady_moving!
  • solve_steady!, solve_unsteady!, solve_unsteady_moving!

All mutate/return LinearSystem objects with solution in .x after solve!.

5. Postprocessing

  • embedded_boundary_quantities
  • embedded_boundary_traction
  • embedded_boundary_stress
  • integrated_embedded_force

Current scope: StokesModelMono.

6. Rigid-Body and FSI APIs

Rigid-body primitives:

  • states: RigidBodyState, RigidBodyState2D, RigidBodyState3D
  • parameters: RigidBodyParams, RigidBodyParams2D, RigidBodyParams3D
  • shapes: Circle, Sphere, Ellipse, Ellipsoid

FSI wrappers/steppers:

  • StokesFSIProblem, StokesFSIProblem2D
  • endtime_static_model
  • step_fsi!, step_fsi_rotation!, step_fsi_strong!
  • simulate_fsi!, simulate_fsi_rotation!

Rigid-motion helper callbacks:

  • rigid_boundary_velocity, rigid_velocity_2d, rigid_velocity
  • rigid_body_levelset, rigid_cut_bc_tuple, rigid_cut_bc_tuple_2d

7. Canonical Docstrings

PenguinStokes.AbstractPressureGaugeType
AbstractPressureGauge

Abstract supertype for pressure nullspace constraints in Stokes systems. Concrete options are PinPressureGauge and MeanPressureGauge.

PenguinStokes.PinPressureGaugeType
PinPressureGauge(; index=nothing)

Pressure gauge that replaces one pressure equation by a pointwise pinning constraint p[index] = 0 (or the first active pressure DOF when index=nothing).

PenguinStokes.MeanPressureGaugeType
MeanPressureGauge()

Pressure gauge that replaces one pressure equation by a zero-mean pressure constraint over active pressure cells.

PenguinStokes.StokesLayoutType
StokesLayout{N}

Unknown ordering for monophasic Stokes: [uomega_1; ugamma_1; ...; uomega_N; ugamma_N; pomega].

PenguinStokes.StokesLayoutTwoPhaseType
StokesLayoutTwoPhase{N}

Unknown ordering for fixed-interface two-phase Stokes: [uomega1_1; ...; uomega1_N; uomega2_1; ...; uomega2_N; ugamma1_1; ...; ugamma1_N; ugamma2_1; ...; ugamma2_N; pomega1; pomega2].

PenguinStokes.StokesModelMonoType
StokesModelMono{N,T}

Monophasic cut-cell Stokes model on a staggered MAC grid.

Use constructors StokesModelMono(gridp, body, mu, rho; ...) or StokesModelMono(cap_p, op_p, cap_u, op_u, mu, rho; ...).

PenguinStokes.MovingStokesModelMonoType
MovingStokesModelMono{N,T}

Unsteady monophasic moving-boundary Stokes model with prescribed embedded boundary velocity through bc_cut_u.

PenguinStokes.StokesModelTwoPhaseType
StokesModelTwoPhase{N,T}

Fixed-interface two-phase Stokes model with phase-wise interface velocity traces ugamma1, ugamma2 and one pressure block per phase.

Use constructors StokesModelTwoPhase(gridp, body, mu1, mu2; ...) or StokesModelTwoPhase(cap_p1, op_p1, ..., cap_p2, op_p2, ...; ...).

PenguinStokes.staggered_velocity_gridsFunction
staggered_velocity_grids(gridp)

Build component-wise staggered velocity grids from a pressure grid gridp by half-cell shifting each component grid along its own axis.

PenguinStokes.assemble_steady!Function
assemble_steady!(sys, model, t=0)

Assemble steady Stokes linear system into sys for StokesModelMono or StokesModelTwoPhase at time t.

Mutates sys.A and sys.b in place.

PenguinStokes.assemble_unsteady!Function
assemble_unsteady!(sys, model, x_prev, t, dt; scheme=:BE)

Assemble one unsteady theta-step system for StokesModelMono or StokesModelTwoPhase.

scheme supports :BE, :CN, or numeric theta ∈ [0,1].

PenguinStokes.assemble_unsteady_moving!Function
assemble_unsteady_moving!(sys, model, x_prev, t, dt; scheme=:CN)

Assemble one unsteady moving-boundary theta-step system for MovingStokesModelMono, using slab geometry over [t, t+dt] and end-time box BC/gauge application.

assemble_unsteady_moving!(sys, model::MovingStokesModelTwoPhase, x_prev, t, dt; scheme=:CN)

Assemble one unsteady moving-interface theta-step system for MovingStokesModelTwoPhase, using slab geometry over [t, t+dt] and end-time box BC/gauge application.

PenguinStokes.solve_steady!Function
solve_steady!(model; t=0, method=:direct, kwargs...)

Assemble and solve a steady Stokes system for StokesModelMono or StokesModelTwoPhase. Returns a LinearSystem with solution in sys.x.

PenguinStokes.solve_unsteady!Function
solve_unsteady!(model, x_prev; t=0, dt, scheme=:BE, method=:direct, kwargs...)

Assemble and solve one unsteady theta-step for StokesModelMono or StokesModelTwoPhase.

PenguinStokes.solve_unsteady_moving!Function
solve_unsteady_moving!(model, x_prev; t=0, dt, scheme=:CN, method=:direct, kwargs...)

Assemble and solve one unsteady moving-boundary theta-step for MovingStokesModelMono.

solve_unsteady_moving!(model::MovingStokesModelTwoPhase, x_prev; t=0, dt, scheme=:CN, method=:direct, kwargs...)

Assemble and solve one unsteady moving-interface theta-step for MovingStokesModelTwoPhase.

PenguinStokes.embedded_boundary_quantitiesFunction
embedded_boundary_quantities(model, x; mu=model.mu, pressure_reconstruction=:linear, x0=nothing)

Compute cut-boundary stress/traction diagnostics on the staggered velocity grids.

Returns a named tuple with:

  • stress: stress tensors on pressure-grid cut cells
  • traction: traction vectors on pressure-grid cut cells
  • force_density: integrated force vectors (traction * Γ) on pressure-grid cut cells
  • interface_indices: active cut-cell indices on the pressure grid
  • force: total integrated force vector
  • force_pressure, force_viscous: pressure/viscous splits of force
  • torque: scalar in 2D or vector in 3D about x0
PenguinStokes.volumeFunction
volume(shape)

Geometric volume (2D area for planar shapes, 3D volume for 3D shapes).

PenguinStokes.sdfFunction
sdf(shape, xi)

Level-set convention used in moving-boundary examples (>0 inside).

PenguinStokes.body_inertiaFunction
body_inertia(shape, rho_body)

Return inertia for rigid-body dynamics.

  • 2D shapes: scalar out-of-plane moment of inertia (per unit thickness)
  • 3D sphere: scalar moment of inertia
  • 3D ellipsoid: inertia tensor about center in body frame
PenguinStokes.RigidBodyState3DType
RigidBodyState3D{T}

3D rigid-body state with translation (X, V) and rotational state (Q, Omega). Q maps body-frame coordinates to lab-frame coordinates.

PenguinStokes.external_forceFunction
external_force(params)

Return gravitational (and optional buoyancy-corrected) external force applied to the rigid body.

PenguinStokes.external_torqueFunction
external_torque(params, state, t)

Return external torque applied to the rigid body at time t. Defaults to zero for built-in parameter/state types.

PenguinStokes.rigid_boundary_velocityFunction
rigid_boundary_velocity(x, X, V, omega_or_Omega)
rigid_boundary_velocity(x, state)

Rigid-body boundary velocity.

  • 2D: u_b = V + ω * k × (x - X)
  • 3D: u_b = V + Ω × (x - X)
PenguinStokes.rigid_velocity_2dFunction
rigid_velocity_2d(x, X, V, omega)
rigid_velocity(x, state2d)

2D convenience wrappers for rigid_boundary_velocity.

PenguinStokes.rigid_body_levelsetFunction
rigid_body_levelset(shape, statefun)

Build a moving level-set callback body(x..., t) from a rigid shape and a state callback statefun(t).

PenguinStokes.rigid_cut_bc_tupleFunction
rigid_cut_bc_tuple(statefun, Val(N))

Build per-component cut-boundary Dirichlet BC tuple for rigid-body motion, compatible with MovingStokesModelMono(...; bc_cut_u=...).

PenguinStokes.endtime_static_modelFunction
endtime_static_model(model)

Build a static StokesModelMono using the end-time capacities/operators cached by MovingStokesModelMono after assemble_unsteady_moving!/solve_unsteady_moving!.

PenguinStokes.step_fsi!Function
step_fsi!(fsi; t, dt, fluid_scheme=:CN, ode_scheme=:symplectic_euler)

Advance one rigid-body FSI step with one-pass split coupling.

PenguinStokes.step_fsi_strong!Function
step_fsi_strong!(fsi; ...)

Strong partitioned coupling using fixed-point iterations with optional Aitken relaxation.

PenguinStokes.simulate_fsi!Function
simulate_fsi!(fsi; t0=0, dt, nsteps, fluid_scheme=:CN, ode_scheme=:symplectic_euler, callback=nothing)

Run repeated step_fsi! updates and return a lightweight history vector.