Repository navigation
Conversation
keiyamamo
approved these changes
Nov 19, 2026
This branch has not been deployed
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.
This continues the DOLFINx port of
postprocessing_fenics/compute_hemodynamics.pyinpostprocessing_fenicsx/compute_hemodynamics.py. It adds the time-averaged indices computed fromthe wall shear stress (WSS) samples, and it splits the WSS expression into reusable UFL functions.
Changes
WSS as UFL functions
cauchy_stress(u, p, mu_f)returns2 mu_f sym(grad(u)) - p I.wall_shear_stress(sigma, n)returns the tangential part of the traction the fluid exerts on thewall,
F - (F·n) nwithF = -sigma n. The pressure term givesF = p n, which is purelynormal, so p drops out exactly.
sigmacan be passed with or without its pressure part.Stressnow uses these helpers with only the viscous part ofsigma. Its behaviour isunchanged, and the compiled kernel still doesn't need p.
HemodynamicIndicesadd(tau, t)adds a WSS sample.compute()returns TAWSS, OSI, RRT, ECAP and TWSSG as namedscalar DG
Functions, using the definitions in https://kvslab.github.io/VaMPy/quantities.html.T = t_N - t_0:<tau>and<|tau|>are trapezoidal time averages.sum_k |tau_k - tau_{k-1}| / T.happens where there is no WSS at all (TAWSS = 0) or where the WSS averages to zero over time
(
|<tau>| = 0, which affects RRT only).The constructor asserts that it has the same dofmap, so each index is a row-wise numpy operation
on
tau.x.array.reshape(-1, 3). This replaces the legacyFunctionAssigner/sub(0).collapse()handling and the
project_dgcall for TWSSG. For a Lagrange space the dofs are pointevaluations, so computing an index dof by dof gives exactly the interpolation of that nonlinear
index. UFL expressions here would add cost and no accuracy.
Intended use:
Differences from the legacy implementation
The trapezoidal rule weights each sample by its time step. With equal steps the only change is
that the first and last samples get half weight.
tau_prevat zero. That added a spurious|tau_0| / dtterm for thefirst sample, and the sum was divided by the number of samples. Now only the N−1 intervals
between samples contribute, so values come out lower than legacy.
inf/nanwhere the WSS is zero. Now those indices are 0.For RRT this is a convention: its true value at
|<tau>| = 0is unbounded.Tests
The tests live in the module for now, because
tests/runs in the legacy-FEniCS environment in CI.test_wall_shear_stress_independent_of_pressure: uses a nonlinear P2 velocity and a P1 pressurethat varies in space. The full
cauchy_stress(u, p, mu)andStressgive the same WSS.test_hemodynamic_indices: feeds samplestau_k = c_k v, with a fixed vectorvper dof, signchanges in
c_kand unequal time steps. All five indices are compared with their closed-formtrapezoidal values, and OSI is checked to lie in [0, ½].
test_hemodynamic_indices_zero_wall_shear_stress: covers dofs with no WSS and dofs whose WSSoscillates with zero time average. It runs
compute()undernp.errstate(all="raise").Not included
vtkhdf), storing P2 data on adegree-2 geometry mesh from
reconstruct_mesh. That replaces the legacy refined-P1 to P2transfer.
🤖 Generated with the help of Claude Code