Settings¶
All STARK configuration is collected in a single stark::Settings object that is passed to the stark::Simulation constructor.
STARK owns the output, simulation, and execution settings, while the nonlinear solver settings are provided by SymX through symx::NewtonSettings.
At minimum, a simulation should provide a name and an output directory.
It is strongly recommended to review all available options; the right tolerances, solver, and time step often depend on the problem at hand. The difference in performance and accuracy between a good and a bad setup can be very significant.
The following is a typical lean configuration that relies almost entirely on defaults:
#include <stark>
int main()
{
stark::Settings settings;
// Required output settings
settings.output.simulation_name = "hanging_cloth";
settings.output.output_directory = OUTPUT_PATH + "/hanging_cloth";
// Typical simulation controls
settings.execution.end_simulation_time = 5.0;
settings.simulation.max_time_step_size = 1.0 / 30.0;
settings.simulation.init_frictional_contact = false;
settings.newton.step_tolerance = 1e-3; // [m/s]
settings.newton.residual_tolerance_abs = 1e-3; // [N]
stark::Simulation simulation(settings);
simulation.run();
}
Convergence¶
Before all the options are introduced, it is important to highlight the importance of convergence. The following are the options given by STARK/SymX:
newton.min_iterationscan be used to enforce at least N corrections are applied, even if already converged. Setting this to 1 can prevent subtle motions from freezing.There are four main convergence options. Convergence is granted once one of them is true:
\(\| \nabla_x G \| <\)
newton.residual_tolerance_absin Newtons.\(\frac{\| \nabla_x G \|}{\| \nabla_x G_0 \|} <\)
newton.residual_tolerance_rel\(\| \Delta \mathbf x \|_{\infty} < \)
newton.step_tolerancethe Newton step in m/s.newton.max_iterationsreached andnewton.max_iterations_as_success = true
Most often when simulations are slow or behave unrealistically it is because the convergence criteria and tolerances are not set appropriately.
Typically, newton.step_tolerance is the most robust general criteria, but it too can be really challenging to obtain in challenging simulations.
Sometimes, shortening the time step size is the best option.
Other times, returning success on a fixed amount of Newton iterations is justified.
Structure¶
stark::Settings is organized into four sections:
Section |
Type |
Purpose |
|---|---|---|
|
|
Paths, frame writing, console output, and log files. |
|
|
Global physical and time-stepping parameters. |
|
|
SymX nonlinear solver, line search, Hessian projection, and linear solver settings. |
|
|
Runtime limits and thread count. |
STARK applies defaults in Settings::Settings(): it sets the timestamp, picks a codegen directory from SymX, sets the default thread count, and overrides some SymX Newton defaults for simulation use.
The tables below list the effective STARK defaults.
Output settings¶
Output settings control where STARK writes generated code, logs, and frame data.
simulation_name, output_directory, and codegen_directory must be non-empty when the internal Stark object is constructed.
By default, codegen_directory is filled from symx::get_codegen_dir().
Field |
Effective default |
Description |
|---|---|---|
|
|
Name of the simulation. Used in log and frame file names. Must be set by the user. |
|
|
Directory where STARK writes logs and frame output. Must be set by the user. |
|
|
Directory used by SymX for generated and compiled code. Cached code can be reused between runs. |
|
creation time |
Timestamp string generated when |
|
|
Frame output rate in simulation frames per second. Use |
|
|
Console verbosity. Common values are |
|
|
Verbosity of the |
|
|
Enables frame writing after accepted time steps. Useful to disable heavy VTK/output callbacks while keeping the simulation and logs active. |
|
|
Enables the SymX output sink. Set to |
Simulation settings¶
Simulation settings control global physical parameters and adaptive time stepping.
The time step starts at max_time_step_size.
A successful step may grow dt up to this maximum.
A failed step halves dt and retries, unless adaptive stepping is disabled.
Field |
Effective default |
Description |
|---|---|---|
|
|
Global gravity acceleration used by STARK systems that query the simulation gravity. Can also be changed later with |
|
|
Initializes the frictional contact infrastructure. Set to |
|
|
Maximum time step size, and also the initial |
|
|
If |
|
|
Multiplicative growth factor applied to |
|
|
Minimum allowed adaptive time step. If |
Newton settings¶
settings.newton is a symx::NewtonSettings object.
These settings are passed to SymX when STARK creates the internal Newton solver during initialization.
Iteration and convergence¶
Field |
Effective default |
Description |
|---|---|---|
|
|
Maximum Newton iterations per solve. The default is effectively unlimited. |
|
|
Minimum Newton iterations before convergence is accepted. |
|
|
Absolute convergence tolerance on the nonlinear residual. |
|
|
Relative convergence tolerance on the nonlinear residual. Disabled by default. |
|
|
Convergence tolerance on the Newton step size. STARK overwrites the raw SymX default of |
|
|
If |
Line search¶
Field |
Effective default |
Description |
|---|---|---|
|
|
Maximum allowed Newton step norm. Use this to limit aggressive updates in difficult problems. |
|
|
Enables Armijo backtracking for sufficient energy decrease. |
|
|
Armijo sufficient-decrease parameter. Smaller values accept weaker agreement with the local model. |
|
|
Maximum number of Armijo backtracking iterations per Newton step. |
|
|
Maximum number of backtracking iterations caused by invalid intermediate states, such as contact penetration. |
|
|
Prints additional line-search information when a solve fails. Useful for debugging. |
Hessian projection¶
SymX can modify local Hessians to obtain a positive-definite global system for Newton-like descent directions. This is important for robust implicit time stepping, especially with nonlinear materials and contact.
Field |
Effective default |
Description |
|---|---|---|
|
|
Hessian projection strategy. STARK overwrites the raw SymX default of |
|
|
Minimum eigenvalue used by projection. |
|
|
If |
|
|
Number of iterations to continue projecting after a projection-triggering failure in |
|
|
Tightening factor used by progressive projected Newton after non-descending behavior. |
|
|
Release factor used by progressive projected Newton after successful behavior. |
Available projection modes:
Value |
Meaning |
|---|---|
|
Pure Newton. Do not project Hessians. Fast, but not guaranteed to produce descent directions for indefinite problems. |
|
Always project local Hessians to positive definite before assembly. Robust, but potentially more expensive. |
|
Start without projection and enable it after solver failures or non-descending directions. |
|
Progressively adjusts projection based on solve behavior. This is STARK’s default. |
Linear solver¶
Field |
Effective default |
Description |
|---|---|---|
|
|
Linear solver used for the Newton system. |
|
|
Maximum conjugate-gradient iterations. Used by iterative solvers. |
|
|
Absolute CG residual tolerance. |
|
|
Relative CG residual tolerance. |
|
|
Stops CG when indefiniteness is detected. This can trigger projection or failure handling depending on the projection mode. |
|
|
Skips taking a step if the nonlinear residual is already below this value, avoiding unnecessary unstable linear solves near convergence. |
Available linear solvers:
Value |
Meaning |
|---|---|
|
Block-diagonal preconditioned conjugate gradient. Default. |
|
Direct LLT solve. Useful for smaller problems or debugging. |
Execution settings¶
Execution settings control when the simulation stops and how many CPU threads are forwarded to SymX. They are independent of physical time-stepping parameters.
Field |
Effective default |
Description |
|---|---|---|
|
|
Wall-clock runtime limit in seconds. STARK stops when this limit is exceeded. |
|
|
Simulated-time limit. Commonly set in examples, e.g. |
|
|
Frame-count limit. STARK stops when the frame counter exceeds this value. |
|
|
Number of threads forwarded to the SymX context. The raw member initializer is |