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

[Question] Evaluating gradient at particle vs at point #155

Closed
giordi91 opened this issue Mar 14, 2018 · 2 comments
Closed

[Question] Evaluating gradient at particle vs at point #155

giordi91 opened this issue Mar 14, 2018 · 2 comments

Comments

@giordi91
Copy link

giordi91 commented Mar 14, 2018

Good morning, I got a question about sampling the gradient or more generically a field.
Let's take as an example the density gradient, the gradient can be sampled at every point, and the result will be the sum of the weighted densities of all nearby particles. Now that is all good if I am sampling in a generic way the gradient, but when I am sampling the gradient in order to update a value of particle I, particle I need not to be in the neighbor's list? Meaning to compute the value at that particle that particle itself is not included in the computation? I guess otherwise the field would be offsetted by "max value" at every particle point?

Basically enforcing

Here is an example of the density gradient, computed at every point, not for every particle:
image

To me makes sense that if I am sampling a point that is exactly on a particle, there I would expect a high density being near the peak of the kernel function. But my source of confusion is instead if I am evaluating the particles itself

Best regards
M.
PS: hope this is clear enough, if not let me know I can elaborate.

@giordi91 giordi91 changed the title Question] [Question] Evaluating gradient at particle vs at point Mar 14, 2018
@giordi91
Copy link
Author

Apologies, after reasoning more about it, the derivative would be zero, for i==j, meaning we would end up adding nothing to the gradient. Avoiding the i==j case is basically a small optimization. Please correct me if wrong.
In my code I have organized the grid to hold the particles in buckets, so I don't have a list where for each particle I have all the neighbors, but from a position, I find a cell, from that cell(and adjacent cells) I get the contained particles, kinda tempted to leave the extra computation in to avoid more complex logic/branching. Of course I will only know by profiling. I will try to get back to you on the matter. Sorry for the bother.

@doyubkim
Copy link
Owner

Hi @giordi91 ! Yes, I think you got it right. i == j will give you zero gradient contribution from j. All the operators including gradient and laplacian can be computed from any random points in the space. Some non-SPH methods have 1/r factor in the equation which introduces singularities, but for SPH, it's all good :)

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