14#ifndef LIBSIMINTEGRATORS_INTEGRATOR_H
15#define LIBSIMINTEGRATORS_INTEGRATOR_H
53 const double *state,
double *out_derivative,
size_t count);
68 double *out_noise,
size_t count);
243 double method_order);
258 double method_order);
310 size_t count,
double dt);
361 double *out_noise,
size_t count);
375 double *out_noise,
size_t count);
387 double *out_noise,
size_t count);
413 double *out_derivative,
size_t count);
Multidimensional contiguous field abstraction with configurable layout.
SimResult
Return codes shared by libsimcore modules.
Definition field.h:29
SimResult(* IntegratorNoiseFn)(struct Integrator *integrator, const Field *field, double *out_noise, size_t count)
Hook producing stochastic source samples.
Definition integrator.h:67
SimResult(* IntegratorDriftFn)(struct Integrator *integrator, const Field *field, const double *state, double *out_derivative, size_t count)
Drift callback computing deterministic derivatives.
Definition integrator.h:52
double integrator_last_step(const Integrator *integrator)
Retrieve the timestep used by the previous update.
double integrator_clamp_dt(const Integrator *integrator, double dt)
Clamp a timestep to configured bounds.
void integrator_apply_stochastic(Integrator *integrator, Field *field, double *scratch, size_t count, double dt)
Apply stochastic increments to the field when enabled.
size_t integrator_state_length(const Field *field)
Compute the scalar length of a field.
double integrator_reject_dt(const Integrator *integrator, double dt, double error_norm, double method_order)
Shrink a rejected timestep using the observed error when available.
double integrator_suggest_dt(const Integrator *integrator, double dt, double error_norm, double method_order)
Suggest a new timestep based on an error estimate.
void(* IntegratorDestroyFn)(struct Integrator *integrator)
Optional teardown hook for integrator-owned state.
Definition integrator.h:75
uint64_t integrator_workspace_bytes(const Integrator *integrator)
Report allocated workspace bytes owned by the integrator buffers.
SimResult integrator_context_drift(Integrator *integrator, const Field *field, const double *state, double *out_derivative, size_t count)
Drift helper evaluating the current context plan side-effect free.
void integrator_destroy(Integrator *integrator)
Release resources held by an integrator.
SimResult integrator_noise_laplace(struct Integrator *integrator, const Field *field, double *out_noise, size_t count)
Fill a buffer with zero-mean, unit-variance Laplace noise samples.
double integrator_next_step(const Integrator *integrator)
Retrieve the suggested timestep for the next call.
double integrator_last_error(const Integrator *integrator)
Retrieve the error norm reported by the last step.
double integrator_rng_normal(Integrator *integrator)
Generate a standard normal variate using the integrator RNG.
double * integrator_buffer(Integrator *integrator, size_t index)
Access a real workspace buffer.
SimField Field
Alias matching the simulation field type used by integrator APIs.
Definition integrator.h:33
SimResult integrator_noise_uniform(struct Integrator *integrator, const Field *field, double *out_noise, size_t count)
Fill a buffer with zero-mean, unit-variance uniform noise samples.
SimComplexDouble * integrator_buffer_complex(Integrator *integrator, unsigned int index)
Access a complex workspace buffer.
double integrator_measure_error(const double *a, const double *b, size_t count)
Measure scaled infinity-norm error between two real state vectors.
double integrator_measure_error_complex(const SimComplexDouble *a, const SimComplexDouble *b, size_t n)
Measure scaled RMS error between two complex state vectors.
SimResult integrator_configure(Integrator *integrator, const char *name, IntegratorStepFn step_fn, const IntegratorConfig *config)
Initialize an integrator object.
uint64_t integrator_drift_scratch_bytes(const Integrator *integrator)
Report reusable drift scratch bytes owned by the integrator.
SimResult integrator_noise_gaussian(struct Integrator *integrator, const Field *field, double *out_noise, size_t count)
Fill a buffer with zero-mean, unit-variance Gaussian noise samples.
void(* IntegratorStepFn)(struct Integrator *integrator, Field *field, double dt)
Integrator step function signature.
Definition integrator.h:88
SimResult integrator_step_context(Integrator *integrator, struct SimContext *context, struct SimBackend *backend, double dt)
Step a context-backed integrator without advancing context time.
SimResult integrator_ensure_workspace(Integrator *integrator, size_t buffers, size_t elements)
Ensure scratch buffers are available.
Configuration parameters for integrator construction.
Definition integrator.h:97
uint32_t random_seed
Definition integrator.h:111
double safety
Definition integrator.h:107
double stochastic_strength
Definition integrator.h:110
double initial_dt
Definition integrator.h:103
bool enable_stochastic
Definition integrator.h:109
bool adaptive
Definition integrator.h:108
size_t workspace_hint
Definition integrator.h:112
IntegratorNoiseFn noise
Definition integrator.h:99
double subordination_alpha
Definition integrator.h:113
void * userdata
Definition integrator.h:101
double tolerance
Definition integrator.h:106
IntegratorDriftFn drift
Definition integrator.h:98
size_t subordination_quadrature_n
Definition integrator.h:114
double min_dt
Definition integrator.h:104
IntegratorDestroyFn destroy
Definition integrator.h:100
size_t target_field_index
Definition integrator.h:102
double max_dt
Definition integrator.h:105
Integrator instance shared across schemes.
Definition integrator.h:125
double max_dt
Definition integrator.h:135
void * userdata
Definition integrator.h:131
IntegratorStepFn step
Definition integrator.h:127
size_t drift_snapshot_count
Definition integrator.h:152
bool enable_stochastic
Definition integrator.h:133
bool is_complex
Definition integrator.h:158
size_t target_field_index
Definition integrator.h:155
void * drift_state_scratch
Definition integrator.h:153
double last_step
Definition integrator.h:139
IntegratorNoiseFn noise
Definition integrator.h:129
size_t buffer_element_size
Definition integrator.h:148
IntegratorDestroyFn destroy
Definition integrator.h:130
char name[32]
Definition integrator.h:126
double split_feedback_max_error
Definition integrator.h:160
uint32_t rng_state
Definition integrator.h:142
double min_dt
Definition integrator.h:134
size_t drift_state_scratch_capacity
Definition integrator.h:154
size_t * drift_snapshot_sizes
Definition integrator.h:150
double current_dt
Definition integrator.h:138
double last_error
Definition integrator.h:140
bool adaptive
Definition integrator.h:132
size_t * drift_snapshot_capacities
Definition integrator.h:151
size_t subordination_quadrature_n
Definition integrator.h:157
uint32_t last_attempt_count
Definition integrator.h:143
double subordination_alpha
Definition integrator.h:156
double safety
Definition integrator.h:137
double ** buffers
Definition integrator.h:145
uint32_t last_rejection_count
Definition integrator.h:144
uint32_t split_feedback_substeps
Definition integrator.h:161
IntegratorDriftFn drift
Definition integrator.h:128
size_t buffer_count
Definition integrator.h:146
size_t buffer_elements
Definition integrator.h:147
double stochastic_strength
Definition integrator.h:141
double split_feedback_dt
Definition integrator.h:159
void ** drift_snapshots
Definition integrator.h:149
double tolerance
Definition integrator.h:136
Runtime backend handle shared across implementations.
Definition backend.h:115
Explicit in-memory representation for a complex double scalar (re, im)
Definition field.h:175
Simulation runtime state.
Definition sim_context.h:70
Owning multidimensional field.
Definition field.h:157