Replace Python numerical kernels with native C execution
This commit is contained in:
1 parent
48da6be21c
commit
3b38f73fe0
227 files changed
+16801
-75499
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#ifndef NATIVE_KERNELS_H
|
||||
#define NATIVE_KERNELS_H
|
||||
typedef struct { double p, T, rho, u, h; } NativeGas;
|
||||
typedef struct {
|
||||
int velocity_index;
|
||||
double lower, upper;
|
||||
double lower_restitution, upper_restitution, lower_threshold, upper_threshold;
|
||||
} NativeStop;
|
||||
/* Constants are emitted per medium instance by the model compiler. */
|
||||
typedef struct { int real_helium; double R, cp, Tref, slope, mu, muT, S; } NativeMedium;
|
||||
int native_medium_init(const NativeMedium *, double p, double T, double V, int legacy_ideal_initial, double *mU);
|
||||
double native_density(const NativeMedium *, double p, double T);
|
||||
double native_temperature_ph(const NativeMedium *, double p, double h);
|
||||
double native_viscosity(const NativeMedium *, double T, int diagnostic);
|
||||
int native_medium_gas(const NativeMedium *, double m, double U, double V, NativeGas *);
|
||||
int native_medium_orifice(const NativeMedium *, double p1, double p2, double h1, double h2,
|
||||
double cq_area, double opening, double *q, double *cm, double *v);
|
||||
double native_pipe_flow(const NativeMedium *, double p1, double p2, double T,
|
||||
double diameter, double length, double roughness, int kind);
|
||||
void native_pipe_diagnostics(const NativeMedium *, double q, double p, double T,
|
||||
double diameter, double length, double roughness,
|
||||
int diagnostic, double *result);
|
||||
double native_limit_force(double penetration, double velocity, double stiffness,
|
||||
double damping, double depth, int signed_force);
|
||||
int native_gas_init(double p, double T, double volume, double *mU);
|
||||
int native_gas(double m, double U, double volume, NativeGas *gas);
|
||||
int native_orifice(double p1, double p2, double h1, double h2,
|
||||
double cq_area, double opening, double *flow,
|
||||
double *cm, double *velocity);
|
||||
double native_contact(double penetration, double velocity, double stiffness,
|
||||
double damping, double pdis, int signed_force);
|
||||
void native_stop_motion(double x, double v, double lower, double upper,
|
||||
double *acceleration, double *velocity);
|
||||
double native_signal(double t, double start, int stages, int cyclic, const double *data);
|
||||
double native_signal_break(double t, double end, double start, int stages,
|
||||
int cyclic, const double *data);
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef NATIVE_RUNTIME_H
|
||||
#define NATIVE_RUNTIME_H
|
||||
#include "model.h"
|
||||
#include <stddef.h>
|
||||
typedef struct {
|
||||
double start, stop, sample_step, max_step, rtol, timeout;
|
||||
int bdf, record_samples;
|
||||
const char *cancel_path;
|
||||
} NativeOptions;
|
||||
typedef struct {
|
||||
NativeOptions options;
|
||||
double *times, *states;
|
||||
size_t count, capacity, sample_index;
|
||||
double final_time, final_state[NSTATES];
|
||||
double wall_start, cpu_start, solve_seconds, solve_cpu_seconds, last_progress;
|
||||
double max_accepted_step;
|
||||
unsigned long nfev, accepted, rejected, events, starts, njev, nlu;
|
||||
int status; /* 0 completed, 1 cancelled, 2 failed */
|
||||
const char *message;
|
||||
} NativeRun;
|
||||
typedef int (*NativeDense)(void *context, double t, double *state);
|
||||
double native_wall_time(void);
|
||||
double native_cpu_time(void);
|
||||
int native_poll(NativeRun *run, double time);
|
||||
int native_rhs(NativeRun *run, double t, const double *y, double *dy);
|
||||
int native_append(NativeRun *run, double t, const double *y);
|
||||
int native_accept(NativeRun *run, double t, double next, const double *old,
|
||||
const double *trial, NativeDense dense, void *context,
|
||||
double *accepted_time, double *accepted_state);
|
||||
int native_rk45(NativeRun *run);
|
||||
int native_bdf(NativeRun *run);
|
||||
int native_solve(NativeRun *run);
|
||||
void native_run_free(NativeRun *run);
|
||||
#endif
|
||||
Reference in new issue
Block a user