Solver Group (Automatic and Manual)
The Solver Group and Automatic Solver Groups extensions are inextricably linked to the concept of multicore processing and are thus leveraged by the Vortex® Parallel Solver. These concepts and their relationship to each other are explained in this topic.
The Vortex Parallel Solver
The Vortex Parallel Solver can be used to significantly speed up complex and time-consuming dynamics simulations. It allows subdividing full dynamics simulations into smaller groups, called partitions. The Parallel Solver processes these partitions concurrently on separate computer cores, thereby fully leveraging modern multicore processors. This can be beneficial in large simulations and significantly reduce computational time.
As an example, consider a multiplayer scenario with two cranes simultaneously lifting a bulky load that is complex to navigate. If no simulation splitting is used, the entire simulation is processed on only one core. In this situation, the time consumption in the dynamics solver for one crane alone might be sufficiently low to ensure real-time simulation performance. However, two cranes linked together to represent a significantly larger simulation problem, which, if not split up, can lead to a correspondingly large increase in time consumption. Real-time simulation might not be possible anymore at this point.
Consider the following example scenario.
Tandem crane use case: two cranes on static platforms attached to the same spreader bar via their hoisting systems |
---|
The two cranes are standing on static platforms and are attached together via a single shared spreader bar which is also lying on a static platform.
Visualizing the simulated Partitions (via the Debug Display menu in the 3D view) reveals that the entire simulation contains only one partition. This single partition contains many hundreds of parts and constraints, and as such, the time spent in the constraint solver is correspondingly high.
Unpartitioned tandem crane simulation. Partition display shows only one simulated partition. |
---|
In the image above, the spheres indicate the centers of mass of the simulated rigid bodies and the lines between the spheres indicate the constraints between these parts. The colors of the spheres indicate the association of the respective bodies to partitions. As can be seen, only one color is present, meaning that only one partition is simulated.
In order to understand whether the Vortex Parallel Solver can be leveraged to speed up your simulation, you can use the Profiler in the Vortex Studio Editor or Player to inspect the time consumption of the dynamics solver.
In the tandem crane example, the Profiler reveals an excessive time consumption in the constraint solver in the unsplit, single partition simulation.
Excessive time consumption in unpartitioned tandem crane simulation |
---|
As can be seen, stepping the Physics takes roughly 18 ms, which exceeds 1/60 s (~ 16.66 ms), and it is thus not possible to achieve real-time simulation performance (considering that the time step is set to 1/60 s).
A big portion of this time, roughly 14 ms, is spent by the constraint solver for computation of the constraint forces (see timing measurement "solveDynamics.computeForces"). This clearly indicates that the simulation is too complex and should be split into smaller, easier to solve partitions, which enables leveraging the new parallel solver to speed up the simulation.
The following image demonstrates the partitions in the tandem crane scene after such a split has been performed. The partition display shows multiple simulated partitions. Note that the constraints that connect two or more partitions are indicated by lines that change color at their midpoint.
Partitioned tandem crane simulation |
---|
After the split, the Profiler reports that the split worked and the same simulation is now running at a significantly higher speed (see screenshot below).
Greatly reduced time consumption in partitioned tandem crane simulation with Vortex Parallel Solver |
---|
The split allows a time consumption reduction from over 14 ms to just over 3 ms, which represents a constraint solver speedup factor of roughly 4.5.
These measurements were performed on an Intel Core i7-6700 CPU with 3.4 GHz clock speed and 4 physical (8 logical) cores.
How to Set Up the Parallel Solver
In order to leverage the Parallel Solver to speed up your simulation, follow the steps described in this section.
Step 1: Configure the Vortex Parallel Solver Properly
The first thing to do is to make sure that the Parallel Solver is properly configured.
- Open your application setup file (.vxc).
- In the Explorer panel, navigate to the Dynamics Engine module.
- Under Partitioning → Coupling Solver → "Partition Coupling Method", select Schur Complement Coupling (Optimized). This will enable efficient parallel processing of the partitions in a split simulation.
The Vortex Parallel Solver will compute the constraint forces in the partitions of a split simulation in parallel. In order to calculate the forces acting between these partitions, i.e., the forces applied by the constraints in the interface between the corresponding partitions, the Parallel Solver will make multiple attempts at finding the right solution. The maximum number of these attempts (called coupling iterations) during this process can be specified with the Partitioning → Coupling Solver → Partition Coupling Max Iterations parameter in the Dynamics Engine module (see your Application Setup file). The Parallel Solver will perform as many attempts as it needs to find the correct solution. The number of coupling attempts performed in every simulation step is provided by the Partition Coupling Iteration output in the Automatic Solver Groups extension.
If Parallel Solver reaches the maximum number of coupling iterations in a given step, it will not make any further attempts, and simulation instabilities can arise. In this case, the maximum number of coupling iterations would need to be increased via this parameter. The number of required iterations for finding the correct result depends on the complexity, size, and number of partitions in a given simulation. Selecting a good value for the maximum coupling iteration parameter is discussed in the remainder of this topic.
Parallel Solver parameters in Dynamics Engine module |
---|
Step 2: Split the Simulation into Partitions
There are two ways to split a simulation into partitions:
- A manual split where you define which parts (or other higher-level components like cable or vehicle extensions) should be grouped together.
- An automatic split is more convenient, specifically for large simulations.
Automatic Splitting
- Select Dynamics from the Toolbox.
- Double-click Automatic Solver Groups to add it to your scene or mechanism. Note that there can only be one such extension in your simulation. If you add another, it will be disabled.
- Select the Automatic Solver Groups extension in the Explorer panel.
- Select the box next to Inputs in its Properties panel to enable it.
- Specify the Maximum Part Count Per Partition that you would like to have in your split simulation.
- Run the simulation by pressing the Play button.
- Right-click in the 3D View, then select Debug Display > Partitions to inspect the split.
- If required, fine-tune the Maximum Part Count Per Partition parameter by
Manual Splitting
Simulation splits can also be performed manually via the Solver Group extension. This extension allows specifically associating parts or other higher-level dynamics extensions (e.g., cables) to partitions.
- Select Dynamics from the Toolbox.
- Double-click Solver Group to add one to your scene. You can add multiple solver groups.
- Select a solver group in the Explorer panel to open its Properties panel.
Make sure the Active input is set in its Properties panel to enable it.
Activating/deactivating Solver Groups at run-time can be useful for testing, as well as for performing certain splits only at certain, critical moment in an ongoing simulation. This run-time activation can also be useful when combined with "Kinematic Coupling" (see next section) to create kinematic interactions between portions of your simulation (e.g., one vehicle and another) only at certain phases of your simulation. This can be useful to either create specific behaviors (Ex: vehicle A will always push vehicle B out of the way), or to reduce the computational load on the solver (by replacing the calculation of physical coupling via trivial kinematic coupling).
- Assign the dynamics objects (e.g., mechanisms, parts, cables) that you want to form a partition to a single solver group. This is done by pressing the + button under Parameters > Extensions and then using the Browse buttons to select an object per row. Each solver group will form an independent partition.
- Run the simulation by pressing the Play button.
- Right-click in the 3D View, then select Debug Display > Partitions to inspect the partitions resulting from your setup.
Kinematic Coupling
For added simulation speed-up, you can completely isolate entire portions of your simulation from others with manual splitting. These isolated partitions can be configured such that they either don't receive any forces from other partitions or that they can't add any forces to other partitions.
This situation, in which the force exchange between partitions no longer goes both ways (bi-directional force exchange) and instead only goes one way (uni-directional force exchange), is called kinematic coupling.
This sort of "level of detail" physics simulation comes in handy in various situations. One example is the simulation of hydraulic hoses attached to the arm of an earthmoving excavator. The dynamics of these hoses don't contribute significantly to the overall behavior of the excavator and are likely irrelevant to the outcome of your simulation. Still, they do add visual realism to the environment and are thus still relevant.
In order to achieve kinematic coupling between a hydraulic hose and the excavator in this scenario, the Generic Cable that represents one of the hydraulic hoses can be added to a Solver Group and made to follow the excavator arm as if the arm was an animated and infinitely massive object. The excavator arm itself will be oblivious to the existence of the hose and won't feel any resistance forces from the hose even if the hose collides with the arm.
And here is how you can achieve this.
- Create a Solver Group as explained in the previous section
- As explained in the previous section, assign the object to this Solver Group that should be entirely split-off from the rest of the simulation, such as the hydraulic hose in the excavator example.
- Now, choose a Coupling Strength in the Solver Group different and smaller than the default coupling strength (which is 0). The value -1 works in this example. This is assuming that the excavator's arm is either not associated to any Solver Group, or if it is assigned to some other Solver Group, this group has a Coupling Strength value of at least 0 (it can be greater than 0 for the example still to work).
- Run the simulation by pressing the Play button.
- Right-click in the 3D View, then select Debug Display > Partitions to inspect the partitions resulting from your setup.
The spherical indicators on the hose will now have a different color than the excavator's arm and the edge connecting the hose and the arm will display a uni-directional force coupling indicator, as shown below.
Now, when moving the arm, the hose will follow the excavator kinematically.
Configuring kinematic coupling for hydraulic hose | Partition display for kinematically coupled hydraulic hose |
---|---|
Combining Manual with Automatic Splitting
The Solver Group extension can be used in conjunction with the Automatic Solver Groups extension. The Solver Group has priority over the Automatic Solver Groups extension. It will therefore enforce certain partitions, overriding the automatic partitioning for the respective portion of the mechanism. Below is an example of such a situation in which most of the mechanism is automatically split (depicted in turquoise blue), and only a few elements (two cables and the sphere at the bottom) are grouped in two separate and larger partitions by two Solver Group extensions (depicted in yellow).
Manual and automatic splitting combined |
---|
Step 3: Select the Correct Number of Coupling Iterations
Once your simulation has been properly split following the steps described in the previous section, an appropriate maximum number of coupling iterations should be found. The Parallel Solver iteratively calculates the correct solution for the coupling forces between the primary partitions in your split simulation. Every time a coupling iteration is performed, the constraint forces inside the primary partitions are calculated, followed by the calculation of the constraint forces of the secondary partitions (the constraints at the interfaces between the primary partitions). The solver will continue iterating until the right coupling forces (i.e., the interface constraint forces) are found, or until the maximum number of coupling, iterations has been reached.
For some simulations, the number of required coupling iterations can be higher than for others. The maximum number of coupling iterations at which the solver stops searching for a solution can be set in the Dynamics Engine parameters in your Application Setup file (.vxc). The default value is 10 and can be modified via the Partitioning → Coupling Solver → Partition Coupling Max Iterations parameter.
If the coupling procedure is terminated prematurely before the coupling process has converged because the specified maximum number of iterations has been reached, instabilities in the simulation can arise as the coupling forces might be incorrect. In this case, the maximum number of coupling iterations should be increased.
In order to understand whether your simulation requires a higher number of coupling iterations, use the Partition Coupling Iteration Count and Partition Coupling Converged outputs of the Automatic Solver Groups extension to monitor the number of coupling iterations used in your simulation, and whether the partition coupling actually converged (which indicates whether the correct coupling solution has been found). If the Partition Coupling Converged parameter becomes deselected, the maximum number of coupling iterations was reached but no solution has yet been found. You can examine the coupling convergence in your simulation by plotting these two outputs using the Plotter in Vortex Studio Editor as shown below.
Plotting the coupling convergence metrics |
---|
If during a simulation run, this plot shows that the coupling convergence becomes deselected at some point, the maximum coupling iteration count should be increased and the simulation restarted and reexamined. This should be repeated until the correct maximum coupling iteration count has been found, or until no more instabilities due to incorrect coupling, forces can be observed.
It is perfectly fine to have a simulation in which the coupling did not converge at times if the simulation remains stable. Finding a good value for the maximum coupling iterations is key here, as setting a higher value can increase the number of iterations and thus the time consumption. A reasonably small coupling iteration limit should ideally be found, which allows for a stable simulation with only occasionally no convergence to maximize the performance gain obtained by splitting the simulation.