Efficiently extracting high-precision fluid position near a surface (PySPH, WCSPH, OpenCL)

25 views
Skip to first unread message

EUDE SILVA

unread,
Jul 28, 2025, 11:53:01 AMJul 28
to pysph-users

Hi all,

I'm working with a 3D PySPH simulation where I need to extract the precise vertical position (z) of fluid particles near a geometrically defined solid surface — e.g., a paraboloid. My goal is to capture positions with spatial resolution in the range of 1e-2 to 1e-4 meters, after a small time evolution (t ≈ 0.5 s).

To achieve this, I’m using the standard WCSPHScheme. I define both the fluid and the solid surface in create_particles(), and in post_process() I compute the fluid particle closest to the surface at each saved frame (based on z). The problem is subtle: tiny errors affect the nearest-point estimation significantly.

To get the required accuracy, I set dx = 1e-3, but this led to simulation times estimated in the range of days or years. I'm currently using --opencl to leverage GPU acceleration (NVIDIA RTX A4000), but unfortunately, I cannot use OctreeNNPS in OpenCL mode, which hurts performance further. With CPU (octree_omp), I can run it but it's also slow.

I have access to:

  • A high-performance CPU machine (many cores), and

  • A strong GPU machine (NVIDIA RTX A4000, OpenCL-enabled).

Questions:
  1. Is there a more efficient way to obtain precise fluid positions near a surface at this level of accuracy?

  2. Is there a way to use OctreeNNPS (or a fast alternative) with OpenCL?

  3. Do you have general advice on how to optimize this kind of simulation?

Here is the high-level structure of my simulation code (based on the paraboloid.py example):


class ParaboloidTank3D(Application):
    def create_particles(self):
        # Create surface (solid) and fluid particle arrays
        # Define outlet condition to remove distant particles
        return [fluid, surface]

    def create_scheme(self):
        # WCSPHScheme with standard parameters

    def configure_scheme(self):
        # WendlandQuintic kernel, adaptive timestep, tf = 0.5

    def post_step(self, solver):
        # Remove particles using a radius/z condition

    def post_process(self, info_fname):
        # For each output file, extract fluid particle with min(z)
        # Save and plot z_min vs. time for analysis


Thanks in advance for any suggestions or optimizations you can offer!

Best regards,
Eude Lucas.


Captura de tela 2025-07-28 125155.png

EUDE SILVA

unread,
Aug 7, 2025, 9:56:39 AMAug 7
to pysph-users

Hello everyone,

I was able to solve the previous issue by changing the scheme I was using. Initially, I was using the WCSPH scheme, but it can lead to divergence in the fluid — in other words, unexpected forces can appear, pushing particles outward, even against gravity. I'm not exactly sure what causes these forces to emerge.

With the divergence issue in mind, I decided to switch to the IISPH scheme, which is designed for incompressible fluids. This helped avoid the divergence problem and allowed the simulation to run successfully.

Now, however, I’m facing a new issue, which I’ve described here:
https://groups.google.com/g/pysph-users/c/B5d9QKArz40/m/W1h8jAV9CAAJ

Any help or suggestions would be greatly appreciated!

Best regards,
Eude Lucas

Reply all
Reply to author
Forward
0 new messages