newton.solvers.VBDSolver#

class newton.solvers.VBDSolver(model, iterations=10, handle_self_contact=False, integrate_with_external_rigid_solver=False, penetration_free_conservative_bound_relaxation=0.42, friction_epsilon=1e-2, vertex_collision_buffer_pre_alloc=32, edge_collision_buffer_pre_alloc=64, edge_edge_parallel_epsilon=1e-5)#

An implicit solver using Vertex Block Descent (VBD) for cloth simulation.

References

  • Anka He Chen, Ziheng Liu, Yin Yang, and Cem Yuksel. 2024. Vertex Block Descent. ACM Trans. Graph. 43, 4, Article 116 (July 2024), 16 pages. https://doi.org/10.1145/3658179

Note

VBDSolver requires particle coloring information through newton.Model.particle_color_groups. You may call newton.ModelBuilder.color() to color particles or use newton.ModelBuilder.set_coloring() to provide you own particle coloring.

Example

# color particles
builder.color()
# or you can use your custom coloring
builder.set_coloring(user_provided_particle_coloring)

model = modelbuilder.finalize()

solver = newton.VBDSolver(model)

# simulation loop
for i in range(100):
    solver.step(model, state_in, state_out, control, contacts, dt)

Methods

__init__(model[, iterations, ...])

integrate_bodies(model, state_in, state_out, dt)

Integrate the rigid bodies of the model.

integrate_particles(model, state_in, ...)

Integrate the particles of the model.

notify_model_changed(flags)

Notify the solver that parts of the Model were modified.

rebuild_bvh(state)

This function will rebuild the BVHs used for detecting self-contacts using the input state.

Attributes

device

Get the device used by the solver.

__init__(model, iterations=10, handle_self_contact=False, integrate_with_external_rigid_solver=False, penetration_free_conservative_bound_relaxation=0.42, friction_epsilon=1e-2, vertex_collision_buffer_pre_alloc=32, edge_collision_buffer_pre_alloc=64, edge_edge_parallel_epsilon=1e-5)#
Parameters:
  • model (Model) – The Model object used to initialize the integrator. Must be identical to the Model object passed to the step function.

  • iterations (int) – Number of VBD iterations per step.

  • handle_self_contact (bool) – whether to self-contact.

  • integrate_with_external_rigid_solver (bool) – an indicator of coupled rigid body - cloth simulation. When set to True, the solver assumes the rigid body solve is handled externally.

  • penetration_free_conservative_bound_relaxation (float) – Relaxation factor for conservative penetration-free projection.

  • friction_epsilon (float) – Threshold to smooth small relative velocities in friction computation.

  • vertex_collision_buffer_pre_alloc (int) – Preallocation size for each vertex’s vertex-triangle collision buffer.

  • edge_collision_buffer_pre_alloc (int) – Preallocation size for edge’s edge-edge collision buffer.

  • edge_edge_parallel_epsilon (float) – Threshold to detect near-parallel edges in edge-edge collision handling.

Note

  • The integrate_with_external_rigid_solver argument is an indicator of one-way coupling between rigid body and soft body solvers. If set to Ture, the rigid states should be integrated externally, with state_in passed to step function representing the previous rigid state and state_out representing the current one. Frictional forces are computed accordingly.

  • vertex_collision_buffer_pre_alloc` and edge_collision_buffer_pre_alloc are fixed and will not be dynamically resized during runtime. Setting them too small may result in undetected collisions. Setting them excessively large may increase memory usage and degrade performance.

step(model, state_in, state_out, control, contacts, dt)#

Simulate the model for a given time step using the given control input.

Parameters:
  • model (Model) – The model to simulate.

  • state_in (State) – The input state.

  • state_out (State) – The output state.

  • control (Control) – The control input. Defaults to None which means the control values from the Model are used.

  • contacts (Contact) – The contact information.

  • dt (float) – The time step (typically in seconds).

rebuild_bvh(state)#

This function will rebuild the BVHs used for detecting self-contacts using the input state.

When the simulated object deforms significantly, simply refitting the BVH can lead to deterioration of the BVH’s quality. In these cases, rebuilding the entire tree is necessary to achieve better querying efficiency.

Parameters:

state (newton.State) – The state whose particle positions (State.particle_q) will be used for rebuilding the BVHs.

property device: Device#

Get the device used by the solver.

Returns:

The device used by the solver.

Return type:

wp.Device

integrate_bodies(model, state_in, state_out, dt, angular_damping=0.0)#

Integrate the rigid bodies of the model.

Parameters:
  • model (Model) – The model to integrate.

  • state_in (State) – The input state.

  • state_out (State) – The output state.

  • dt (float) – The time step (typically in seconds).

  • angular_damping (float, optional) – The angular damping factor. Defaults to 0.0.

integrate_particles(model, state_in, state_out, dt)#

Integrate the particles of the model.

Parameters:
  • model (Model) – The model to integrate.

  • state_in (State) – The input state.

  • state_out (State) – The output state.

  • dt (float) – The time step (typically in seconds).

notify_model_changed(flags)#

Notify the solver that parts of the Model were modified.

The flags argument is a bit-mask composed of the NOTIFY_FLAG_* constants defined in newton.core.types. Each flag represents a category of model data that may have been updated after the solver was created. Passing the appropriate combination of flags enables a solver implementation to refresh its internal buffers without having to recreate the whole solver object. Valid flags are:

Constant

Description

NOTIFY_FLAG_JOINT_PROPERTIES

Joint transforms or coordinates have changed.

NOTIFY_FLAG_JOINT_AXIS_PROPERTIES

Joint axis limits, targets, or modes have changed.

NOTIFY_FLAG_DOF_PROPERTIES

Joint DOF state or force buffers have changed.

NOTIFY_FLAG_BODY_PROPERTIES

Rigid-body pose or velocity buffers have changed.

NOTIFY_FLAG_BODY_INERTIAL_PROPERTIES

Rigid-body mass or inertia tensors have changed.

NOTIFY_FLAG_SHAPE_PROPERTIES

Shape transforms or geometry have changed.

Parameters:

flags (int) – Bit-mask of model-update flags indicating which model properties changed.