Skip to content

Commit

Permalink
Provide mode flag to ResetToInitialConditions() to skip the execution…
Browse files Browse the repository at this point in the history
… of RunIC() (#466)
  • Loading branch information
seanmcleod authored and bcoconni committed Jul 10, 2021
1 parent 46800dd commit 14beeb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/FGFDMExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ void FGFDMExec::ResetToInitialConditions(int mode)
{
if (Constructing) return;

if (mode == 1) Output->SetStartNewOutput();
// mode flags

if (mode & START_NEW_OUTPUT) Output->SetStartNewOutput();

InitializeModels();

Expand All @@ -613,7 +615,8 @@ void FGFDMExec::ResetToInitialConditions(int mode)
else
Setsim_time(0.0);

RunIC();
if (!(mode & DONT_EXECUTE_RUN_IC))
RunIC();
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
11 changes: 8 additions & 3 deletions src/FGFDMExec.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,15 @@ class FGFDMExec : public FGJSBBase
void Resume(void) {holding = false;}
/// Returns true if the simulation is Holding (i.e. simulation time is not moving).
bool Holding(void) {return holding;}
/// Mode flags for ResetToInitialConditions
static const int START_NEW_OUTPUT = 0x1;
static const int DONT_EXECUTE_RUN_IC = 0x2;
/** Resets the initial conditions object and prepares the simulation to run
again. If mode is set to 1 the output instances will take special actions
such as closing the current output file and open a new one with a
different name.
again. If the mode's first bit is set the output instances will take special actions
such as closing the current output file and open a new one with a different name.
If the second bit is set then RunIC() won't be executed, leaving it to the caller
to call RunIC(), e.g. in case the caller wants to set some other state like control
surface deflections which would've been reset.
@param mode Sets the reset mode.*/
void ResetToInitialConditions(int mode);
/// Sets the debug level.
Expand Down

0 comments on commit 14beeb7

Please sign in to comment.