Integration loop DR recording - #2062
Conversation
…the swig thisown override for some reason.
| } | ||
|
|
||
| template<typename T, typename U> | ||
| void register_integgroup_wih_mm(T & grp, const std::string & nameIn) |
There was a problem hiding this comment.
| void register_integgroup_wih_mm(T & grp, const std::string & nameIn) | |
| void register_integgroup_with_mm(T & grp, const std::string & nameIn) |
| // DRBinary::set_job_class("integration"); | ||
| // DRBinary::register_group_with_mm(this, "Trick::IntegJobDRBinary"); |
There was a problem hiding this comment.
Why are these commented out?
| @@ -0,0 +1,139 @@ | |||
| #include "trick/IntegrationJobDataRecordGroup.hh" | |||
There was a problem hiding this comment.
source file should match header file name
| 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]; | ||
| } |
There was a problem hiding this comment.
Is this function (and the template functions below) meant to be static/local-only?
| // DRBinary::set_job_class("integration"); | ||
| // DRBinary::register_group_with_mm(this, "Trick::IntegJobDRBinary"); |
| ${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 \ |
There was a problem hiding this comment.
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| #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 |
There was a problem hiding this comment.
should be blocked in // clang-format off/on guards
| #ifdef SWIG | ||
| %feature("compactdefaultargs","1") ; | ||
| #endif |
There was a problem hiding this comment.
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 { }; |
There was a problem hiding this comment.
does this (and the other 2) need trick_io comment?
| 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]; | ||
| } |
There was a problem hiding this comment.
static constexpr array instead?
| 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]; | |
| } |
There was a problem hiding this comment.
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
|
and your formatting lol |
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.