-
Notifications
You must be signed in to change notification settings - Fork 33
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
Used center of f_1 as an additional storage and also fixed some bugs #99
Conversation
This seems unnecessary, and I’m not even sure it won’t cause issues in some scenarios that you may need post/pre collision values as the center value is updated during collision. Could you please explain what problem this extra data is intended to solve? At the very least, it introduces a lot of confusion and deviates from the usual definition of using "unknown population" for storage. Regarding the central population, @massimim dicussed the possibility of using a different buffer for central populations in the future, so this approach will not be compatible in that context. |
_rho = f_post[_opp_indices[q], index[0], index[1], index[2]] | ||
break | ||
# Since we need only one scalar value, we only need to find one value (stored at the center of f_1) | ||
_rho = f_post[0, index[0], index[1], index[2]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting that this BC (zouhe) might need more than 1 aux variable? I am not sure what you mean by "more general".
We always have these additional storage spaces at our disposal say in the pull method: (1) I hope this answers your questions about "what problem this extra data is intended to solve". |
I don't think this is correct. This will cause information loss and the core idea of using aux data is that you use "UNUSED" populations to store these values. Say that I come up with a new BC tomorrow that is applied during streaming, and requires pre-collision populations. How can I retrieve the value of pre-collision at location 0 at the beginning of the iteration? |
The center location of OUTPUT (or f_1) is UNUSED and no one needs it just like the missing directions of f_1. This has nothing to do with requiring the pre-collision (or post-streaming) populations because they are already available in the thread (those desgingated with |
This doesn't answer my question. "Say that I come up with a new BC tomorrow that is applied during streaming, and requires pre-collision populations. How can I retrieve the value of pre-collision at location 0 at the beginning of the iteration?" At the beginning of the iteration the registers are empty, so they're not stored there. |
haha! it does not answer your question because you changed / editted your question :) But again we store aux data in In any case, please think about it this way: any argument you want to make against center location of |
The difference is that the missing directions are reconstructed, the center is not. If that information is needed (for any reason whatsoever), it is lost as it is overwritten. |
NO! It is not lost! Of course we ALWAYS need the data at the center of the lattice but that is not overwritten by this method. We have two fields f_0 and f_1. Generally speaking in the two pop approach (as you know) |
If you will never need values of f_1 for any physical computations, you should be able to use the full extra field as additional storage, as long as you swap the whole cell in apply_aux_recovery_bc before storing f_1. Hypothetically if you need them (like the example I gave, which is the pre-collision values at time t, given that the streaming operation does nothing at index=0), then overwriting them in apply_aux_recovery_bc will cause issues. |
But we don't do that, because it will cause race condition in the streaming. Again, if pre-collision values at time t is needed for any computations, the overwrite will lose that value. We don't currently use it in our BCs as far as I can tell. |
Isn't f_1 the f_post in functional_pressure? In that case, in _get_fsum function, we're using f_1[0] to compute fsum_middle? |
fsum_middle includes f_1[0], which instead of the population it is adding the aux data. Am I wrong here? |
I think you use _f_post not f_post...the namings are very confusing. We should fix this later. The buffer values are not the same as the register values and the same name will cause confusion. We should use f_0 and f_1 for the buffers always. |
Again this is my final argument for this:
|
7dbb071
to
23d06d8
Compare
I agree with the naming confusion and pushed a change. |
No the value of f_1 at index=0 at current time step, t, is equal to the values of f_0 at the previous time-step (because of the buffer swapping) which are in turn equal to the pre-streaming (or post-collision) values at t-1 for the same voxel. The most complicated BC we have so far which is closest to your hypothetical scenario is ExrapolationOutflow that needs previous time-step information of the neighbouring cells. If you look at
I don't think we ever need that space. |
@@ -91,8 +91,8 @@ def bc_profile(self): | |||
@wp.func | |||
def bc_profile_warp(index: wp.vec3i): | |||
# Poiseuille flow profile: parabolic velocity distribution | |||
y = self.precision_policy.store_precision.wp_dtype(index[1]) | |||
z = self.precision_policy.store_precision.wp_dtype(index[2]) | |||
y = wp.float32(index[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this back to compute type instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revering it back will cause lots of issues if you run this example with f64/f64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm pls create an issue if it is a bug.
y = self.precision_policy.store_precision.wp_dtype(index[1]) | ||
z = self.precision_policy.store_precision.wp_dtype(index[2]) | ||
y = wp.float32(index[1]) | ||
z = wp.float32(index[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revering it back will cause lots of issues if you run this example with f64/f64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm pls create an issue if it is a bug
23d06d8
to
77ecdf6
Compare
Applied the requested changes and pushed again. |
Contributing Guidelines
Description
Added feature:
Fixed the following bugs:
Type of change
How Has This Been Tested?
Linting and Code Formatting
Make sure the code follows the project's linting and formatting standards. This project uses Ruff for linting.
To run Ruff, execute the following command from the root of the repository:
ruff check .