Add native CPU, Metal, and CUDA microfluidic flow solvers - #3
Open
marpaia wants to merge 4 commits into
Open
Conversation
marpaia
force-pushed
the
marpaia/microfluidics-flow-solvers
branch
from
August 20, 2026 17:10
2ca3f45 to
90c7b60
Compare
This was referenced Aug 20, 2026
marpaia
force-pushed
the
marpaia/microfluidics-flow-solvers
branch
from
August 20, 2026 20:52
90c7b60 to
1ac63e0
Compare
marpaia
marked this pull request as ready for review
August 20, 2026 23:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR adds microfluidic flow solving to the native
ComputeBackendinterface. PR #2 supplies voxel obstacles, boundary conditions, and face-staggered velocity storage; this layer turns those authored device inputs into steady velocity fields on the CPU, Metal, or CUDA backend selected by aSimulation. Cell motion under the solved field remains in PR #4.Native backend architecture
cm/flow.hppdefines backend-neutral parameters, convergence reports, and results for depth-averaged and resolved flow.ComputeBackenddeclares both operations, andSimulationexposes them to C++ and Python.cellmodeller2.flowandcellmodeller2.stokesconstruct dense geometry and coefficient arrays, validate arguments, and dispatch through the selectedSimulation. They no longer contain NumPy implementations of the linear solvers.Numerical methods
div(m grad p) = 0over fluid voxels, with harmonic face mobility, fixed pressure at the inlet and outlet, and zero flux across solid or non-flow boundaries. The matrix-free symmetric positive-definite system uses Jacobi-preconditioned conjugate gradient. Face velocities are reconstructed as-m grad pand rescaled to the requested mean inlet speed.mu lap(v) - mu d(x) v - grad(p) = 0withdiv(v) = 0on the engine MAC grid. Fluid-solid faces impose no slip, flow-axis boundaries impose pressure, and optional Brinkman drag represents porous colony resistance. A matrix-free pressure Schur solve uses an outer preconditioned conjugate-gradient iteration and inner preconditioned momentum solves.1e-6, explicit iteration limits, convergence reports, and the same face layout consumed by signal transport.Device authoring
TrapChannelDeviceandBiopixelTrapDevicegenerate mechanics walls, a conservative solid mask, fixed reservoirs, gap-height mobility, and an initial flow field from one set of dimensions.gap_mobility,colony_mobility, andcolony_dragprepare coefficients for native solves.Simulation.set_velocity_fieldinstalls a re-solved field atomically for transport, drift, and checkpointing.Scientific scope
min_gap_voxelsreports the narrowest transverse resolution.Stack
PR 2 of 5.
Base: #2 (
marpaia/microfluidics-primitives), unchanged by this rewrite.Next: #4 (
marpaia/microfluidics-experimental-coupling).Validation at
1c7a725