Skip to content

Error checking for DPStokes open#79

Merged
rykerfish merged 9 commits intomainfrom
dpstokes_open
Apr 1, 2026
Merged

Error checking for DPStokes open#79
rykerfish merged 9 commits intomainfrom
dpstokes_open

Conversation

@rykerfish
Copy link
Copy Markdown
Contributor

@rykerfish rykerfish commented Mar 7, 2026

This is for the error checking for DPStokes open that we talked about. I'm leaving it as a draft currently since I'm still unsure about the tolerances.

Madison has a case for bending forces on a membrane where I recall the absolute sum being ~1e5 but the (signed) sum being ~1e-2 or 1e-3. This is kinda small and seems like it should be acceptable, but overall not that small numerically. I'm asking for the exact values to decide.

@RaulPPelaez @brennansprinkle how do you think we should set the tolerance for when DPStokes throws an error? The most sound way to be seems to be setting it relative to the absolute mean, i.e.

$$\frac{\sum F_i}{\sum \vert F_i \vert} < \epsilon $$,

where $\epsilon$ could seemingly be set pretty small, maybe at least $10^{-4}$, based on Madison's case. However, I think this would require an extra reduction per call to Mdot which might get expensive. We could alternatively set it conservatively based on the signed sum, and just informing users with cases like this to enable the unsafe flag.

Closes #78

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

Linter reported no issues

All Python files are correctly formatted with Black.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

Linter reported no issues

All C/C++ files are correctly formatted with clang-format.

@RaulPPelaez
Copy link
Copy Markdown
Contributor

the absolute sum being ~1e5 but the (signed) sum being ~1e-2 or 1e-3

Is that computing the sum with a parallel reduction or just sequential summing? The parallel version might be more precise. A quick and dirty check would be to accumulate using double (you can use thrust::transform_reduce).
Otherwise your strategy sounds reasonable to me.

You can compute the absolute sum by using a single transform_reduce by transforming the real3 forces into a vec4 (fx,fy,fz, abs(fx)+abs(fy)+abs(fz)) and accumulating that.

@rykerfish rykerfish marked this pull request as ready for review March 31, 2026 22:36
@rykerfish rykerfish requested a review from RaulPPelaez March 31, 2026 22:36
@RaulPPelaez
Copy link
Copy Markdown
Contributor

LGTM, feel free to merge

@rykerfish rykerfish merged commit 39f76a3 into main Apr 1, 2026
3 checks passed
@rykerfish rykerfish deleted the dpstokes_open branch April 1, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DPStokes (periodic, periodic, open) needs net zero force on the domain

2 participants