How to Determine Intersection Points for SPH to Eulerian Grid Conversion?

  • Thread starter TimeFall
  • Start date
  • Tags
    Grid
In summary, the author is trying to find points of intersection between a sphere and a cube, but does not know how to do it efficiently. He is looking for help from others.
  • #1
TimeFall
12
0
Hello! I'm currently working on an algorithm that converts SPH (smoothed particle hydrodynamics) data to an Eulerian grid. Basically, the problem is this: each sph particle has an associated smoothing length, which is effectively the radius of a sphere centered at the sph particle's position. The properties of the particle as "smeared" out by a so-called smoothing kernel W(r, h), where r is the distance from the particle and h is the smoothing length. W is a piecewise polynomial. The idea is to get the points on the cell where the sphere overlaps it, and then integrate the smoothing kernel over this overlap volume. My problem is that I do not know of an efficient, effective way of getting these intersection points so that I can do the kernel integration, and was wondering if anyone out there did?

In a nutshell, I have a sphere that overlaps with a cube (not necessarily fully), and I would like to know the points of intersection in the x, y, and z directions. Or, if anyone knows of a better way to approach this problem, I am open to suggestions. Any help would be greatly appreciated! Thanks!
 
Technology news on Phys.org
  • #2
The intersection problem isn't that bad, but there are a lot of combinations to consider.
Basically, you start with the intersection of the sphere with each of the 6 planes - but I don't you need to do that.

You haven't said this explicitly, but I believe that your cube is already lined up with the x, y, and z axis. If not, rotate to a coordinate system where it is. Assuming this is required, it will involve changing the sph center coordinates.

I'm assuming that you only have one cell - I'm a little foggy on exactly what you're doing in that regard.

My first thought was that you wanted to scan through x,y,z coordinates that are shared by the cube and the sph. I'm now thinking that's not exactly what you want, but this might be useful anyway. When you respond, I can be more exact:
So start as if you were going to scan the entire cure - with three nested loops, one each for x, y, and z. Then limit the min x and max x value to those that are shared by the cube and the sphere. If the center of the sphere is Xs, Ys, Zs; the radius R; and the cube limits Xcmin, Xcmax, Ycmin, Ycmax, Zcmin, Zcmax, then you'll be limiting the range of "X" in the outer for loop to (Xcmin to Xcmax) and (Xs +/- R).
Then inside the X loop, compute the range of Y values - limited by (Ycmin to Ycmax) and (Ys +/- sqrt(R*R-(Xs-X)^2)). Then inside the Y loop, compute the range of Z values - limited by (Zcmin to Zcmax) and (Zs +/- sqrt(R*R-(Xs-X)^2-(Ys-Y)^2)).

Do the optimizations explicitly - as opposed to hoping the compiler will do them for you. For example, precompute R*R.
 
  • #3
When you say, "the points on the cell where the sphere overlaps it", are these points along a grid in the interior of the cell and sphere, or the interiors without any grid, or points along the surface of the cell?

I don't know what the integration is that you're performing. The details may reveal significant possibilities for optimization.
 
  • #4
Hey .Scott, thanks for replying! There is more than one cell. I probably should have been more explicit in my description of the problem. What I'm doing is dividing up the simulation volume (which has periodic boundary conditions, so if one sph smoothing sphere goes off the edge of the simulation volume, it has to wraparound to the opposite side) into a regular grid of a user-defined number of cells in each dimension. Yes, the grid is lined up with the x,y, and z axis. The function I need to integrate is:
[tex]
W(r, h) = \frac{8}{\pi h^{3}} \begin{cases} 1 - 6(\frac{r}{h})^{2} + 6(\frac{r}{h})^{3},
&0 \leq \frac{r}{h} \leq \frac{1}{2}\\
2(1 - \frac{r}{h})^{3},
& \frac{1}{2} < \frac{r}{h} \leq 1 \\
0, & \frac{r}{h} > 1\end{cases}
[/tex]
To answer your last question, the region of overlap is defined by points along the surface of the cell (basically, where the sphere "passes through" the surface of the cell).
Another thing that I tried is a sort of quasi Monte Carlo integration that found a normalization weight for each sph particle and then filled each cell with a random field. I then checked to see how many of the random field particles were inside the smoothing sphere and then applied the normalization constant. This worked decently well, but it takes, effectively, forever to run on the larger simulation output files. However, the reason I tried doing it this way was, as you said, there are a ton of different cases you have to worry about when trying to find the integration limits.
Thanks for your help!
 
  • #5


I can understand the challenge you are facing in converting SPH data to an Eulerian grid. One possible approach to this problem could be to use a Monte Carlo method, where you randomly sample points within the sphere and check if they fall within the cube. This can give you an estimate of the intersection points and help in the integration process. Another approach could be to use a numerical integration method, such as the trapezoidal rule, to approximate the integration of the smoothing kernel over the overlapping volume. You could also consider using a grid-based approach, where you divide the cube into smaller cells and then use a search algorithm to find the intersection points with the sphere. I would recommend exploring these options and testing them to see which one gives the most accurate results for your specific problem. Additionally, you could also consult with experts in the field of SPH and Eulerian grids for their insights and suggestions. Good luck with your research!
 

Related to How to Determine Intersection Points for SPH to Eulerian Grid Conversion?

1. What is the difference between SPH and Eulerian grid methods?

SPH (Smoothed Particle Hydrodynamics) is a Lagrangian method that uses particles to represent a continuous fluid while Eulerian grid methods use a fixed grid to represent the fluid. SPH is more accurate for simulating highly dynamic fluids, while Eulerian grid methods are better suited for simulating large scale fluid phenomena.

2. How does SPH convert to an Eulerian grid?

SPH particles can be used to generate a set of interpolation functions which can then be applied to the Eulerian grid to estimate the fluid properties at each grid point. This process is known as Particle-to-Grid (P2G) conversion.

3. What are the advantages of using an Eulerian grid over SPH?

Eulerian grid methods have a fixed grid structure which allows for more straightforward and efficient implementation of boundary conditions and other physics. They also have better mass conservation and can handle larger scale simulations compared to SPH.

4. Are there any limitations to using an Eulerian grid?

One limitation of using an Eulerian grid is the difficulty in accurately capturing highly dynamic fluid phenomena such as splashing or breaking waves. These types of behaviors require a high resolution grid and specialized numerical schemes to accurately simulate.

5. Can SPH and Eulerian grid methods be combined?

Yes, it is possible to combine SPH and Eulerian grid methods to take advantage of the strengths of both approaches. This is known as the Meshless Local P2G method and has been shown to be effective in simulating complex fluid behaviors such as wave breaking and splashing.

Similar threads

  • Advanced Physics Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Quantum Physics
Replies
16
Views
1K
Replies
2
Views
7K
Replies
4
Views
2K
  • Special and General Relativity
Replies
1
Views
1K
Replies
10
Views
1K
  • High Energy, Nuclear, Particle Physics
Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
54
Views
4K
Back
Top