Skip to content

Integration loop DR recording - #2062

Draft
excaliburtb wants to merge 4 commits into
nasa:masterfrom
excaliburtb:add_integ_job_dr_group
Draft

Integration loop DR recording#2062
excaliburtb wants to merge 4 commits into
nasa:masterfrom
excaliburtb:add_integ_job_dr_group

Conversation

@excaliburtb

Copy link
Copy Markdown
Contributor

primarily useful for debugging, we do find ourselves needing to log the intermediate steps of a multi-step integration technique (like RK4) sometimes. we usually resort to prints but this class which just extends the current DR* ones could help.

@excaliburtb
excaliburtb marked this pull request as draft March 4, 2026 21:17
}

template<typename T, typename U>
void register_integgroup_wih_mm(T & grp, const std::string & nameIn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void register_integgroup_wih_mm(T & grp, const std::string & nameIn)
void register_integgroup_with_mm(T & grp, const std::string & nameIn)

Comment on lines +90 to +91
// DRBinary::set_job_class("integration");
// DRBinary::register_group_with_mm(this, "Trick::IntegJobDRBinary");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these commented out?

@@ -0,0 +1,139 @@
#include "trick/IntegrationJobDataRecordGroup.hh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source file should match header file name

Comment on lines +6 to +25
int getStepsForIntegType(Integrator_type integ_type)
{
static int stepsPerType[User_Defined+1]{};
if(stepsPerType[Euler] == 0)
{
stepsPerType[Euler] = 1;
stepsPerType[Euler_Cromer] = 1;
stepsPerType[Nystrom_Lear_2] = 2;
stepsPerType[Runge_Kutta_2] = 2;
stepsPerType[Modified_Midpoint_4] = 3;
stepsPerType[Runge_Kutta_4] = 4;
stepsPerType[Runge_Kutta_Gill_4] = 4;
stepsPerType[Runge_Kutta_Fehlberg_45] = 6;
stepsPerType[Runge_Kutta_Fehlberg_78] = 12;
stepsPerType[ABM_Method] = 4;
stepsPerType[User_Defined] = 1;
}

return stepsPerType[integ_type];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function (and the template functions below) meant to be static/local-only?

Comment on lines +108 to +109
// DRBinary::set_job_class("integration");
// DRBinary::register_group_with_mm(this, "Trick::IntegJobDRBinary");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise

${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h
object_${TRICK_HOST_CPU}/IntegJobDRGroup.o: IntegJobDRGroup.cpp ${TRICK_HOME}/include/trick/IntegrationJobDataRecordGroup.hh \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integJobDRGroup.o needs the hdf5 flags also in the Makefile

$(OBJ_DIR)/IntegJobDRGroup.o: TRICK_CXXFLAGS += -I$(HDF5)/include
$(OBJ_DIR)/io_IntegJobDRGroup.o: TRICK_CXXFLAGS += -I$(HDF5)/include

Comment on lines +19 to +47
#ifdef SWIG
%feature("compactdefaultargs","0") ;
%feature("shadow") Trick::IntegJobDRBinary::IntegJobDRBinary(const std::string& in_name, Trick::IntegLoopScheduler& integSchedulerRefIn) %{
def __init__(self, *args):
this = $action(*args)
try: self.this.append(this)
except: self.this = this
this.own(0)
self.this.own(0)
%}

%feature("shadow") Trick::IntegJobDRAscii::IntegJobDRAscii(const std::string& in_name, Trick::IntegLoopScheduler& integSchedulerRefIn) %{
def __init__(self, *args):
this = $action(*args)
try: self.this.append(this)
except: self.this = this
this.own(0)
self.this.own(0)
%}

%feature("shadow") Trick::IntegJobDRHDF5::IntegJobDRHDF5(const std::string& in_name, Trick::IntegLoopScheduler& integSchedulerRefIn) %{
def __init__(self, *args):
this = $action(*args)
try: self.this.append(this)
except: self.this = this
this.own(0)
self.this.own(0)
%}
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be blocked in // clang-format off/on guards

Comment on lines +90 to +92
#ifdef SWIG
%feature("compactdefaultargs","1") ;
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block in // clang-format off/on guard

virtual int init(bool is_restart = false) override;
virtual int data_record(double in_time) override;

Trick::IntegLoopScheduler* integSchedulerPtr { };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this (and the other 2) need trick_io comment?

Comment on lines +6 to +25
int getStepsForIntegType(Integrator_type integ_type)
{
static int stepsPerType[User_Defined+1]{};
if(stepsPerType[Euler] == 0)
{
stepsPerType[Euler] = 1;
stepsPerType[Euler_Cromer] = 1;
stepsPerType[Nystrom_Lear_2] = 2;
stepsPerType[Runge_Kutta_2] = 2;
stepsPerType[Modified_Midpoint_4] = 3;
stepsPerType[Runge_Kutta_4] = 4;
stepsPerType[Runge_Kutta_Gill_4] = 4;
stepsPerType[Runge_Kutta_Fehlberg_45] = 6;
stepsPerType[Runge_Kutta_Fehlberg_78] = 12;
stepsPerType[ABM_Method] = 4;
stepsPerType[User_Defined] = 1;
}

return stepsPerType[integ_type];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static constexpr array instead?

Suggested change
int getStepsForIntegType(Integrator_type integ_type)
{
static int stepsPerType[User_Defined+1]{};
if(stepsPerType[Euler] == 0)
{
stepsPerType[Euler] = 1;
stepsPerType[Euler_Cromer] = 1;
stepsPerType[Nystrom_Lear_2] = 2;
stepsPerType[Runge_Kutta_2] = 2;
stepsPerType[Modified_Midpoint_4] = 3;
stepsPerType[Runge_Kutta_4] = 4;
stepsPerType[Runge_Kutta_Gill_4] = 4;
stepsPerType[Runge_Kutta_Fehlberg_45] = 6;
stepsPerType[Runge_Kutta_Fehlberg_78] = 12;
stepsPerType[ABM_Method] = 4;
stepsPerType[User_Defined] = 1;
}
return stepsPerType[integ_type];
}
int getStepsForIntegType(Integrator_type integ_type)
{
static constexpr int stepsPerType[User_Defined + 1] = {
1, // Euler
1, // Euler_Cromer
2, // Nystrom_Lear_2
2, // Runge_Kutta_2
3, // Modified_Midpoint_4
4, // Runge_Kutta_4
4, // Runge_Kutta_Gill_4
6, // Runge_Kutta_Fehlberg_45
12, // Runge_Kutta_Fehlberg_78
4, // ABM_Method
1 // User_Defined
};
return stepsPerType[integ_type];
}

@brendan-nasa brendan-nasa Aug 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my suggestion isn't any better. it fixes the potential race condition but adds ordering dependent behaviour that would need to be maintained alongside any changes to integrator interface

should really just be a switch tree with the function itself made static/constexpr

@brendan-nasa

Copy link
Copy Markdown
Contributor

and your formatting lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants