@@ -180,7 +180,11 @@ If `dt` drops below `settings.simulation.time_step_size_lower_bound`, the simula
180180Callbacks inject behavior into the solver loop.
181181Most users only need the scripting interface, but lower-level callbacks are useful when extending STARK.
182182
183+ Callbacks are accessed through ` simulation.get_callbacks() ` , which returns a reference to ` stark::Callbacks ` .
184+ That struct exposes the STARK-level methods directly, and a ` newton ` member of type ` symx::SolverCallbacks ` that carries the SymX/Newton-level hooks.
185+
183186### STARK-level callbacks
187+ These callbacks relate to time stepping.
184188
185189| Callback | When it runs | Purpose |
186190| ---| ---| ---|
@@ -194,8 +198,17 @@ Most users only need the scripting interface, but lower-level callbacks are usef
194198The frame-writing callback is how STARK's built-in output system writes registered meshes every frame.
195199The frame cadence is controlled by ` settings.output.fps ` .
196200
201+ Register a STARK-level callback via ` simulation.get_callbacks()->add_<name>(f) ` :
202+
203+ ``` cpp
204+ simulation.get_callbacks()->add_before_time_step ([ &] ( ) {
205+ // runs once before Newton starts for every time step
206+ // e.g. update step-lagged quantities
207+ });
208+ ```
209+
197210### SymX/Newton callbacks
198- Check the [ original SymX docs] ( https://symx.physics-simulation.org/newtons_method.html ) for more details.
211+ These callbacks relate to the Newton solves. Check the [original SymX docs](https://symx.physics-simulation.org/newtons_method.html) for more details.
199212
200213| Callback | When it runs | Purpose |
201214|---|---|---|
@@ -210,9 +223,19 @@ Check the [original SymX docs](https://symx.physics-simulation.org/newtons_metho
210223| `is_converged_state_valid` | after Newton reports success | verify final constraints/contact tolerances |
211224| `after_step` | at the end of each Newton iteration | per-iteration diagnostics, adaptive parameter updates |
212225
213- Boolean validity callbacks are combined with logical ` AND ` . All registered checks must pass.
214- ` max_allowed_step ` callbacks are combined by taking the smallest returned step fraction.
215- The default residual used by Newton is the infinity norm of the gradient, unless a custom residual callback is installed.
226+ Notes:
227+ - Boolean validity callbacks are combined with logical `AND`. All registered checks must pass.
228+ - `max_allowed_step` callbacks are combined by taking the smallest returned step fraction.
229+ - The default residual used by Newton is the infinity norm of the gradient, unless a custom residual callback is installed.
230+
231+ SymX/Newton callbacks live on `simulation.get_callbacks()->newton`, which is of type `symx::spSolverCallbacks` (defined in SymX):
232+
233+ ```cpp
234+ simulation.get_callbacks()->newton->add_before_energy_evaluation([&]() {
235+ // runs before every energy / gradient / Hessian evaluation inside Newton
236+ // e.g. update broad-phase collision sets
237+ });
238+ ```
216239
217240## Public scripting and control
218241
0 commit comments