Skip to content

Commit

Permalink
Added "target_integ_time" to Integrator class. It can be useful to kn…
Browse files Browse the repository at this point in the history
…ow the integration time. (#1760)

Co-authored-by: Thomas Brain <[email protected]>
  • Loading branch information
excaliburtb and excaliburtb authored Aug 13, 2024
1 parent 446f1fa commit 26f6a02
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/trick/Integrator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ namespace Trick {
bool use_deriv2; // -- set by integration technique

double dt; // -- set by IntegLoopSimObject.cpp
double target_integ_time; // -- set by IntegLoopScheduler.cpp. Final integration time regardless of
// intermediate step.
#ifndef USE_ER7_UTILS_INTEGRATORS
double **state_origin;
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/trick/integrator_c_intf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ int integrate(void);
int integrate_1st_order_ode(const double* deriv, double* state);
int integrate_2nd_order_ode(const double* acc, double* vel, double * pos);
double get_integ_time(void);
double get_integ_dt(void);
double get_integ_target_time(void);
void set_integ_time(double time_value);
void reset_state();
#ifndef USE_ER7_UTILS_INTEGRATORS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ int Trick::IntegLoopScheduler::integrate_dt ( double t_start, double dt) {
int ex_pass = 0;
bool need_derivs = get_first_step_deriv_from_integrator();

double target_time = t_start + dt;

do {
ex_pass ++;
// Call all of the jobs in the derivative job queue if needed.
Expand Down Expand Up @@ -482,11 +484,12 @@ int Trick::IntegLoopScheduler::integrate_dt ( double t_start, double dt) {
if (ex_pass == 1) {
trick_curr_integ->time = t_start;
trick_curr_integ->dt = dt;
trick_curr_integ->target_integ_time = target_time;
}

if (verbosity || trick_curr_integ->verbosity) {
message_publish (MSG_DEBUG, "Job: %s, time: %f, dt: %f\n",
curr_job->name.c_str(), t_start, dt);
message_publish (MSG_DEBUG, "Job: %s, target_integ_time: %f, integ_time: %f, dt: %f, ipass = %d\n",
curr_job->name.c_str(), target_time, t_start, dt, ipass);
}

ipass = curr_job->call();
Expand Down
1 change: 1 addition & 0 deletions trick_source/sim_services/Integrator/src/Integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Trick::Integrator::Integrator() {
is_2nd_order_ODE_technique = 0;
use_deriv2 = 0;
dt = 0.01;
target_integ_time = dt;
state = NULL;
deriv = NULL;
deriv2 = NULL;
Expand Down
11 changes: 10 additions & 1 deletion trick_source/sim_services/Integrator/src/Integrator_C_Intf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ extern "C" int integrate_2nd_order_ode(const double* acc, double* vel, double *
}

extern "C" double get_integ_time() {
return (trick_curr_integ->time);
return (trick_curr_integ->time);
}

extern "C" double get_integ_dt(void) {
return (trick_curr_integ->dt);
}

extern "C" double get_integ_target_time(void) {
return (trick_curr_integ->target_integ_time);
}

extern "C" void set_integ_time(double time_value) {
trick_curr_integ->time = time_value;
trick_curr_integ->target_integ_time = time_value;
}

extern "C" void reset_state() {
Expand Down

0 comments on commit 26f6a02

Please sign in to comment.