PBDSolver#

The PBDSolver implements Position Based Dynamics for simulating cloth, soft bodies, and particle systems with fast, stable steps. The materials it supports are listed in PBD. For the algorithm, its constraint groups, and usage, see Soft solvers and Beyond rigid bodies.

Options#

class genesis.options.solvers.PBDOptions(*, dt: float | None = None, gravity: tuple[float, float, float] | None = None, max_stretch_solver_iterations: int = 4, max_bending_solver_iterations: int = 1, max_volume_solver_iterations: int = 1, max_density_solver_iterations: int = 1, max_viscosity_solver_iterations: int = 1, particle_size: float = 0.01, hash_grid_res: tuple[float, float, float] | None = None, hash_grid_cell_size: float | None = None, lower_bound: tuple[float, float, float] = (-100.0, -100.0, 0.0), upper_bound: tuple[float, float, float] = (100.0, 100.0, 100.0)) None[source]#

Options configuring the PBDSolver.

Note

If spatial hashing parameters are not given, we will compute them automatically this way: For hash_grid_cell_size, we will set it to be 1.25 * particle_size. For hash_grid_res, if a small bound is given, it’s used for the hash grid; otherwise, we use a default value of a 150^3 cube. Any grid bigger than that will results in too many cells hence not ideal.

Parameters:
  • max_stretch_solver_iterations (int, optional) – Maximum number of iterations for the solving stretch constraints. Defaults to 4.

  • max_bending_solver_iterations (int, optional) – Maximum number of iterations for the solving bending constraints. Defaults to 1.

  • max_volume_solver_iterations (int, optional) – Maximum number of iterations for the solving volume constraints. Defaults to 1.

  • max_density_solver_iterations (int, optional) – Maximum number of iterations for the solving density constraints. Defaults to 1.

  • max_viscosity_solver_iterations (int, optional) – Maximum number of iterations for the solving viscosity constraints. Defaults to 1.

  • particle_size (float, optional) – Particle diameter in meters. Defaults to 1e-2.

  • hash_grid_res (tuple, optional) – Size of the spatially-repetitive spatial hashing grid in meters. If none, it will be computed automatically. Defaults to None.

  • hash_grid_cell_size (float, optional) – Size of the lattic cell of the spatial hashing grid in meters. This should be at least 1.25 * particle_size. If none, it will be computed automatically. Defaults to None.

  • lower_bound (tuple, shape (3,), optional) – Lower bound of the simulation domain. Defaults to (-100.0, -100.0, 0.0).

  • upper_bound (tuple, shape (3,), optional) – Upper bound of the simulation domain. Defaults to (100.0, 100.0, 100.0).

PBDSolver#

class genesis.engine.solvers.pbd_solver.PBDSolver(scene, sim, options)[source]#

Bases: GravityMixin, TimeBasedMixin, Solver

material_cls#

alias of Base

class MATERIAL(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: IntEnum

CLOTH = 0#
ELASTIC = 1#
LIQUID = 2#
PARTICLE = 3#
setup_boundary()[source]#
init_vvert_fields()[source]#
init_particle_fields()[source]#
init_edge_fields()[source]#
init_elem_fields()[source]#
init_ckpt()[source]#
reset_grad()[source]#
build()[source]#
property is_active#
add_entity(idx, material, morph, surface, visualize_contact=False, name: str | None = None, desc=None) PBD2DEntity | PBD3DEntity | PBDParticleEntity | PBDFreeParticleEntity[source]#
poly6(dist)[source]#
poly6_scalar(dist)[source]#
spiky(dist)[source]#
S_Corr(dist)[source]#
process_input(in_backward=False)[source]#
process_input_grad()[source]#
substep_pre_coupling(f)[source]#
substep_pre_coupling_grad(f)[source]#
substep_post_coupling(f)[source]#
substep_post_coupling_grad(f)[source]#
collect_output_grads()[source]#
add_grad_from_state(state)[source]#
save_ckpt(ckpt_name)[source]#
load_ckpt(ckpt_name)[source]#
set_state(f, state, envs_idx=None)[source]#
get_state(f)[source]#
get_state_render()[source]#

Get visual vertex positions, UVs, and face indices for rendering.

Returns:

(vverts_pos, vverts_uvs, vfaces_indices) - vertex positions, UV coords, and triangle indices

Return type:

tuple

update_render_fields()[source]#
property n_particles#
property n_fluid_particles#
property n_edges#
property n_inner_edges#
property n_elems#
property n_vverts#
property n_vfaces#
property particle_size#
property particle_radius#
property hash_grid_res#
property hash_grid_cell_size#
property upper_bound#
property lower_bound#

See also#