SPHEntity#
- class genesis.engine.entities.sph_entity.SPHEntity(scene, solver, material, morph, surface, particle_size, idx, particle_start)[source]#
Bases:
ParticleEntitySPH-based particle entity.
- Parameters:
scene (Scene) – The simulation scene.
solver (Solver) – The solver handling the simulation logic.
material (Material) – Material properties (e.g., density, stiffness).
morph (Morph) – Morphological configuration.
surface (Surface) – Surface constraints or geometry.
particle_size (float) – The size of each particle.
idx (int) – Index of this entity in the scene.
particle_start (int) – Start index for the particles belonging to this entity.
- init_sampler()[source]#
Initialize the particle sampler based on the material’s sampling method.
- Raises:
GenesisException – If the sampler is not one of the supported types: ‘regular’, ‘pbs’, or ‘pbs-sdf_res’.
- set_pos(f, pos)[source]#
Set particle positions for the specified frame.
- Parameters:
f (int) – Frame index.
pos (ndarray) – Array of particle positions of shape (n_envs, n_particles, 3).
- set_pos_grad(f: <gstaichi._lib.core.gstaichi_python.DataTypeCxx object at 0x7d47a6882530>, pos_grad: NdarrayType(dtype=None, ndim=None, layout=Layout.AOS, needs_grad=None))[source]#
Set gradient of particle positions.
- Parameters:
f (int) – Frame index.
pos_grad (ndarray) – Gradient array for positions.
- set_vel(f, vel)[source]#
Set particle velocities for the specified frame.
- Parameters:
f (int) – Frame index.
vel (ndarray) – Array of particle velocities of shape (n_envs, n_particles, 3).
- set_vel_grad(f: <gstaichi._lib.core.gstaichi_python.DataTypeCxx object at 0x7d47a6882530>, vel_grad: NdarrayType(dtype=None, ndim=None, layout=Layout.AOS, needs_grad=None))[source]#
Set gradient of particle velocities.
- Parameters:
f (int) – Frame index.
vel_grad (ndarray) – Gradient array for velocities.
- set_active(f, active)[source]#
Set the active status of particles for a given frame.
- Parameters:
f (int) – Frame index.
active (ndarray) – Boolean array indicating whether each particle is active.
- clear_grad(f: <gstaichi._lib.core.gstaichi_python.DataTypeCxx object at 0x7d47a6882530>)[source]#
Placeholder to clear gradients for the specified frame (not yet implemented).
- Parameters:
f (int) – Frame index.
- get_frame(f: <gstaichi._lib.core.gstaichi_python.DataTypeCxx object at 0x7d47a6882530>, pos: NdarrayType(dtype=None, ndim=None, layout=Layout.AOS, needs_grad=None), vel: NdarrayType(dtype=None, ndim=None, layout=Layout.AOS, needs_grad=None))[source]#
Retrieve particle positions and velocities for the given frame.
- Parameters:
f (int) – Frame index.
pos (ndarray) – Output array for positions (n_envs, n_particles, 3).
vel (ndarray) – Output array for velocities (n_envs, n_particles, 3).