Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle in-patch invariants when converting between different precisions #6

Open
germasch opened this issue Feb 6, 2018 · 3 comments

Comments

@germasch
Copy link
Contributor

germasch commented Feb 6, 2018

So I'm pretty sure I hit cases where a particle was validly inside a given patch in double precision, but when those particle got converted to single precision for some operation (like sorting), that invariant was violated and then leads to an assertion failure (or worse).

@wrfox
Copy link

wrfox commented Feb 6, 2018 via email

@germasch
Copy link
Contributor Author

germasch commented Feb 6, 2018

Yeah, so I think it helps to have proper invariants, and I've moved into that direction: Ideally, the invariant would just be: All particles in the particle array are within bounds (which needs a definition, too).

In particular, whenever a particle gets added (during injection, initialization, ?), it needs to be within bounds. However, the particle push breaks the invariant temporarily, until the boundary exchange is performed. This should be kinda acceptable, though not ideal, since it's a bit more complex than I'd like to have it. One option might be to move particles that leave the local patch out out of the particle list right in the pusher, so then the invariant would be satisfied at all times.

The particular issues at hand, though, I think isn't as tough. Patch ownership is currently defined as, say the domain goes from [0:40[, divided into 4 subdomains / patches in that direction:
[0:10[, [10:20[, [20:30[, [30:40[. Patch positions are actually stored patch-local, so local positions would be [0:10[ for every patch. However, if one does not have periodic b.c., the last patch should actually become [30:40], or [0:10] locally. That's kind of a pain, since the cell index isn't then just simply floor(x / dx), a particle exactly at the right limit would be considered in a non-existing cell. This is still not handled well.

The particular problem here, though, is not that bad, it doesn't require actual communication to solve, I think. A particle at 9.999999999 in double precision turns into position 10.0 in single precision, which would be considered out of bounds. But I think just nudging it back to 9.99999 would work well enough.

On the other hand, I think the best solution might be to just have the invariant condition to allow the closed interval [0:10] everywhere, but assign a particle at the right limit to be still at the cell index m-1, that is, in the cell [9:10[. Interpolation etc will work just fine that way, as long as that cell index is always calculated consistently that way.

I don't completely like that because of the ambiguity (a particle at 20.0 could legally part of patch [10:20] or [20:30]), but since some kind of special case, at least at the top boundary w/o periodic b.c. is unavoidable, that may be the cleanest way.

@wrfox
Copy link

wrfox commented Feb 7, 2018 via email

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

No branches or pull requests

2 participants