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_quantitiesembedded_boundary_tractionembedded_boundary_stressintegrated_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,StokesFSIProblem2Dendtime_static_modelstep_fsi!,step_fsi_rotation!,step_fsi_strong!simulate_fsi!,simulate_fsi_rotation!
Rigid-motion helper callbacks:
rigid_boundary_velocity,rigid_velocity_2d,rigid_velocityrigid_body_levelset,rigid_cut_bc_tuple,rigid_cut_bc_tuple_2d
7. Canonical Docstrings
PenguinStokes.AbstractPressureGauge — Type
AbstractPressureGaugeAbstract supertype for pressure nullspace constraints in Stokes systems. Concrete options are PinPressureGauge and MeanPressureGauge.
PenguinStokes.PinPressureGauge — Type
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.MeanPressureGauge — Type
MeanPressureGauge()Pressure gauge that replaces one pressure equation by a zero-mean pressure constraint over active pressure cells.
PenguinStokes.StokesLayout — Type
StokesLayout{N}Unknown ordering for monophasic Stokes: [uomega_1; ugamma_1; ...; uomega_N; ugamma_N; pomega].
PenguinStokes.StokesLayoutTwoPhase — Type
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.StokesModelMono — Type
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.MovingStokesModelMono — Type
MovingStokesModelMono{N,T}Unsteady monophasic moving-boundary Stokes model with prescribed embedded boundary velocity through bc_cut_u.
PenguinStokes.StokesModelTwoPhase — Type
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_grids — Function
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_quantities — Function
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 cellstraction: traction vectors on pressure-grid cut cellsforce_density: integrated force vectors (traction * Γ) on pressure-grid cut cellsinterface_indices: active cut-cell indices on the pressure gridforce: total integrated force vectorforce_pressure,force_viscous: pressure/viscous splits offorcetorque: scalar in 2D or vector in 3D aboutx0
PenguinStokes.embedded_boundary_traction — Function
embedded_boundary_traction(model, x; kwargs...)Return pressure-grid traction vectors on embedded boundary cells.
PenguinStokes.embedded_boundary_stress — Function
embedded_boundary_stress(model, x; kwargs...)Return pressure-grid stress tensors on embedded boundary cells.
PenguinStokes.integrated_embedded_force — Function
integrated_embedded_force(model, x; kwargs...)Return integrated embedded-boundary force components and torque.
PenguinStokes.Circle — Type
Circle(R)2D rigid circular shape with radius R.
PenguinStokes.Sphere — Type
Sphere(R)3D rigid spherical shape with radius R.
PenguinStokes.Ellipse — Type
Ellipse(a, b)2D rigid ellipse with semi-axes a and b.
PenguinStokes.Ellipsoid — Type
Ellipsoid(a, b, c)3D rigid ellipsoid with semi-axes a, b, and c.
PenguinStokes.Orientation2D — Type
Orientation2D(theta)Planar orientation represented by a scalar angle theta (radians).
PenguinStokes.Orientation3D — Type
Orientation3D(Q)3D orientation represented by a rotation matrix Q (body -> lab frame).
PenguinStokes.volume — Function
volume(shape)Geometric volume (2D area for planar shapes, 3D volume for 3D shapes).
PenguinStokes.sdf — Function
sdf(shape, xi)Level-set convention used in moving-boundary examples (>0 inside).
PenguinStokes.body_inertia — Function
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.RigidBodyState — Type
RigidBodyState{N,T}Translation-only rigid-body state with center position X and velocity V.
PenguinStokes.RigidBodyState2D — Type
RigidBodyState2D{T}2D rigid-body state with translation (X, V) and scalar rotation (theta, omega).
PenguinStokes.RigidBodyState3D — Type
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.RigidBodyParams — Type
RigidBodyParams{N,T}Translation-only rigid-body parameters.
PenguinStokes.RigidBodyParams2D — Type
RigidBodyParams2D{T,S}2D rigid-body parameters with scalar inertia I.
PenguinStokes.RigidBodyParams3D — Type
RigidBodyParams3D{T,S}3D rigid-body parameters with isotropic (I::T) or tensor (I::SMatrix) inertia.
PenguinStokes.external_force — Function
external_force(params)Return gravitational (and optional buoyancy-corrected) external force applied to the rigid body.
PenguinStokes.external_torque — Function
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_velocity — Function
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_2d — Function
rigid_velocity_2d(x, X, V, omega)
rigid_velocity(x, state2d)2D convenience wrappers for rigid_boundary_velocity.
PenguinStokes.rigid_velocity — Function
rigid_velocity(x, state2d)2D convenience wrapper for rigid_boundary_velocity(x, state2d).
PenguinStokes.rigid_body_levelset — Function
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_tuple — Function
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.rigid_cut_bc_tuple_2d — Function
rigid_cut_bc_tuple_2d(statefun)2D convenience wrapper for rigid_cut_bc_tuple(statefun, Val(2)).
PenguinStokes.StokesFSIProblem — Type
StokesFSIProblemDimension-generic rigid-body FSI wrapper around MovingStokesModelMono.
PenguinStokes.endtime_static_model — Function
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_rotation! — Function
step_fsi_rotation!(fsi; kwargs...)2D rotation-focused alias of step_fsi! for RigidBodyState2D.
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.
PenguinStokes.simulate_fsi_rotation! — Function
simulate_fsi_rotation!(fsi; kwargs...)2D rotation-focused alias of simulate_fsi! for RigidBodyState2D.