Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

Re-solve the SPARK problem with different runtime controls

After solving a problem with the runtime controls specified in the SPARK::TRuntimeControls object passed to SPARK::TProblem::Initialize(), it is possible to re-use the SPARK::TProblem instance to solve the same problem with a different set of runtime controls specified in a new SPARK::TRuntimeControls object.

For example, assuming that the names for the new *.run and *.prf files are specified in the variables RunFileName2 and RuntimeControls2, the following code snippet shows how to re-solve the same problem object pointed to by P:

    SPARK::TRuntimeControls RuntimeControls2( 
           "Runtime controls #2",   // name of controls set
           RunFileName2             // *.run file name
    );
    SPARK::TPreferenceSettings PreferenceSettings2( PrfFileName2 );
   
    P->Initialize( RuntimeControls2 );
    P->LoadPreferenceSettings( PreferenceSettings2 );
   
    if ( P->Simulate() != SPARK::TProblem::SimulatorState_OK ) {
           SPARK::ExitWithError( 
              SPARK::ExitCode_ERROR_NUMERICAL,
              __FILE__,
              "Abort simulation.",
              P // Specifiy active problem to ensure proper diagnostic
           );
    }
   
    P->Terminate();

Warning:
Before intializing the problem with the new SPARK::TRuntimeControls object, the SPARK::TProblem::Terminate() method must be invoked to ensure proper destruction of all control-specific handlers. If you fail to do this, you subject yourself to possible memory leaks.


Generated on 5 Nov 2003 for VisualSPARK 2.01