Changeset 22981


Ignore:
Timestamp:
2014-10-27T15:37:35+01:00 (10 years ago)
Author:
nimen
Message:

Cleanup of Cpp Runtime files

Location:
trunk/SimulationRuntime/cpp/Include
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/SimulationRuntime/cpp/Include/Core/HistoryImpl.h

    r22024 r22981  
    1212template< template <size_t,size_t,size_t,size_t>  class ResultsPolicy,size_t dim_1, size_t dim_2,size_t dim_3,size_t dim_4>
    1313class HistoryImpl: public IHistory,
    14     public ResultsPolicy<dim_1,dim_2,dim_3,dim_4>
     14  public ResultsPolicy<dim_1,dim_2,dim_3,dim_4>
    1515{
    1616public:
     17  HistoryImpl(IGlobalSettings& globalSettings)
     18    :ResultsPolicy<dim_1,dim_2,dim_3,dim_4>((globalSettings.getEndTime()-globalSettings.getStartTime())/globalSettings.gethOutput(),globalSettings.getOutputPath(),globalSettings.getResultsFileName())
     19    ,_globalSettings(globalSettings)
     20  {
     21  }
    1722
    18   HistoryImpl(IGlobalSettings& globalSettings)
    19   :ResultsPolicy<dim_1,dim_2,dim_3,dim_4>((globalSettings.getEndTime()-globalSettings.getStartTime())/globalSettings.gethOutput(),globalSettings.getOutputPath(),globalSettings.getResultsFileName())
    20   ,_globalSettings(globalSettings)
    21   {
     23  void setOutputs(map<unsigned int,string> var_outputs)
     24  {
     25    _var_outputs=var_outputs;
     26  }
    2227
    23     }
     28  void init()
     29  {
     30    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::init(_globalSettings.getOutputPath(), _globalSettings.getResultsFileName());
     31  }
    2432
    25     void setOutputs(map<unsigned int,string> var_outputs)
    26     {
    27         _var_outputs=var_outputs;
     33  virtual void getOutputNames(vector<string>& output_names)
     34  {
     35    boost::copy(_var_outputs | boost::adaptors::map_values, std::back_inserter(output_names));
     36  }
    2837
     38  void getSimResults(const double time, ublas::vector<double>& v, ublas::vector<double>& dv)
     39  {
     40    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(time,v,dv);
     41  }
    2942
    30     }
    31     void init()
    32     {
    33         ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::init(_globalSettings.getOutputPath(),_globalSettings.getResultsFileName());
    34     }
    35     virtual void getOutputNames(vector<string>& output_names)
    36     {
     43  void getSimResults(ublas::matrix<double>& R, ublas::matrix<double>& dR)
     44  {
     45    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(R,dR);
     46  }
    3747
    38         boost::copy(_var_outputs | boost::adaptors::map_values, std::back_inserter(output_names));
     48  void getSimResults(ublas::matrix<double>& R, ublas::matrix<double>& dR, ublas::matrix<double>& Re)
     49  {
     50    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(R, dR, Re);
     51  }
    3952
    40     }
     53  virtual void getOutputResults(ublas::matrix<double>& Ro)
     54  {
     55    vector<unsigned int> ids;
     56    boost::copy(_var_outputs | boost::adaptors::map_keys, std::back_inserter(ids));
     57    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(Ro,ids);
     58  }
    4159
    42     void getSimResults(const double time,ublas::vector<double>& v,ublas::vector<double>& dv)
    43     {
    44         ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(time,v,dv);
     60  unsigned long getSize()
     61  {
     62    return  ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::size();
     63  }
     64 
     65  unsigned long getDimRe()
     66  {
     67    return dim_3;
     68  }
    4569
    46     }
     70  unsigned long getDimdR()
     71  {
     72    return  dim_2;
     73  }
    4774
     75  unsigned long getDimR()
     76  {
     77    return  dim_1;
     78  }
    4879
    49     void getSimResults(ublas::matrix<double>& R,ublas::matrix<double>& dR)
    50     {
     80  vector<double> getTimeEntries()
     81  {
     82    vector<double> time;
     83    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::getTime(time);
     84    return time;
     85  }
    5186
    52         ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(R,dR);
     87  void clear()
     88  {
     89    ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::eraseAll();
     90  };
    5391
    54     }
    55 
    56     void getSimResults(ublas::matrix<double>& R,ublas::matrix<double>& dR,ublas::matrix<double>& Re)
    57     {
    58 
    59         ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(R,dR,Re);
    60 
    61     }
    62 
    63     virtual void getOutputResults(ublas::matrix<double>& Ro)
    64     {
    65         vector<unsigned int> ids;
    66         boost::copy(_var_outputs | boost::adaptors::map_keys, std::back_inserter(ids));
    67         ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::read(Ro,ids);
    68     }
    69 
    70     unsigned long getSize()
    71     {
    72         return  ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::size();
    73     }
    74 
    75 
    76     unsigned long getDimRe()
    77     {
    78         return dim_3;
    79     }
    80 
    81 
    82     unsigned long getDimdR()
    83     {
    84         return  dim_2;
    85     }
    86 
    87 
    88 
    89     unsigned long getDimR()
    90     {
    91         return  dim_1;
    92     }
    93 
    94 
    95     vector<double> getTimeEntries()
    96     {
    97         vector<double> time;
    98         ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::getTime(time);
    99         return time;
    100     }
    101 
    102     void clear()
    103     {
    104        ResultsPolicy<dim_1,dim_2,dim_3,dim_4>::eraseAll();
    105     };
    10692private:
    107     //map of indices of all output variables
    108     map<unsigned int,string> _var_outputs;
    109     IGlobalSettings& _globalSettings;
    110 
     93  //map of indices of all output variables
     94  map<unsigned int,string> _var_outputs;
     95  IGlobalSettings& _globalSettings;
    11196};
  • trunk/SimulationRuntime/cpp/Include/Core/Modelica/ModelicaSystem.h

    r22400 r22981  
    1616*****************************************************************************/
    1717
     18class Modelica: public IMixedSystem ,public IContinuous ,public IEvent ,public ISystemProperties, public SystemDefaultImplementation
     19{
     20  public:
    1821
     22    Modelica(IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> nonlinsolverfactory,boost::shared_ptr<ISimData>);
    1923
    20 class Modelica: public IMixedSystem ,public IContinuous ,public IEvent ,public ISystemProperties, public SystemDefaultImplementation
    21  {
    22       public:
     24  ~Modelica();
    2325
    24       Modelica(IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> nonlinsolverfactory,boost::shared_ptr<ISimData>);
     26  //Releases the Modelica System
     27  virtual void destroy();
    2528
    26   ~Modelica();
     29  // Geerbt von IContinuous
     30  //////////////////////////////////////////////////
     31  virtual int getDimBoolean() const;
    2732
    28   //Releases the Modelica System
    29    virtual void destroy();
     33  /// Provide number (dimension) of states
     34  virtual int getDimContinuousStates() const;
    3035
    31    // Geerbt von IContinuous
    32    //////////////////////////////////////////////////
    33    virtual int getDimBoolean() const;
     36  /// Provide number (dimension) of integer variables
     37    virtual int getDimInteger() const;
    3438
    35    /// Provide number (dimension) of states
    36    virtual int getDimContinuousStates() const;
     39    /// Provide number (dimension) of real variables
     40    virtual int getDimReal() const;
    3741
    38       /// Provide number (dimension) of integer variables
    39       virtual int getDimInteger() const;
     42    /// Provide number (dimension) of string variables
     43    virtual int getDimString() const;
    4044
    41       /// Provide number (dimension) of real variables
    42       virtual int getDimReal() const;
     45    /// Provide number (dimension) of right hand sides (equations and/or residuals) according to the index
     46    virtual int getDimRHS() const;
    4347
    44       /// Provide number (dimension) of string variables
    45       virtual int getDimString() const;
     48    /// Provide boolean variables
     49    virtual void getBoolean(bool* z);
    4650
    47       /// Provide number (dimension) of right hand sides (equations and/or residuals) according to the index
    48       virtual int getDimRHS() const;
     51    /// Provide boolean variables
     52    virtual void getContinuousStates(double* z);
    4953
     54    /// Provide integer variables
     55    virtual void getInteger(int* z);
    5056
    51       /// Provide boolean variables
    52       virtual void getBoolean(bool* z);
     57    /// Provide real variables
     58    virtual void getReal(double* z);
    5359
    54       /// Provide boolean variables
    55       virtual void getContinuousStates(double* z);
     60    /// Provide real variables
     61    virtual void getString(std::string* z);
    5662
    57       /// Provide integer variables
    58       virtual void getInteger(int* z);
     63    /// Provide the right hand side
     64    virtual void getRHS(double* f);
    5965
    60       /// Provide real variables
    61       virtual void getReal(double* z);
     66    /// Provide boolean variables
     67    virtual void setBoolean(const bool* z);
    6268
    63       /// Provide real variables
    64       virtual void getString(std::string* z);
     69    /// Provide boolean variables
     70    virtual void setContinuousStates(const double* z);
    6571
    66       /// Provide the right hand side
    67       virtual void getRHS(double* f);
     72    /// Provide integer variables
     73    virtual void setInteger(const int* z);
    6874
     75    /// Provide real variables
     76    virtual void setReal(const double* z);
    6977
    70       /// Provide boolean variables
    71       virtual void setBoolean(const bool* z);
     78    /// Provide real variables
     79    virtual void setString(const std::string* z);
    7280
    73       /// Provide boolean variables
    74       virtual void setContinuousStates(const double* z);
     81    /// Provide the right hand side
     82    virtual void setRHS(const double* f);
    7583
    76       /// Provide integer variables
    77       virtual void setInteger(const int* z);
     84    // Update transfer behavior of the system of equations according to command given by solver
     85  virtual bool evaluateAll(const UPDATETYPE command = IContinuous::UNDEF_UPDATE);
     86    virtual void evaluateODE(const UPDATETYPE command = IContinuous::UNDEF_UPDATE);
     87  virtual void evaluateZeroFuncs(const UPDATETYPE command = IContinuous::UNDEF_UPDATE);
    7888
    79       /// Provide real variables
    80       virtual void setReal(const double* z);
     89  //Resets all time events
     90  virtual void resetTimeEvents();
    8191
    82       /// Provide real variables
    83       virtual void setString(const std::string* z);
     92  //Set current integration time
     93  virtual void setTime(const double& t);
    8494
    85       /// Provide the right hand side
    86       virtual void setRHS(const double* f);
     95  // Provide Jacobian
     96  virtual void getJacobian(SparseMatrix& matrix);
     97  virtual void getStateSetJacobian(SparseMatrix& matrix);
     98  // Provide number (dimension) of zero functions
     99  virtual int getDimZeroFunc() ;
    87100
    88       // Update transfer behavior of the system of equations according to command given by solver
    89    virtual bool evaluateAll(const UPDATETYPE command = IContinuous::UNDEF_UPDATE);
    90     virtual void evaluateODE(const UPDATETYPE command = IContinuous::UNDEF_UPDATE);
    91    virtual void evaluateZeroFuncs(const UPDATETYPE command =IContinuous::UNDEF_UPDATE);
     101  // Provides current values of root/zero functions
     102  virtual void getZeroFunc(double* f);
     103  virtual bool checkConditions();
     104  virtual void getConditions(bool* c);
    92105
     106  //Called to handle all  events occured at same time
     107  virtual bool handleSystemEvents( bool* events);
     108  //Called to handle an event
     109  virtual void handleEvent(const bool* events);
    93110
    94   //Resets all time events
    95    virtual void resetTimeEvents();
     111  //Checks if a discrete variable has changed and triggers an event
     112  virtual bool checkForDiscreteEvents();
    96113
    97   //Set current integration time
    98    virtual void setTime(const double& t);
     114  // M is regular
     115  virtual bool isODE();
    99116
     117  // M is singular
     118  virtual bool isAlgebraic();
    100119
     120  // System is able to provide the Jacobian symbolically
     121  virtual bool provideSymbolicJacobian();
     122  virtual void saveDiscreteVars();
     123  virtual bool stepCompleted(double time);
    101124
     125private:
     126  //Methods:
     127  //Saves all variables before an event is handled, is needed for the pre, edge and change operator
     128  void saveAll();
    102129
    103 
    104 
    105   // Provide Jacobian
    106    virtual void getJacobian(SparseMatrix& matrix);
    107    virtual void getStateSetJacobian(SparseMatrix& matrix);
    108   // Provide number (dimension) of zero functions
    109    virtual int getDimZeroFunc() ;
    110 
    111   // Provides current values of root/zero functions
    112    virtual void getZeroFunc(double* f);
    113    virtual bool checkConditions();
    114    virtual void getConditions(bool* c);
    115 
    116    //Called to handle all  events occured at same time
    117    virtual bool handleSystemEvents( bool* events);
    118   //Called to handle an event
    119    virtual void handleEvent(const bool* events);
    120 
    121   //Checks if a discrete variable has changed and triggers an event
    122    virtual bool checkForDiscreteEvents();
    123 
    124 
    125 
    126   // M is regular
    127    virtual bool isODE();
    128 
    129   // M is singular
    130    virtual bool isAlgebraic();
    131 
    132   // System is able to provide the Jacobian symbolically
    133    virtual bool provideSymbolicJacobian() ;
    134    virtual void saveDiscreteVars();
    135    virtual bool stepCompleted(double time);
    136 private:
    137 
    138   //Methods:
    139   //Saves all variables before an event is handled, is needed for the pre, edge and change operator
    140   void saveAll();
    141 
    142    void resetHelpVar(const int index);
    143 
     130  void resetHelpVar(const int index);
    144131};
  • trunk/SimulationRuntime/cpp/Include/Core/SimController/Configuration.h

    r22025 r22981  
    22#include <SimCoreFactory/Policies/FactoryPolicy.h>
    33
    4 
    5 
    6 class Configuration :  public ConfigurationPolicy
     4class Configuration : public ConfigurationPolicy
    75{
    86public:
     
    1311    ISolverSettings* getSolverSettings();
    1412    ISimControllerSettings* getSimControllerSettings();
     13 
    1514private:
    16 
    1715     boost::shared_ptr<ISettingsFactory> _settings_factory;
    18      boost::shared_ptr<ISolverSettings>  _solver_settings;
    19      boost::shared_ptr<IGlobalSettings>  _global_settings;
    20      boost::shared_ptr<ISimControllerSettings>  _simcontroller_settings;
     16     boost::shared_ptr<ISolverSettings> _solver_settings;
     17     boost::shared_ptr<IGlobalSettings> _global_settings;
     18     boost::shared_ptr<ISimControllerSettings> _simcontroller_settings;
    2119     boost::shared_ptr<ISolver> _solver;
    22 
    2320};
  • trunk/SimulationRuntime/cpp/Include/Core/SimController/ISimController.h

    r22917 r22981  
    3636class ISimController
    3737{
    38 
    3938public:
    4039  /// Enumeration to control the time integration
     
    4241#if defined(__vxworks) || defined(__TRICORE__)
    4342#else
    44   virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey)=0;
     43  virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey) = 0;
    4544#endif
    46   virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadSystem(string modelLib,string modelKey) = 0;
    47   virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadModelicaSystem(PATH modelica_path,string modelKey) = 0;
     45  virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(string modelLib, string modelKey) = 0;
     46  virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadModelicaSystem(PATH modelica_path,string modelKey) = 0;
    4847
    49   /*
    50   Starts the simulation
    51   modelKey: Modelica model name
    52   modelica_path: path to Modelica system dll
    53   */
     48  // Starts the simulation; modelKey: Modelica model name; modelica_path: path to Modelica system dll
    5449  virtual void Start(boost::shared_ptr<IMixedSystem> mixedsystem, SimSettings simsettings, string modelKey)=0;
    55 
     50  // Stops the simulation
     51  virtual void Stop() = 0;
     52 
     53  // Functions for realtime-usage (VxWorks and BODAS)
    5654  virtual void StartVxWorks(boost::shared_ptr<IMixedSystem> mixedsystem, SimSettings simsettings) = 0;
    5755  virtual boost::shared_ptr<ISimData> getSimData(string modelname) = 0;
    5856  virtual void calcOneStep() = 0;
    59 
    60   /// Stops the simulation
    61   virtual void Stop() = 0;
    6257};
  • trunk/SimulationRuntime/cpp/Include/Core/SimController/ISimData.h

    r22903 r22981  
    1818  virtual ISimVar* Get(std::string key) = 0;
    1919  //Adds Results for an output var to simdata object
    20   virtual void addOutputResults(std::string name,uBlas::vector<double> v) = 0;
     20  virtual void addOutputResults(std::string name, uBlas::vector<double> v) = 0;
    2121  //Returns reference to results for an output var, when simData object is destroyed results are no longer valid
    22   virtual void getOutputResults(std::string name,uBlas::vector<double>& v) = 0;
     22  virtual void getOutputResults(std::string name, uBlas::vector<double>& v) = 0;
    2323  //Clears all output var results
    2424  virtual void clearResults() = 0;
    25   //Return the time intervall
     25  //Returns the time interval
    2626  virtual void getTimeEntries(std::vector<double>& time_entries) = 0;
    2727  virtual void addTimeEntries(std::vector<double> time_entries) = 0;
  • trunk/SimulationRuntime/cpp/Include/Core/SimController/Initialization.h

    r22025 r22981  
    88{
    99public:
    10       Initialization(boost::shared_ptr<ISystemInitialization> system_initialization,boost::shared_ptr<ISolver>  );
     10      Initialization(boost::shared_ptr<ISystemInitialization> system_initialization,boost::shared_ptr<ISolver>);
    1111      ~Initialization(void);
    1212      void initializeSystem(/*double start_time, double end_time*/);
     13   
    1314private:
    14 
    1515      boost::shared_ptr<ISystemInitialization> _system;
    16     boost::shared_ptr<ISolver>                  _solver;
     16    boost::shared_ptr<ISolver> _solver;
    1717};
    1818
  • trunk/SimulationRuntime/cpp/Include/Core/SimController/SimController.h

    r22904 r22981  
    2121#if defined(__vxworks) || defined(__TRICORE__)
    2222#else
    23     virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey);
     23    virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), string modelKey);
    2424#endif
    2525    virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > LoadModelicaSystem(PATH modelica_path, string modelKey);
     
    2929    virtual void Stop();
    3030
     31  // for real-time usage (VxWorks and BODAS) 
    3132    virtual boost::shared_ptr<ISimData> getSimData(string modelname);
    3233    virtual void StartVxWorks(boost::shared_ptr<IMixedSystem> mixedsystem, SimSettings simsettings);
     
    4041    boost::shared_ptr<IAlgLoopSolverFactory> _algloopsolverfactory;
    4142
     43  // for real-time usage (VxWorks and BODAS)
    4244    boost::shared_ptr<SimManager> _simMgr;
    4345
  • trunk/SimulationRuntime/cpp/Include/Core/SimController/SimManager.h

    r22903 r22981  
    3030{
    3131public:
    32     SimManager(boost::shared_ptr<IMixedSystem> system,Configuration* _config);
     32    SimManager(boost::shared_ptr<IMixedSystem> system, Configuration* _config);
    3333    ~SimManager();
    3434    void runSimulation();
    3535    void initialize();
    36   void runSingleStep();
     36 
     37  // for real-time usage (VxWorks and BODAS)
     38  void runSingleStep();
    3739
    3840private:
    39 
    40 
    4141    void computeEndTimes(std::vector<std::pair<double,int> > &tStopsSub);
    4242    void runSingleProcess();
     
    4646    Configuration* _config;
    4747
    48 
    49 
    50     std::vector<std::vector<std::pair<double,int> > >                  ///<             - Stopzeitpunkte aufgrund von Time-Events
    51         _tStops;
    52     boost::shared_ptr<ISolver>                  _solver;            ///<             - Solver
    53 
    54 
    55     int            _dimtimeevent,      ///< Temp                  - Timeevent-Dimensionen-Array
    56             _dimZeroFunc;                              ///< Number of zero functions
    57     int*      _timeeventcounter;      ///< Temp                  - Timeevent-Counter-Array
    58     int
    59         _totStps,                        ///< Output                  - Anzahl steps der Prozesse
    60         _accStps,                        ///< Output                  - Anzahl akzeptierte steps der Prozesse
    61         _rejStps;                        ///< Output                  - Anzahl verworfene steps der Prozesse
    62 
    63     ISolver::SOLVERCALL                  _solverTask;                  ///< Temporary            - Beschreibt die Aufgabe mit der der Solver aufgerufen wird
    64 
    65     int
    66             _idid;                              ///< Output                  - DebugID
    67     bool
    68         _continueSimulation                        ///<       - Flag für Endlossimulation (wird gesetzt, wenn Solver zurückkehrt)
    69         ,_writeFinalState;                        ///< Temporary            - Ist am Ende noch ein Time-Event???
    70     bool*
    71         _events;                                    ///< Vector (of dimension _dimZeroF) indicating which zero function caused an event
    72     double
    73     _H,                                    ///< Input, Output      - Koppelschrittweite
    74         _tStart,
    75         _tEnd;
    76       boost::shared_ptr<Initialization> _initialization;
     48    std::vector<std::vector<std::pair<double,int> > >   _tStops;  ///< - Stopzeitpunkte aufgrund von Time-Events       
     49    boost::shared_ptr<ISolver>      _solver;      ///<             - Solver
     50  int                       _dimtimeevent,    ///< Temp        - Timeevent-Dimensionen-Array
     51                    _dimZeroFunc;     ///<       - Number of zero functions
     52    int*                    _timeeventcounter;  ///< Temp        - Timeevent-Counter-Array
     53    int                 _totStps,           ///< Output      - Anzahl Steps der Prozesse
     54                    _accStps,     ///< Output      - Anzahl akzeptierte Steps der Prozesse
     55                    _rejStps;     ///< Output      - Anzahl verworfene steps der Prozesse
     56    ISolver::SOLVERCALL         _solverTask;    ///< Temporary   - Beschreibt die Aufgabe mit der der Solver aufgerufen wird
     57    int                 _idid;        ///< Output    - DebugID
     58    bool                _continueSimulation,///<         - Flag für Endlossimulation (wird gesetzt, wenn Solver zurückkehrt)
     59                    _writeFinalState;   ///< Temporary   - Ist am Ende noch ein Time-Event???
     60    bool*               _events;      ///<       - Vector (of dimension _dimZeroF) indicating which zero function caused an event
     61    double                _H,                 ///< Input, Output - Koppelschrittweite
     62                    _tStart,
     63                    _tEnd;
     64    boost::shared_ptr<Initialization>   _initialization;
    7765};
  • trunk/SimulationRuntime/cpp/Include/Core/SimulationSettings/Factory.h

    r22025 r22981  
    1313{
    1414public:
    15    SettingsFactory(PATH libraries_path,PATH config_path,PATH modelicasystem_path);
    16    virtual boost::shared_ptr<ISolverSettings>  createSelectedSolverSettings();
    17   virtual boost::shared_ptr<IGlobalSettings> createSolverGlobalSettings();
    18   ~SettingsFactory(void);
     15  SettingsFactory(PATH libraries_path, PATH config_path, PATH modelicasystem_path);
     16  virtual boost::shared_ptr<ISolverSettings> createSelectedSolverSettings();
     17  virtual boost::shared_ptr<IGlobalSettings> createSolverGlobalSettings();
     18  ~SettingsFactory(void);
     19 
    1920private:
    2021    boost::shared_ptr<IGlobalSettings> _global_settings;
    2122    boost::shared_ptr<ISolverSettings> _solver_settings;
    22 
    2323};
  • trunk/SimulationRuntime/cpp/Include/Core/SimulationSettings/GlobalSettings.h

    r22025 r22981  
    11#pragma once
    2 
    3 
    42#include <fstream>
    53
    6 class  GlobalSettings : public IGlobalSettings
     4class GlobalSettings : public IGlobalSettings
    75{
    8 
    96public:
    107    GlobalSettings(void);
     
    2219    virtual bool getResultsOutput();
    2320    virtual void setResultsOutput(bool);
    24     ///< Write out statistical simulation infos, e.g. number of steps (at the end of simulation); [false,true]; default: true)
     21    ///< Write out statistical simulation infos, e.g. number of steps (at the end of simulation); [false, true]; default: true)
    2522    virtual bool getInfoOutput();
    2623    virtual void setInfoOutput(bool);
     
    2825    virtual void useEndlessSim(bool);
    2926    ///path for simulation results in textfile
    30     virtual string    getOutputPath();
     27    virtual string getOutputPath();
    3128    virtual void setOutputPath(string);
    3229    virtual OutputFormat getOutputFormat();
    3330    virtual void setOutputFormat(OutputFormat format);
    34 
    3531    virtual OutputPointType getOutputPointType();
    3632    virtual void setOutputPointType(OutputPointType);
    37 
    38      virtual LogType getLogType();
     33    virtual LogType getLogType();
    3934    virtual void setLogType(LogType);
    4035
    4136    //solver used for simulation
    42     virtual string    getSelectedSolver();
     37    virtual string getSelectedSolver();
    4338    virtual void setSelectedSolver(string);
    44     virtual string    getSelectedNonLinSolver();
     39    virtual string getSelectedNonLinSolver();
    4540    virtual void setSelectedNonLinSolver(string);
    46     virtual string    getSelectedLinSolver();
     41    virtual string getSelectedLinSolver();
    4742    virtual void setSelectedLinSolver(string);
    4843    virtual void setResultsFileName(string);
     
    5449    virtual void setAlarmTime(unsigned int);
    5550    virtual unsigned int getAlarmTime();
     51 
    5652private:
    5753    double
     
    5955        _endTime,///< End time of integraiton (default: 1.0)
    6056        _hOutput;//< Output step size (default: 20 ms)
    61 
    6257    bool
    6358        _resultsOutput,   ///< Write out results ([false,true]; default: true)
     
    7570    LogType _log_type;
    7671    unsigned int _alarm_time;
    77 
    78 
    7972};
  • trunk/SimulationRuntime/cpp/Include/Core/SimulationSettings/IGlobalSettings.h

    r22562 r22981  
    1818#endif
    1919
    20 enum OutputFormat {CSV, MAT, EMPTY} ;
    21 enum LogType {OFF,STATS, NLS, ODE} ;
    22 enum OutputPointType {ALL,STEP,EMPTY2} ;
     20enum OutputFormat {CSV, MAT, EMPTY};
     21enum LogType {OFF, STATS, NLS, ODE};
     22enum OutputPointType {ALL, STEP, EMPTY2};
    2323class IGlobalSettings
    2424{
    25 
    2625public:
    27     virtual  ~IGlobalSettings() {}
     26    virtual ~IGlobalSettings() {}
    2827    ///< Start time of integration (default: 0.0)
    29     virtual double getStartTime()=0;
    30     virtual void setStartTime(double)=0;
    31     ///< End time of integraiton (default: 1.0)
    32     virtual double getEndTime()=0;
    33     virtual void setEndTime(double)=0;
     28    virtual double getStartTime() = 0;
     29    virtual void setStartTime(double) = 0;
     30    ///< End time of integration (default: 1.0)
     31    virtual double getEndTime() = 0;
     32    virtual void setEndTime(double) = 0;
    3433    ///< Output step size (default: 20 ms)
    35     virtual double gethOutput()=0;
    36     virtual void sethOutput(double)=0;
     34    virtual double gethOutput() = 0;
     35    virtual void sethOutput(double) = 0;
    3736    ///< Write out results ([false,true]; default: true)
    38     virtual bool getResultsOutput()=0;
    39     virtual void setResultsOutput(bool)=0;
     37    virtual bool getResultsOutput() = 0;
     38    virtual void setResultsOutput(bool) = 0;
    4039    virtual OutputFormat getOutputFormat() = 0;
    4140    virtual void setOutputFormat(OutputFormat) = 0;
     
    4443    virtual LogType getLogType() = 0;
    4544    virtual void setLogType(LogType) = 0;
    46      virtual void setAlarmTime(unsigned int) = 0;
     45    virtual void setAlarmTime(unsigned int) = 0;
    4746    virtual unsigned int getAlarmTime() = 0;
    4847
    49     virtual bool useEndlessSim()=0;
    50     virtual void useEndlessSim(bool)=0;
     48    virtual bool useEndlessSim() = 0;
     49    virtual void useEndlessSim(bool) = 0;
    5150    ///< Write out statistical simulation infos, e.g. number of steps (at the end of simulation); [false,true]; default: true)
    52     virtual bool getInfoOutput()=0;
    53     virtual void setInfoOutput(bool)=0;
    54     virtual string    getOutputPath() =0;
    55     virtual void setOutputPath(string)=0;
    56     virtual string    getSelectedSolver()=0;
    57     virtual void setSelectedSolver(string)=0;
    58     virtual string    getSelectedLinSolver()=0;
    59     virtual void setSelectedLinSolver(string)=0;
    60     virtual string    getSelectedNonLinSolver()=0;
    61     virtual void setSelectedNonLinSolver(string)=0;
    62     virtual void load(std::string xml_file)=0;
    63   virtual void setResultsFileName(string)=0;
    64   virtual string getResultsFileName()=0;
    65   virtual void setRuntimeLibrarypath(string)=0;
    66   virtual string getRuntimeLibrarypath()=0;
     51    virtual bool getInfoOutput() = 0;
     52    virtual void setInfoOutput(bool) = 0;
     53    virtual string getOutputPath() = 0;
     54    virtual void setOutputPath(string)= 0;
     55    virtual string getSelectedSolver() = 0;
     56    virtual void setSelectedSolver(string) = 0;
     57    virtual string getSelectedLinSolver() = 0;
     58    virtual void setSelectedLinSolver(string) = 0;
     59    virtual string getSelectedNonLinSolver() = 0;
     60    virtual void setSelectedNonLinSolver(string) = 0;
     61    virtual void load(std::string xml_file) = 0;
     62  virtual void setResultsFileName(string) = 0;
     63  virtual string getResultsFileName() = 0;
     64  virtual void setRuntimeLibrarypath(string) = 0;
     65  virtual string getRuntimeLibrarypath() = 0;
    6766};
  • trunk/SimulationRuntime/cpp/Include/Core/SimulationSettings/ISettingsFactory.h

    r22024 r22981  
    11#pragma once
    2 
    32#include <Core/Solver/ISolverSettings.h>
    43
     
    87  ISettingsFactory() {};
    98  virtual ~ISettingsFactory(void) {};
    10   virtual boost::shared_ptr<ISolverSettings> createSelectedSolverSettings() =0;
    11   virtual boost::shared_ptr<IGlobalSettings> createSolverGlobalSettings() =0;
     9  virtual boost::shared_ptr<ISolverSettings> createSelectedSolverSettings() = 0;
     10  virtual boost::shared_ptr<IGlobalSettings> createSolverGlobalSettings() = 0;
    1211};
  • trunk/SimulationRuntime/cpp/Include/Core/SimulationSettings/ISimControllerSettings.h

    r22024 r22981  
    11#pragma once
    22
    3 /**
    4 Klasse zur Kapselung der Parameter (Einstellungen) für den SimManagerSettings.
    5 */
     3/* Klasse zur Kapselung der Parameter (Einstellungen) für den SimManagerSettings.*/
    64
    75#include <Core/Math/Constants.h>
     
    119public:
    1210    ISimControllerSettings(IGlobalSettings* globalSettings)
    13         : dHcpl                    (1e-3)
    14     , dErrTol                (0.0)
    15         , dK                    (-0.25)
    16         , dC                    (1.0)
    17         , dCmax                    (1.5)
    18         , dCmin                    (0.5)
    19         , dHuplim                ((globalSettings->getEndTime()-globalSettings->getStartTime())/100)
    20         , dHlowlim                (10.0 * UROUND)
    21         , dSingleStepTol        (1e-5)
    22         , dTendTol                (1e-6)
    23     , iMaxRejSteps            (50)
    24     , iSingleSteps            (0)
    25     , bDynCouplingStepSize    (false)
    26         , bCouplingOutput        (true)
    27     , _globalSettings     (globalSettings)
     11        : dHcpl               (1e-3)
     12    , dErrTol             (0.0)
     13        , dK                  (-0.25)
     14        , dC                  (1.0)
     15        , dCmax               (1.5)
     16        , dCmin               (0.5)
     17        , dHuplim             ((globalSettings->getEndTime()-globalSettings->getStartTime())/100)
     18        , dHlowlim            (10.0 * UROUND)
     19        , dSingleStepTol      (1e-5)
     20        , dTendTol            (1e-6)
     21    , iMaxRejSteps        (50)
     22    , iSingleSteps        (0)
     23    , bDynCouplingStepSize  (false)
     24        , bCouplingOutput   (true)
     25    , _globalSettings       (globalSettings)
    2826    {
    2927    };
    3028
    3129    double
    32         dHcpl,                    ///< Koppelschrittweite (=Intervalllänge nach der Daten zwischen gekoppelten System ausgetauscht werden, default: 100 Schritte [1/s])
     30        dHcpl,                ///< Koppelschrittweite (=Intervalllänge nach der Daten zwischen gekoppelten System ausgetauscht werden, default: 100 Schritte [1/s])
    3331        dErrTol,                ///< Gibt an, wieviel größer als 1.0 der Fehler sein darf, damit der Schritt akzeptiert wird (vorteilhaft, wenn sich wenig ändert) (default: 0.0)
    34         dK,                        ///< Faktor für Schrittweitensteuerung (k-ten Wurzel des Fehlers) (dK <= 0, default: -0.25, kleinerer Wert = größere Schrittweite)
    35         dC,                        ///< Savety Faktor für Schrittweitensteuerung (default: 1.0)
    36         dCmax,                    ///< Upscale Faktor für Schrittweitensteuerung (default: 1.5)
    37         dCmin,                    ///< Downscale Faktor für Schrittweitensteuerung (default: 0.5)
     32        dK,                   ///< Faktor für Schrittweitensteuerung (k-ten Wurzel des Fehlers) (dK <= 0, default: -0.25, kleinerer Wert = größere Schrittweite)
     33        dC,                     ///< Savety Faktor für Schrittweitensteuerung (default: 1.0)
     34        dCmax,                  ///< Upscale Faktor für Schrittweitensteuerung (default: 1.5)
     35        dCmin,                  ///< Downscale Faktor für Schrittweitensteuerung (default: 0.5)
    3836        dHuplim,                ///< Maximale Koppelschrittweite
    39         dHlowlim,                ///< Minimale Koppelschrittweite
    40         dSingleStepTol,            ///< Fehlertoleranz zur Aussetzung der Doppelschritt-Technik (default: 1e-5)
    41         dTendTol;                ///< Toleranz mit der Endzeit erreicht werden soll (default: 1e-6)
     37        dHlowlim,               ///< Minimale Koppelschrittweite
     38        dSingleStepTol,         ///< Fehlertoleranz zur Aussetzung der Doppelschritt-Technik (default: 1e-5)
     39        dTendTol;               ///< Toleranz mit der Endzeit erreicht werden soll (default: 1e-6)
    4240
    4341    int
    44         iMaxRejSteps,            ///< Max. Anzahl nacheinander verworfener Schritte (default: 50)
    45         iSingleSteps;            ///< Anzahl Schritte ohne Doppelschritt-Technik (ACHTUNG: nur bei genauer Kenntniss über Kopplungsgrad verwenden) (default: 0)
     42        iMaxRejSteps,         ///< Max. Anzahl nacheinander verworfener Schritte (default: 50)
     43        iSingleSteps;           ///< Anzahl Schritte ohne Doppelschritt-Technik (ACHTUNG: nur bei genauer Kenntniss über Kopplungsgrad verwenden) (default: 0)
    4644
    4745    bool
    48         bDynCouplingStepSize,    ///< Aquidistante oder dynamische gesteuerte Koppelschrittweite ([false,true]; default: false)
    49         bCouplingOutput;        ///< SimManagerSettings-spezifische Ausgaben ([false,true]; default: false)
     46        bDynCouplingStepSize,   ///< Aquidistante oder dynamische gesteuerte Koppelschrittweite ([false,true]; default: false)
     47        bCouplingOutput;        ///< SimManagerSettings-spezifische Ausgaben ([false,true]; default: false)
    5048
    5149    IGlobalSettings*
    5250        _globalSettings;        ///< Zeiger auf Globale Simulations Einstellungen
    53 
    5451};
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/FactoryExport.h

    r22901 r22981  
    1717    error "operating system not supported"
    1818#endif
    19 
    20 
    21 
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/IAlgLoopSolver.h

    r20164 r22981  
    1919class IAlgLoopSolver
    2020{
    21 
    2221public:
    2322    /// Enumeration to denote the status of iteration
     
    2928    };
    3029
    31     virtual ~IAlgLoopSolver()    {};
     30    virtual ~IAlgLoopSolver() {};
    3231
    3332    /// (Re-) initialize the solver
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/ILinSolverSettings.h

    r21137 r22981  
    11#pragma once
    2 
    32#include <string>
    43
     
    65/**
    76
    8 Algemeine Klasse zur Kapselung der Parameter (Einstellungen) für einen linearen Solver
     7Allgemeine Klasse zur Kapselung der Parameter (Einstellungen) für einen linearen Solver
    98Hier werden default-Einstellungen entsprechend der allgemeinen Simulations-
    10 einstellugnen gemacht, diese können überprüft und ev. Fehleinstellungen korrigiert
     9einstellungen gemacht, diese können überprüft und ev. Fehleinstellungen korrigiert
    1110werden.
    1211*****************************************************************************/
     
    1615    virtual ~ILinSolverSettings(){};
    1716
    18     virtual bool getUseSparseFormat()=0;
    19     virtual void setUseSparseFormat(bool value)=0;
    20 
    21     virtual void load(std::string)=0;
     17    virtual bool getUseSparseFormat() = 0;
     18    virtual void setUseSparseFormat(bool value) = 0;
     19    virtual void load(std::string) = 0;
    2220};
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/INonLinSolverSettings.h

    r21136 r22981  
    11#pragma once
    2 
    3 
    4 
    5 
    62
    73/*****************************************************************************/
    84/**
    95
    10 Algemeine Klasse zur Kapselung der Parameter (Einstellungen) für einen nicht linearen Solver
     6Allgemeine Klasse zur Kapselung der Parameter (Einstellungen) für einen nicht linearen Solver
    117Hier werden default-Einstellungen entsprechend der allgemeinen Simulations-
    12 einstellugnen gemacht, diese können überprüft und ev. Fehleinstellungen korrigiert
     8einstellungen gemacht, diese können überprüft und ev. Fehleinstellungen korrigiert
    139werden.
    1410*****************************************************************************/
     
    1814    virtual ~INonLinSolverSettings(){};
    1915
    20     virtual long int    getNewtMax() = 0;
    21     virtual void        setNewtMax(long int)= 0;
    22     virtual double        getRtol() = 0;
    23     virtual void        setRtol(double) = 0;
    24     virtual double        getAtol() = 0;
    25     virtual void        setAtol(double) = 0;
    26     virtual double        getDelta()= 0;
    27     virtual void        setDelta(double)= 0;
    28     virtual void load(string)=0;
     16    virtual long int getNewtMax() = 0;
     17    virtual void setNewtMax(long int)= 0;
     18    virtual double getRtol() = 0;
     19    virtual void setRtol(double) = 0;
     20    virtual double getAtol() = 0;
     21    virtual void setAtol(double) = 0;
     22    virtual double getDelta() = 0;
     23    virtual void setDelta(double) = 0;
     24    virtual void load(string) = 0;
    2925};
    3026
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/ISolver.h

    r21582 r22981  
    11#pragma once
    2 
    3 
    4 
    52/*****************************************************************************/
    63/**
     
    1815class ISolver
    1916{
    20 
    2117public:
    2218    /// Enumeration to control the time integration
    2319    enum SOLVERCALL
    2420    {
    25         UNDEF_CALL        =    0x00000000,
    26 
    27     FIRST_CALL    =  0x00000100,      ///< First call to solver
    28     RECALL      =  0x00000400,      ///< Call to solver after restart (state vector of solver has to be reinitialized
    29     RECORDCALL      =   0x00004000,      ///< Erster Aufruf zum recorden von y0
    30   };
     21    UNDEF_CALL      = 0x00000000,
     22    FIRST_CALL      = 0x00000100,       ///< First call to solver
     23    RECALL        = 0x00000400,       ///< Call to solver after restart (state vector of solver has to be reinitialized
     24    RECORDCALL      = 0x00004000,       ///< Erster Aufruf zum recorden von y0
     25  };
    3126
    3227    /// Enum to define the current status of the solver
    3328    enum SOLVERSTATUS
    3429    {
    35         UNDEF_STATUS    =    0x00000,
    36         CONTINUE        =    0x00001,        ///< Continoue integration
    37         USER_STOP        =    0x00002,            ///< Integratin stopped by user
    38         SOLVERERROR            =    0x00004,        ///< An error occured. Integration was stopped
    39         DONE            =    0x00008,            ///< Integration successfully done
     30        UNDEF_STATUS    = 0x00000,
     31        CONTINUE        = 0x00001,          ///< Continoue integration
     32        USER_STOP       = 0x00002,        ///< Integratin stopped by user
     33        SOLVERERROR     = 0x00004,          ///< An error occured. Integration was stopped
     34        DONE            = 0x00008,          ///< Integration successfully done
    4035    };
    4136
     
    4338    enum ZEROSTATUS
    4439    {
    45         EQUAL_ZERO,            ///< Value of zero function smaller than given tolerance (_zeroTol)
    46         ZERO_CROSSING,        ///< zero crossing = change in sign of zero function
    47         NO_ZERO,            ///< Even though zero crossing occured, no value of zero function did not become zero in given intervall
    48         UNCHANGED_SIGN        ///< no zero crossing = continoue time integration
     40        EQUAL_ZERO,                   ///< Value of zero function smaller than given tolerance (_zeroTol)
     41        ZERO_CROSSING,                ///< zero crossing = change in sign of zero function
     42        NO_ZERO,                    ///< Even though zero crossing occured, no value of zero function did not become zero in given intervall
     43        UNCHANGED_SIGN                ///< no zero crossing = continoue time integration
    4944    };
    5045
    51   virtual ~ISolver()  {};
    52 
     46  virtual ~ISolver()  {};
    5347
    5448    /// Set start time
     
    6357     /// (Re-) initialize the solver
    6458    virtual void initialize() = 0;
    65   virtual bool stateSelection() = 0;
     59  virtual bool stateSelection() = 0;
    6660    /// Approximation of the numerical solution in a given time interval
    6761    virtual void solve(const SOLVERCALL command = UNDEF_CALL) = 0;
     
    7468    virtual void writeSimulationInfo() = 0;
    7569
    76   /// Indicates whether a solver error occurred during integration, returns type of error and provides error message
    77   /*virtual const int reportErrorMessage(ostream& messageStream) = 0;*/
    78 
     70  /// Indicates whether a solver error occurred during integration, returns type of error and provides error message
     71  /*virtual const int reportErrorMessage(ostream& messageStream) = 0;*/
    7972};
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/ISolverSettings.h

    r22917 r22981  
    3131  virtual double getEndTimeTol() = 0;
    3232  virtual void setEndTimeTol(double) = 0;
    33   //DenseOut
     33  // DenseOut
    3434  virtual bool getDenseOutput() = 0;
    3535  virtual void setDenseOutput(bool) = 0;
     
    4040  virtual void setRTol(double) = 0;
    4141
    42   ///  Global simulation settings
    43   virtual IGlobalSettings* getGlobalSettings()=0;
    44   virtual void load(string)=0;
     42  /// Global simulation settings
     43  virtual IGlobalSettings* getGlobalSettings() = 0;
     44  virtual void load(string) = 0;
    4545};
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/SimulationMonitor.h

    r22561 r22981  
    88{
    99public:
    10   SimulationMonitor();
    11   ~SimulationMonitor();
    12    void initialize();
    13    void setTimeOut(unsigned int time_out);
    14    void checkTimeout();
    15  protected:
     10  SimulationMonitor();
     11  ~SimulationMonitor();
     12  void initialize();
     13  void setTimeOut(unsigned int time_out);
     14  void checkTimeout();
     15
     16protected:
    1617     /*nanosecond_type _time_out;*/
    17 
    1818     bool _interrupt;
    1919     /*cpu_timer _timer;*/
    20 
    2120};
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/SolverDefaultImplementation.h

    r22024 r22981  
    1212#include <Core/Solver/SystemStateSelection.h>
    1313#include <Core/Solver/SimulationMonitor.h>
     14
    1415/// typedef to hand over (callback) functions to fortran routines
    1516typedef int (*U_fp)(...);
     
    3435#define BOOST_EXTENSION_SOLVER_DECL
    3536#endif
     37
    3638class BOOST_EXTENSION_SOLVER_DECL SolverDefaultImplementation : public SimulationMonitor
    3739{
     
    4042    SolverDefaultImplementation(IMixedSystem* system, ISolverSettings* settings);
    4143    virtual ~SolverDefaultImplementation();
    42 
    4344
    4445    /// Set start time for numerical solution
     
    4950
    5051    /// Set the initial step size (needed for reinitialization after external zero search)
    51      void setInitStepSize(const double& h)    ;
     52     void setInitStepSize(const double& h);
    5253
    5354    /// Assemble system and (re-)initialize solver
     
    6061    void setZeroState();
    6162
    62 
    6363    /// Called by solver after every successfull integration step (calls writeOutput)
    6464    void writeToFile(const int& stp, const double& t, const double& h);
    65   virtual bool stateSelection();
     65  virtual bool stateSelection();
    6666
    6767protected:
     
    6969    //---------------------------------------------------------------
    7070    IMixedSystem
    71         *_system;                        ///< System to be solved
     71        *_system;                     ///< System to be solved
    7272
    7373    ISolverSettings
    74         *_settings;                        ///< Settings for the solver
     74        *_settings;                     ///< Settings for the solver
    7575
    7676    boost::shared_ptr<SystemStateSelection> _state_selection;
    7777    double
    78         _tInit,                            ///< (initiale) Startzeit (wird nicht vom Solver verändert)
    79         _tCurrent,                        ///< current time (is changed by the solver)
    80         _tEnd,                            ///< end time
    81         _tLastSuccess,                    ///< time of last successfull integration step (before zero crossing)
    82         _tLastUnsucess,                    ///< time of last unsuccessfull integration step (after zero crossing)
     78        _tInit,                       ///< (initiale) Startzeit (wird nicht vom Solver verändert)
     79        _tCurrent,                      ///< current time (is changed by the solver)
     80        _tEnd,                          ///< end time
     81        _tLastSuccess,                  ///< time of last successfull integration step (before zero crossing)
     82        _tLastUnsucess,                 ///< time of last unsuccessfull integration step (after zero crossing)
    8383        _tLargeStep;
    8484
    8585    double
    86         _h;                                ///< step size (changed by the solver)
     86        _h;                           ///< step size (changed by the solver)
    8787
    8888    bool
    89         _firstCall,                        ///< Denotes the first call to the solver. May be used to call init()
    90         _firstStep;                        ///< Denotes the first step. May be used for (re-)initialization to call giveVars(...)
     89        _firstCall,                     ///< Denotes the first call to the solver. May be used to call init()
     90        _firstStep;                     ///< Denotes the first step. May be used for (re-)initialization to call giveVars(...)
    9191
    9292
    9393    int
    94         _totStps,                        ///< Total number of time integration steps
    95         _accStps,                        ///< Number of accepted time integration steps
    96         _rejStps,                        ///< Number of rejected time integration steps
    97         _zeroStps,                        ///< Number of zero search steps during whole time integration intervall
    98         _zeros;                            ///< Number of zeros in whole time integration intervall
     94        _totStps,                       ///< Total number of time integration steps
     95        _accStps,                       ///< Number of accepted time integration steps
     96        _rejStps,                       ///< Number of rejected time integration steps
     97        _zeroStps,                      ///< Number of zero search steps during whole time integration intervall
     98        _zeros;                         ///< Number of zeros in whole time integration intervall
    9999
    100100    int
    101101        _dimSys,                        ///< Number of equations (=dimension of the system)
    102         _dimZeroFunc;                    ///< Number of zero functions
     102        _dimZeroFunc;                   ///< Number of zero functions
    103103
    104104    bool*
    105         _events;                        ///< Vector (of dimension _dimZeroF) indicating which zero function caused an event
    106      event_times_type                    ///< Map including all time entries and the event ID occuring a time event
     105        _events;                      ///< Vector (of dimension _dimZeroF) indicating which zero function caused an event
     106     
     107  event_times_type                  ///< Map including all time entries and the event ID occuring a time event
    107108        _time_events;
    108109
    109110    double
    110         *_zeroVal,            ///< Vector (of dimension _dimZeroF) containing values of all zero functions
    111         *_zeroValInit,          ///< Vektor (der Dimension _dimZeroF) mit Nullstellenfunktionswerten am Anfang des Integrationsintervalles
    112         *_zeroValLastSuccess;    ///< Vector (of dimension _dimZeroF) containing values of all zero functions of last sucessfull integration step (before zero crossing)
     111        *_zeroVal,                  ///< Vector (of dimension _dimZeroF) containing values of all zero functions
     112        *_zeroValInit,              ///< Vektor (der Dimension _dimZeroF) mit Nullstellenfunktionswerten am Anfang des Integrationsintervalles
     113        *_zeroValLastSuccess;       ///< Vector (of dimension _dimZeroF) containing values of all zero functions of last sucessfull integration step (before zero crossing)
    113114
    114115    ISolver::ZEROSTATUS
    115         _zeroStatus;            ///< Denotes whether a change in sign in at least one zero function occured
     116        _zeroStatus;                ///< Denotes whether a change in sign in at least one zero function occured
    116117
    117118    ISolver::SOLVERSTATUS
    118         _solverStatus;          ///< Denotes the current status of the solver
     119        _solverStatus;              ///< Denotes the current status of the solver
    119120
    120121    IWriteOutput::OUTPUT
    121         _outputCommand;          ///< Controls the output
     122        _outputCommand;             ///< Controls the output
    122123
    123124private:
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/SolverSettings.h

    r22565 r22981  
    22
    33#include "ISolverSettings.h"
    4 
    5 
    6 
    74/*****************************************************************************/
    85/**
     
    2219#define BOOST_EXTENSION_SOLVERSETTINGS_DECL
    2320#endif
     21
    2422class BOOST_EXTENSION_SOLVERSETTINGS_DECL SolverSettings : public ISolverSettings
    2523{
    2624public:
    27   SolverSettings( IGlobalSettings* globalSettings);
    28    virtual ~SolverSettings();
    29   /// Initial step size (default: 1e-2)
    30   virtual double gethInit();
    31   virtual void sethInit(double);
    32   /// Lower limit for step size during integration (default: should be machine precision)
    33   virtual double getLowerLimit();
    34   virtual void setLowerLimit(double);
    35   /// Upper limit for step size during integration (default: _endTime-_startTime)
    36   virtual double getUpperLimit();
    37   virtual void setUpperLimit(double);
    38   /// Tolerance to reach _endTime (default: 1e-6)
    39   virtual double getEndTimeTol();
    40   virtual void setEndTimeTol(double);
    41 
    42   //dense Output
    43   virtual bool getDenseOutput();
    44   virtual void setDenseOutput(bool);
    45 
    46   virtual double getATol();
    47   virtual void setATol(double);
    48   virtual double getRTol();
    49   virtual void setRTol(double);
    50 
    51   ///  Global simulation settings
    52   virtual IGlobalSettings* getGlobalSettings();
    53   virtual void load(string);
     25  SolverSettings( IGlobalSettings* globalSettings);
     26  virtual ~SolverSettings();
     27  /// Initial step size (default: 1e-2)
     28  virtual double gethInit();
     29  virtual void sethInit(double);
     30  /// Lower limit for step size during integration (default: should be machine precision)
     31  virtual double getLowerLimit();
     32  virtual void setLowerLimit(double);
     33  /// Upper limit for step size during integration (default: _endTime-_startTime)
     34  virtual double getUpperLimit();
     35  virtual void setUpperLimit(double);
     36  /// Tolerance to reach _endTime (default: 1e-6)
     37  virtual double getEndTimeTol();
     38  virtual void setEndTimeTol(double);
     39 
     40  //dense Output
     41  virtual bool getDenseOutput();
     42  virtual void setDenseOutput(bool);
     43 
     44  virtual double getATol();
     45  virtual void setATol(double);
     46  virtual double getRTol();
     47  virtual void setRTol(double);
     48 
     49  ///  Global simulation settings
     50  virtual IGlobalSettings* getGlobalSettings();
     51  virtual void load(string);
     52 
    5453private:
    5554  double
    56     _hInit,        ///< Initial step size (default: 1e-2)
    57     _hLowerLimit,    ///< Lower limit for step size during integration (default: should be machine precision)
    58     _hUpperLimit,    ///< Upper limit for step size during integration (default: _endTime-_startTime)
    59     _endTimeTol,      ///< Tolerance to reach _endTime (default: 1e-6)
     55    _hInit,           ///< Initial step size (default: 1e-2)
     56    _hLowerLimit,     ///< Lower limit for step size during integration (default: should be machine precision)
     57    _hUpperLimit,     ///< Upper limit for step size during integration (default: _endTime-_startTime)
     58    _endTimeTol,        ///< Tolerance to reach _endTime (default: 1e-6)
    6059    _dRtol,
    6160    _dAtol;
    6261    IGlobalSettings*
    63     _globalSettings;  ///< Global simulation settings
     62    _globalSettings;    ///< Global simulation settings
    6463
    6564  bool
    6665    _denseOutput;
    67 
    6866};
  • trunk/SimulationRuntime/cpp/Include/Core/Solver/SystemStateSelection.h

    r22903 r22981  
    1616{
    1717public:
    18   SystemStateSelection(IMixedSystem* system);
    19 
    20   ~SystemStateSelection();
    21 
    22   bool stateSelection(int switchStates);
    23   void initialize();
     18  SystemStateSelection(IMixedSystem* system);
     19  ~SystemStateSelection();
     20 
     21  bool stateSelection(int switchStates);
     22  void initialize();
    2423
    2524private:
    26   void setAMatrix(int* newEnable, unsigned int index);
    27   int comparePivot(int *oldPivot, int *newPivot, int switchStates, unsigned int index);
    28 
    29   IMixedSystem* _system;
    30   IStateSelection* _state_selection;
    31   std::vector<boost::shared_array<int> > _rowPivot;
    32   std::vector<boost::shared_array<int> > _colPivot;
    33   unsigned int _dimStateSets;
    34   std::vector<unsigned int> _dimStates;
    35   std::vector<unsigned int> _dimDummyStates;
    36   std::vector<unsigned int> _dimStateCanditates;
    37   bool _initialized;
     25  void setAMatrix(int* newEnable, unsigned int index);
     26  int comparePivot(int* oldPivot, int* newPivot, int switchStates, unsigned int index);
     27 
     28  IMixedSystem* _system;
     29  IStateSelection* _state_selection;
     30  std::vector<boost::shared_array<int> > _rowPivot;
     31  std::vector<boost::shared_array<int> > _colPivot;
     32  unsigned int _dimStateSets;
     33  std::vector<unsigned int> _dimStates;
     34  std::vector<unsigned int> _dimDummyStates;
     35  std::vector<unsigned int> _dimStateCanditates;
     36  bool _initialized;
    3837};
    39 
  • trunk/SimulationRuntime/cpp/Include/Core/System/EventHandling.h

    r22509 r22981  
    11#pragma once
    2 
    32
    43/**
     
    1615    //Inits the event variables
    1716    //void initialize(IEvent* system,int dim,init_prevars_type init_prevars);
    18   void initialize(IEvent* system,int dim);
     17  void initialize(IEvent* system, int dim);
    1918    //Returns the help vector
    2019    //void getHelpVars(double* h);
     
    2423    //int getDimHelpVars() const;
    2524
    26 
    27 
    2825    //saves a variable in _pre_vars vector
    29     void save(double var,string key);
     26    void save(double var, string key);
    3027    void savePreVars(double vars [], unsigned int n);
    3128    void saveDiscretPreVars(double vars [], unsigned int n);
    3229    //saves all helpvariables
    3330    //void saveH();
    34    // void setHelpVar(unsigned int i,double var);
     31  // void setHelpVar(unsigned int i,double var);
    3532    //const double& operator[](unsigned int i) const;
    3633    //Implementation of the Modelica pre  operator
    37     double pre(double var,string key);
     34    double pre(double var, string key);
    3835    //Implementation of the Modelica edge  operator
    39     bool edge(double var,string key);
     36    bool edge(double var, string key);
    4037    //Implementation of the Modelica change  operator
    41     bool change(double var,string key);
    42       //Adds an event to the eventqueue
     38    bool change(double var, string key);
     39    //Adds an event to the eventqueue
    4340    //void addEvent(long index);
    4441    //removes an event from the eventqueue
     
    4744    bool IterateEventQueue(bool& state_vars_reinitialized);
    4845
    49     void saveDiscreteVar(double var,string key);
    50     bool changeDiscreteVar(double var,string key);
    51 
     46    void saveDiscreteVar(double var, string key);
     47    bool changeDiscreteVar(double var, string key);
    5248
    5349    getCondition_type  getCondition;
     50 
    5451private:
    5552    //Stores all varibales occured before an event
     
    6259    //Dimesion of Helpvarsvector
    6360    //int _dimH;
    64      event_times_type _time_events;
    65      boost::multi_array<double,1> _pre_vars;
    66      boost::multi_array<double,1> _pre_discrete_vars;
     61    event_times_type _time_events;
     62    boost::multi_array<double,1> _pre_vars;
     63    boost::multi_array<double,1> _pre_discrete_vars;
    6764
    68      IContinuous* _countinous_system; //just a cast of _event_system -> required in IterateEventQueue
    69      IMixedSystem* _mixed_system; //just a cast of _event_system -> required in IterateEventQueue
    70      bool* _conditions0;
    71      bool* _conditions1;
     65    IContinuous* _countinous_system; //just a cast of _event_system -> required in IterateEventQueue
     66    IMixedSystem* _mixed_system; //just a cast of _event_system -> required in IterateEventQueue
     67    bool* _conditions0;
     68    bool* _conditions1;
    7269};
  • trunk/SimulationRuntime/cpp/Include/Core/System/IAlgLoop.h

    r22276 r22981  
    1616*****************************************************************************/
    1717
    18 
    1918class IAlgLoop
    2019{
     
    2322    enum CONSTRTYPE
    2423    {
    25         UNDEF    =    0x00000000,
     24        UNDEF   =    0x00000000,
    2625        REAL    =    0x00000001,
    27         INTEGER    =    0x00000002,
    28         BOOLEAN    =    0x00000004,
    29         ALL        =    0x00000007,
     26        INTEGER =    0x00000002,
     27        BOOLEAN =    0x00000004,
     28        ALL     =    0x00000007,
    3029    };
     30 
     31    virtual ~IAlgLoop() {};
    3132
    32 
    33 
    34     virtual ~IAlgLoop()    {};
    35 
    36   /// Provide number (dimension) of variables according to the data type
    37   virtual int getDimReal() const = 0;
    38 
    39   /// Provide number (dimension) of right hand sides (residuals) according to the data type
    40   virtual int getDimRHS() const = 0;
    41 
    42   /// (Re-) initialize the system of equations
    43   virtual void initialize() = 0;
    44 
    45   /// Provide variables of given data type
    46   virtual void getReal(double* lambda) = 0;
    47   /// Provide nominal values of given data type
    48   virtual void getNominalReal(double* lambda) = 0;
    49   /// Set variables with given data type
    50   virtual void setReal(const double* lambda) = 0;
    51 
    52   /// Update transfer behavior of the system of equations according to command given by solver
    53   virtual void evaluate() = 0;   // vxworksupdate
    54 
    55   /// Provide the right hand side (according to the index)
    56   virtual void getRHS(double* res) = 0;
    57 
    58   virtual void getSystemMatrix(double* A_matrix) = 0;
    59   virtual void getSystemMatrix(sparse_matrix * ) {};
    60 
    61   virtual bool isLinear() = 0;
    62   virtual bool isLinearTearing()=0;
    63   virtual bool isConsistent() = 0;
    64 
    65 
    66   virtual bool getUseSparseFormat() = 0;
    67   virtual void setUseSparseFormat(bool value) = 0;
    68   virtual float queryDensity() = 0;
    69   /*/// Fügt das übergebene Objekt als Across-Kante hinzu
    70   void addAcrossEdge(IObject& new_obj);
    71 
    72     /// Fübt das übergebene Objekt als Through-Kante hinzu
    73     void addThroughEdge(IObject& new_obj);
    74 
    75   /// Definiert die übergebene Größe als Schnittgröße
    76   void addConstraint(double& constr_value);
    77   */
     33  /// Provide number (dimension) of variables according to the data type
     34  virtual int getDimReal() const = 0;
     35 
     36  /// Provide number (dimension) of right hand sides (residuals) according to the data type
     37  virtual int getDimRHS() const = 0;
     38 
     39  /// (Re-) initialize the system of equations
     40  virtual void initialize() = 0;
     41 
     42  /// Provide variables of given data type
     43  virtual void getReal(double* lambda) = 0;
     44  /// Provide nominal values of given data type
     45  virtual void getNominalReal(double* lambda) = 0;
     46  /// Set variables with given data type
     47  virtual void setReal(const double* lambda) = 0;
     48 
     49  /// Update transfer behavior of the system of equations according to command given by solver
     50  virtual void evaluate() = 0;   // vxworksupdate
     51 
     52  /// Provide the right hand side (according to the index)
     53  virtual void getRHS(double* res) = 0;
     54 
     55  virtual void getSystemMatrix(double* A_matrix) = 0;
     56  virtual void getSystemMatrix(sparse_matrix * ) {};
     57 
     58  virtual bool isLinear() = 0;
     59  virtual bool isLinearTearing() = 0;
     60  virtual bool isConsistent() = 0; 
     61 
     62  virtual bool getUseSparseFormat() = 0;
     63  virtual void setUseSparseFormat(bool value) = 0;
     64  virtual float queryDensity() = 0;
     65  /*/// Fügt das übergebene Objekt als Across-Kante hinzu
     66  void addAcrossEdge(IObject& new_obj);
     67 
     68  /// Fübt das übergebene Objekt als Through-Kante hinzu
     69  void addThroughEdge(IObject& new_obj);
     70 
     71  /// Definiert die übergebene Größe als Schnittgröße
     72  void addConstraint(double& constr_value);
     73  */
    7874};
    7975
  • trunk/SimulationRuntime/cpp/Include/Core/System/IContinuous.h

    r22917 r22981  
    11#pragma once
    2 
    3 
    42
    53/*****************************************************************************/
     
    1513Copyright (c) 2008, OSMC
    1614*****************************************************************************/
     15
    1716class IContinuous
    1817{
    1918public:
    20 
    21 
    2219    /// Enumeration to control the evaluation of equations within the system
    2320    enum UPDATETYPE
    2421    {
    25         UNDEF_UPDATE  = 0x00000000,
    26         ACROSS      = 0x00000001,
    27         THROUGH      = 0x00000002,
    28         ALL        = 0x00000003,
    29         DISCRETE   = 0x00000004,
    30         CONTINUOUS  = 0x00000008,
    31         RANKING      = 0x00000016      ///< Ranking Method
     22        UNDEF_UPDATE    = 0x00000000,
     23        ACROSS        = 0x00000001,
     24        THROUGH       = 0x00000002,
     25        ALL           = 0x00000003,
     26        DISCRETE      = 0x00000004,
     27        CONTINUOUS    = 0x00000008,
     28        RANKING       = 0x00000016      ///< Ranking Method
    3229    };
    33 
    34 
    3530
    3631    virtual ~IContinuous()  {};
     
    5449    virtual int getDimRHS() const = 0;
    5550
    56 
    57 
    58 
    5951    /// Provide boolean variables
    6052    virtual void getBoolean(bool* z) = 0;
     
    6254    /// Provide boolean variables
    6355    virtual void getContinuousStates(double* z) = 0;
    64     virtual void getNominalStates(double* z)   = 0 ;
     56    virtual void getNominalStates(double* z) = 0 ;
    6557    /// Provide integer variables
    6658    virtual void getInteger(int* z) = 0;
     
    7466    /// Provide the right hand side
    7567    virtual void getRHS(double* f) = 0;
    76 
    77 
    78 
    79 
    8068
    8169    /// Provide boolean variables
     
    9785    virtual void setRHS(const double* f) = 0;
    9886
    99 
    100 
    101 
    10287    /// Update transfer behavior of the system of equations according to command given by solver
    10388
    10489    virtual bool evaluateAll(const UPDATETYPE command = UNDEF_UPDATE) = 0;  // vxworks
    10590    virtual void evaluateODE(const UPDATETYPE command = UNDEF_UPDATE) = 0;  // vxworks
    106     virtual void evaluateZeroFuncs(const UPDATETYPE command = UNDEF_UPDATE)= 0;
    107     virtual bool evaluateConditions(const UPDATETYPE command = UNDEF_UPDATE)= 0;
     91    virtual void evaluateZeroFuncs(const UPDATETYPE command = UNDEF_UPDATE) = 0;
     92    virtual bool evaluateConditions(const UPDATETYPE command = UNDEF_UPDATE) = 0;
    10893
    10994    virtual bool stepCompleted(double time) = 0;
    11095    virtual bool stepStarted(double time) = 0;
    111 
    11296};
    11397
     
    117101    enum INDEX
    118102    {
    119         UNDEF_INDEX            =    0x00000,
    120         VAR_INDEX0            =    0x00001,    ///< Variable Index 0 (States of systems of 1st order)
    121         VAR_INDEX1            =    0x00002,    ///< Variable Index 1 (1st order States of systems of 2nd order, e.g. positions)
    122         VAR_INDEX2            =    0x00004,    ///< Variable Index 2 (2nd order States of systems of 2nd order, e.g. velocities)
    123         VAR_INDEX3            =    0x00038,    ///< Variable Index 3 (all constraints)
    124         DIFF_INDEX3            =    0x00008,    ///< Differentiation Index 3 (constraints on position level only)
    125         DIFF_INDEX2            =    0x00010,    ///< Differentiation Index 2 (constraints on velocity level only)
    126         DIFF_INDEX1            =    0x00020,    ///< Differentiation Index 1 (constraints on acceleration level only)
    127         ALL_RESIDUES        =    0x00040,    ///< All residues
    128         ALL_STATES            =    0x00007,    ///< All states (no order)
    129         ALL_VARS            =    0x0003f,    ///< All variables (no order)
     103        UNDEF_INDEX     =    0x00000,
     104        VAR_INDEX0      =    0x00001,    ///< Variable Index 0 (States of systems of 1st order)
     105        VAR_INDEX1      =    0x00002,    ///< Variable Index 1 (1st order States of systems of 2nd order, e.g. positions)
     106        VAR_INDEX2      =    0x00004,    ///< Variable Index 2 (2nd order States of systems of 2nd order, e.g. velocities)
     107        VAR_INDEX3      =    0x00038,    ///< Variable Index 3 (all constraints)
     108        DIFF_INDEX3     =    0x00008,    ///< Differentiation Index 3 (constraints on position level only)
     109        DIFF_INDEX2     =    0x00010,    ///< Differentiation Index 2 (constraints on velocity level only)
     110        DIFF_INDEX1     =    0x00020,    ///< Differentiation Index 1 (constraints on acceleration level only)
     111        ALL_RESIDUES    =    0x00040,    ///< All residues
     112        ALL_STATES      =    0x00007,    ///< All states (no order)
     113        ALL_VARS        =    0x0003f,    ///< All variables (no order)
    130114    };
    131115    */
  • trunk/SimulationRuntime/cpp/Include/Core/System/ICoupledSystem.h

    r22024 r22981  
    11#pragma once
    22#include <Core/Object/IObject.h>
     3
    34class ICoupledSystem
    45{
    56public:
    6 
    7   virtual void addAcross(IObject&)=0;
    8   virtual void addThrough(IObject&)=0;
     7  virtual void addAcross(IObject&) = 0;
     8  virtual void addThrough(IObject&) = 0;
    99};
  • trunk/SimulationRuntime/cpp/Include/Core/System/IEvent.h

    r22509 r22981  
    11#pragma once
    2 
    32
    43/*****************************************************************************/
     
    2019{
    2120public:
    22 
    2321    virtual ~IEvent()    {};
    2422
     
    2826    virtual void getZeroFunc(double* f) = 0;
    2927
    30     virtual void  setConditions(bool* c) =0;
    31     virtual void getConditions(bool* c)=0;
     28    virtual void  setConditions(bool* c) = 0;
     29    virtual void getConditions(bool* c) = 0;
    3230    virtual void saveDiscreteVars() = 0;
    3331    /// Called to handle an event
     
    3634    virtual bool checkForDiscreteEvents() = 0;
    3735    virtual  bool getCondition(unsigned int index) = 0;
    38   virtual void initPreVars(unordered_map<string,unsigned int>&,unordered_map<string,unsigned int>&)= 0;
     36  virtual void initPreVars(unordered_map<string,unsigned int>&,unordered_map<string,unsigned int>&)= 0;
    3937};
    40 
  • trunk/SimulationRuntime/cpp/Include/Core/System/IStateSelection.h

    r21829 r22981  
    88{
    99public:
    10 
    11   virtual ~IStateSelection()  {};
    12   virtual int getDimStateSets() const = 0;
    13   virtual int getDimStates(unsigned int index) const = 0;
    14   virtual int getDimCanditates(unsigned int index) const = 0;
    15   virtual int getDimDummyStates(unsigned int index) const = 0;
    16   virtual void getStates(unsigned int index,double* z) = 0;
    17   virtual void setStates(unsigned int index,const double* z) = 0;
    18   virtual void getStateCanditates(unsigned int index,double* z) = 0;
    19   virtual bool getAMatrix(unsigned int index,DynArrayDim2<int> & A) =0 ;
    20   virtual void setAMatrix(unsigned int index,DynArrayDim2<int>& A)=0;
    21   virtual bool getAMatrix(unsigned int index,DynArrayDim1<int> & A) =0 ;
    22   virtual void setAMatrix(unsigned int index,DynArrayDim1<int>& A)=0;
     10  virtual ~IStateSelection()  {};
     11  virtual int getDimStateSets() const = 0;
     12  virtual int getDimStates(unsigned int index) const = 0;
     13  virtual int getDimCanditates(unsigned int index) const = 0;
     14  virtual int getDimDummyStates(unsigned int index) const = 0;
     15  virtual void getStates(unsigned int index, double* z) = 0;
     16  virtual void setStates(unsigned int index, const double* z) = 0;
     17  virtual void getStateCanditates(unsigned int index, double* z) = 0;
     18  virtual bool getAMatrix(unsigned int index, DynArrayDim2<int> & A) = 0 ;
     19  virtual void setAMatrix(unsigned int index, DynArrayDim2<int>& A) = 0;
     20  virtual bool getAMatrix(unsigned int index, DynArrayDim1<int> & A) = 0 ;
     21  virtual void setAMatrix(unsigned int index, DynArrayDim1<int>& A) = 0;
    2322};
  • trunk/SimulationRuntime/cpp/Include/Core/System/IStepEvent.h

    r22362 r22981  
    22class IStepEvent
    33{
    4  public:
    5 
    6   virtual ~IStepEvent(){};
    7   virtual bool isStepEvent() = 0;
    8   //sets the initial status
    9   virtual void setTerminal(bool) = 0;
    10   //returns the intial status
    11   virtual bool terminal() = 0;
     4public:
     5  virtual ~IStepEvent(){};
     6  virtual bool isStepEvent() = 0;
     7  //sets the initial status
     8  virtual void setTerminal(bool) = 0;
     9  //returns the intial status
     10  virtual bool terminal() = 0;
    1211};
    1312
  • trunk/SimulationRuntime/cpp/Include/Core/System/ISystemInitialization.h

    r20164 r22981  
    1616{
    1717public:
    18 
    19     virtual ~ISystemInitialization()    {};
    20 
    21 
    22 
    23 
    24   /// (Re-) initialize the system of equations and bounded parameters
    25   virtual void initialize() = 0;
    26   virtual void initEquations() = 0;
    27   //sets the initial status
    28   virtual void setInitial(bool) = 0;
    29   //returns the intial status
    30   virtual bool initial() = 0;
    31 
    32 
     18  virtual ~ISystemInitialization() {};
     19  /// (Re-) initialize the system of equations and bounded parameters
     20  virtual void initialize() = 0;
     21  virtual void initEquations() = 0;
     22  //sets the initial status
     23  virtual void setInitial(bool) = 0;
     24  //returns the intial status
     25  virtual bool initial() = 0;
    3326};
  • trunk/SimulationRuntime/cpp/Include/Core/System/ISystemProperties.h

    r20164 r22981  
    1313Copyright (c) 2008, OSMC
    1414*****************************************************************************/
     15
    1516class ISystemProperties
    1617{
    1718public:
    18 
    19   virtual ~ISystemProperties()  {};
    20 
    21   /// M is regular
    22   virtual bool isODE() /*const*/ = 0;
    23 
    24   /// M is singular
    25   virtual bool isAlgebraic() /*const*/ = 0;
    26 
    27   /// System is able to provide the Jacobian symbolically
    28   virtual bool provideSymbolicJacobian() /*const*/ = 0;
     19  virtual ~ISystemProperties()  {};
     20 
     21  /// M is regular
     22  virtual bool isODE() /*const*/ = 0;
     23 
     24  /// M is singular
     25  virtual bool isAlgebraic() /*const*/ = 0;
     26 
     27  /// System is able to provide the Jacobian symbolically
     28  virtual bool provideSymbolicJacobian() /*const*/ = 0;
    2929};
  • trunk/SimulationRuntime/cpp/Include/Core/System/ITime.h

    r21582 r22981  
    1 
    21#pragma once
    32typedef std::vector<std::pair<double,double> > time_event_type;
     3
    44class ITime
    55{
    66public:
    7 
    8   virtual ~ITime() {};
    9   virtual int getDimTimeEvent() const  = 0;
    10   //gibt die Time events (Startzeit und Frequenz) zurück
    11   virtual void getTimeEvent(time_event_type& time_events) = 0;
    12   //Wird vom Solver zur Behandlung der Time events aufgerufen (wenn zero_sign[i] = 0  kein time event,zero_sign[i] = n  Anzahl von vorgekommen time events )
    13   virtual void handleTimeEvent(int* time_events) = 0;
    14   /// Set current integration time
    15   virtual void setTime(const double& time) = 0;
     7  virtual ~ITime() {};
     8  virtual int getDimTimeEvent() const = 0;
     9  //gibt die Time events (Startzeit und Frequenz) zurück
     10  virtual void getTimeEvent(time_event_type& time_events) = 0;
     11  //Wird vom Solver zur Behandlung der Time events aufgerufen (wenn zero_sign[i] = 0  kein time event,zero_sign[i] = n  Anzahl von vorgekommen time events )
     12  virtual void handleTimeEvent(int* time_events) = 0;
     13  /// Set current integration time
     14  virtual void setTime(const double& time) = 0;
    1615};
  • trunk/SimulationRuntime/cpp/Include/Core/System/IWriteOutput.h

    r20164 r22981  
    11#pragma once
    2 
    32
    43class IHistory;
     
    65{
    76public:
    8 
    97    /// Enumeration to control the output
    108    enum OUTPUT
    119    {
    12         UNDEF_OUTPUT    =    0x00000000,
     10    UNDEF_OUTPUT =  0x00000000,
     11    WRITEOUT     =  0x00000001,  ///< vxworks! Store current position of curser and write out current results
     12    RESET        =  0x00000002,  ///< Reset curser position
     13    OVERWRITE    =  0x00000003,  ///< RESET|WRITE
     14    HEAD_LINE    =  0x00000010,  ///< Write out head line
     15    RESULTS      =  0x00000020,  ///< Write out results
     16    SIMINFO      =  0x00000040   ///< Write out simulation info (e.g. number of steps)
     17  };
    1318
    14     WRITEOUT      =  0x00000001,      ///< vxworks! Store current position of curser and write out current results
    15     RESET      =  0x00000002,      ///< Reset curser position
    16     OVERWRITE    =  0x00000003,      ///< RESET|WRITE
    17 
    18 
    19     HEAD_LINE    =  0x00000010,      ///< Write out head line
    20     RESULTS      =  0x00000020,      ///< Write out results
    21     SIMINFO      =  0x00000040      ///< Write out simulation info (e.g. number of steps)
    22   };
    23 
    24   virtual ~IWriteOutput()  {};
    25   /// Output routine (to be called by the solver after every successful integration step)
    26   virtual void writeOutput(const OUTPUT command = UNDEF_OUTPUT) = 0;
    27   virtual IHistory* getHistory()=0;
    28 
    29 
    30 
     19  virtual ~IWriteOutput() {};
     20 
     21  /// Output routine (to be called by the solver after every successful integration step)
     22  virtual void writeOutput(const OUTPUT command = UNDEF_OUTPUT) = 0;
     23  virtual IHistory* getHistory() = 0;
    3124};
  • trunk/SimulationRuntime/cpp/Include/Core/System/SystemDefaultImplementation.h

    r22401 r22981  
    4545};
    4646
    47 
    4847class BOOST_EXTENSION_SYSTEM_DECL SystemDefaultImplementation
    4948{
    5049public:
    5150    SystemDefaultImplementation(IGlobalSettings* globalSettings);
    52 
    5351    virtual ~SystemDefaultImplementation();
    54 
    55 
    5652
    5753    /// Provide number (dimension) of boolean variables
     
    7470
    7571
    76 
    77 
    78     /// Provide boolean variables
    79     virtual void getBoolean(bool* z);
    80 
    81     /// Provide boolean variables
    82     virtual void getContinuousStates(double* z);
    83 
    84     /// Provide integer variables
    85     virtual void getInteger(int* z);
    86 
    87     /// Provide real variables
    88     virtual void getReal(double* z);
    89 
    90     /// Provide real variables
    91     virtual void getString(std::string* z);
    92 
    93     /// Provide the right hand side
    94     virtual void getRHS(double* f);
    95 
    96     virtual void  setConditions(bool* c);
    97     virtual void getConditions(bool* c);
    98     /// Provide boolean variables
    99     virtual void setBoolean(const bool* z);
    100 
    101     /// Provide boolean variables
    102     virtual void setContinuousStates(const double* z);
    103 
    104     /// Provide integer variables
    105     virtual void setInteger(const int* z);
    106 
    107     /// Provide real variables
    108     virtual void setReal(const double* z);
    109 
    110     /// Provide real variables
    111     virtual void setString(const std::string* z);
    112 
    113     /// Provide the right hand side
    114     virtual void setRHS(const double* f);
    115 
    116 
    117 
    118     /// (Re-) initialize the system of equations
    119      void initialize();
    120     /// Set current integration time
    121      void setTime(const double& t);
     72  /// Provide boolean variables
     73  virtual void getBoolean(bool* z);
     74 
     75  /// Provide boolean variables
     76  virtual void getContinuousStates(double* z);
     77 
     78  /// Provide integer variables
     79  virtual void getInteger(int* z);
     80 
     81  /// Provide real variables
     82  virtual void getReal(double* z);
     83 
     84  /// Provide real variables
     85  virtual void getString(std::string* z);
     86 
     87  /// Provide the right hand side
     88  virtual void getRHS(double* f);
     89 
     90  virtual void  setConditions(bool* c);
     91  virtual void getConditions(bool* c);
     92  /// Provide boolean variables
     93  virtual void setBoolean(const bool* z);
     94 
     95  /// Provide boolean variables
     96  virtual void setContinuousStates(const double* z);
     97 
     98  /// Provide integer variables
     99  virtual void setInteger(const int* z);
     100 
     101  /// Provide real variables
     102  virtual void setReal(const double* z);
     103 
     104  /// Provide real variables
     105  virtual void setString(const std::string* z);
     106 
     107  /// Provide the right hand side
     108  virtual void setRHS(const double* f);
     109 
     110  /// (Re-) initialize the system of equations
     111  void initialize();
     112  /// Set current integration time
     113  void setTime(const double& t);
    122114
    123115protected:
    124      void Assert(bool cond, const string& msg);
    125      void Terminate(string msg);
    126      void intDelay(vector<unsigned int> expr,vector<double> delay_max);
    127      void storeDelay(unsigned int expr_id,double expr_value,double time);
    128      void storeTime(double time);
    129      double delay(unsigned int expr_id,double expr_value, double delayTime, double delayMax);
    130      bool isConsistent();
    131 
     116    void Assert(bool cond, const string& msg);
     117    void Terminate(string msg);
     118    void intDelay(vector<unsigned int> expr,vector<double> delay_max);
     119    void storeDelay(unsigned int expr_id,double expr_value,double time);
     120    void storeTime(double time);
     121    double delay(unsigned int expr_id,double expr_value, double delayTime, double delayMax);
     122    bool isConsistent();
    132123
    133124    double getRealStartValue(string key);
    134     bool  getBoolStartValue(string key);
    135     int   getIntStartValue(string key);
     125    bool getBoolStartValue(string key);
     126    int getIntStartValue(string key);
    136127    void setRealStartValue(double& var,double val,string key);
    137128    void setBoolStartValue(bool& var,bool val, string key);
     
    139130
    140131    double
    141         _simTime;        ///< current simulation time (given by the solver)
     132        _simTime;           ///< current simulation time (given by the solver)
    142133
    143134    double
    144         *__z,        ///< "Extended state vector", containing all states and algebraic variables of all types
    145         *__zDot;       ///< "Extended vector of derivatives", containing all right hand sides of differential and algebraic equations
     135        *__z,             ///< "Extended state vector", containing all states and algebraic variables of all types
     136        *__zDot;            ///< "Extended vector of derivatives", containing all right hand sides of differential and algebraic equations
    146137    bool
    147         * _conditions,    ///< External conditions changed by the solver
     138        * _conditions,        ///< External conditions changed by the solver
    148139        * _time_conditions;
    149140
    150141    int
    151          _dimContinuousStates,
    152          _dimRHS,            ///< Dimension der rechten Seite
    153          _dimReal,            ///< Anzahl der reelwertigen Variablen
    154          _dimInteger,            ///< Anzahl der integerwertigen Variablen
    155          _dimBoolean,            ///< Anzahl der boolwertigen Variablen
    156          _dimString,          ///< Anzahl der stringwertigen Variablen
    157          _dimZeroFunc,          ///< Dimension (=Anzahl) Nullstellenfunktion
    158          _dimTimeEvent,          ///< Dimension (=Anzahl) Time event (start zeit und frequenz)
    159          _dimAE;        ///< Number (dimension) of algebraic equations (e.g. constraints from an algebraic loop)
     142        _dimContinuousStates,
     143        _dimRHS,              ///< Dimension der rechten Seite
     144        _dimReal,             ///< Anzahl der reelwertigen Variablen
     145        _dimInteger,            ///< Anzahl der integerwertigen Variablen
     146        _dimBoolean,          ///< Anzahl der boolwertigen Variablen
     147        _dimString,           ///< Anzahl der stringwertigen Variablen
     148        _dimZeroFunc,           ///< Dimension (=Anzahl) Nullstellenfunktion
     149        _dimTimeEvent,        ///< Dimension (=Anzahl) Time event (start zeit und frequenz)
     150        _dimAE;             ///< Number (dimension) of algebraic equations (e.g. constraints from an algebraic loop)
    160151
    161152    int
    162        * _time_event_counter;
    163        std::ostream *_outputStream;        ///< Output stream for results
     153    * _time_event_counter;
     154    std::ostream *_outputStream;        ///< Output stream for results
    164155
    165      IContinuous::UPDATETYPE _callType;
    166 
     156    IContinuous::UPDATETYPE _callType;
    167157
    168158    bool _initial;
     
    175165    InitVars<bool> _bool_start_values;
    176166
    177 
    178167    EventHandling _event_handling;
    179168
     
    183172    double _delay_max;
    184173    double _start_time;
    185     IGlobalSettings*  _global_settings; //this should be a reference, but this is not working if the libraries are linked statically
     174    IGlobalSettings* _global_settings; //this should be a reference, but this is not working if the libraries are linked statically
    186175};
    187176
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/OMCFactory/OMCFactory.h

    r21582 r22981  
    99class ISimController;
    1010struct SimSettings;
     11
    1112class OMCFactory
    1213{
    13     public:
     14public:
    1415    OMCFactory();
    15         OMCFactory(PATH library_path, PATH modelicasystem_path);
    16         virtual ~OMCFactory();
    17         void UnloadAllLibs(void);
    18         LOADERRESULT LoadLibrary(string libName,type_map& current_map);
    19         LOADERRESULT UnloadLibrary(shared_library lib);
     16  OMCFactory(PATH library_path, PATH modelicasystem_path);
     17  virtual ~OMCFactory();
     18 
     19  void UnloadAllLibs(void);
     20  LOADERRESULT LoadLibrary(string libName, type_map& current_map);
     21  LOADERRESULT UnloadLibrary(shared_library lib);
     22 
     23    virtual std::pair<boost::shared_ptr<ISimController>,SimSettings> createSimulation(int argc, const char* argv[]);
    2024
    21         virtual std::pair<boost::shared_ptr<ISimController>,SimSettings> createSimulation(int argc,  const char* argv[]);
    22 
    23     protected:
    24 
    25         SimSettings ReadSimulationParameter(int argc, const char* argv[]);
    26         //boost::shared_ptr<ISimController> _simController;
    27         std::map<string,shared_library> _modules;
    28         PATH _library_path;
    29         PATH _modelicasystem_path;
     25protected:
     26  SimSettings ReadSimulationParameter(int argc, const char* argv[]);
     27  //boost::shared_ptr<ISimController> _simController;
     28  std::map<string,shared_library> _modules;
     29  PATH _library_path;
     30  PATH _modelicasystem_path;
    3031};
    31 
    32 
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/OMCFactory/StaticOMCFactory.h

    r21929 r22981  
    1111    public:
    1212    StaticOMCFactory();
    13         StaticOMCFactory(PATH library_path, PATH modelicasystem_path);
     13    StaticOMCFactory(PATH library_path, PATH modelicasystem_path);
     14    virtual ~StaticOMCFactory();
    1415
    15         virtual ~StaticOMCFactory();
    16 
    17         virtual std::pair<boost::shared_ptr<ISimController>,SimSettings> createSimulation(int argc,  const char* argv[]);
     16    virtual std::pair<boost::shared_ptr<ISimController>, SimSettings> createSimulation(int argc, const char* argv[]);
    1817};
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/ObjectFactory.h

    r22573 r22981  
    33#include <SimCoreFactory/Policies/FactoryConfig.h>
    44#endif
     5
    56template<class T>
    67struct ObjectFactory
    78{
    8   ObjectFactory(PATH library_path,PATH modelicasystem_path,PATH config_path)
    9             :_library_path(library_path)
    10             ,_modelicasystem_path(modelicasystem_path)
    11             ,_config_path(config_path)
     9  ObjectFactory(PATH library_path, PATH modelicasystem_path, PATH config_path)
     10            : _library_path(library_path)
     11            , _modelicasystem_path(modelicasystem_path)
     12            , _config_path(config_path)
    1213    {
    13     _factory = boost::shared_ptr<T>(new T(library_path,modelicasystem_path));
    14   }
    15     virtual ~ObjectFactory() {};
    16     protected:
    17     boost::shared_ptr<T>  _factory;
     14    _factory = boost::shared_ptr<T>(new T(library_path, modelicasystem_path));
     15  }
     16   
     17  virtual ~ObjectFactory() {};
     18 
     19protected:
     20    boost::shared_ptr<T> _factory;
    1821    PATH _library_path;
    1922    PATH _modelicasystem_path;
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/Policies/FactoryConfig.h

    r22917 r22981  
    3030#include <boost/filesystem/operations.hpp>
    3131#include <boost/filesystem/path.hpp>
    32 
    33 
    3432#include <boost/unordered_map.hpp>
    3533
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/Policies/FactoryPolicy.h

    r22905 r22981  
    2424    #include <SimCoreFactory/Policies/SystemBodasFactory.h>
    2525    #include <SimCoreFactory/Policies/NonLinSolverBodasFactory.h>
    26   #include <SimCoreFactory/Policies/LinSolverBodasFactory.h>
     26  #include <SimCoreFactory/Policies/LinSolverBodasFactory.h>
    2727    /*Policy defines*/
    2828    typedef SystemBodasFactory<BodasFactory> SimControllerPolicy;
     
    4040    #include <SimCoreFactory/Policies/SystemFactory.h>
    4141    #include <SimCoreFactory/Policies/NonLinSolverFactory.h>
    42   #include <SimCoreFactory/Policies/LinSolverFactory.h>
     42  #include <SimCoreFactory/Policies/LinSolverFactory.h>
    4343    /*Policy defines*/
    4444    typedef SystemFactory<GenericFactory> SimControllerPolicy;
     
    4747    typedef NonLinSolverFactory<GenericFactory> NonLinSolverPolicy;
    4848    typedef SolverSettingsFactory<GenericFactory> SolverSettingsPolicy;
    49   typedef LinSolverFactory<GenericFactory> LinSolverPolicy;
     49  typedef LinSolverFactory<GenericFactory> LinSolverPolicy;
    5050
    5151#elif defined(OMC_BUILD) && !defined(ANALYZATION_MODE)
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/Policies/LinSolverOMCFactory.h

    r21932 r22981  
    77 */
    88template<class CreationPolicy>
    9 struct LinSolverOMCFactory : virtual public ObjectFactory<CreationPolicy> {
     9struct LinSolverOMCFactory : virtual public ObjectFactory<CreationPolicy>
     10{
     11public:
     12  LinSolverOMCFactory(PATH library_path, PATH modelicasystem_path, PATH config_path)
     13    : ObjectFactory<CreationPolicy>(library_path, modelicasystem_path, config_path)
     14    , _last_selected_solver("empty")
     15  {
     16    _linsolver_type_map = new type_map();
     17  }
     18  virtual ~LinSolverOMCFactory()
     19  {
     20    delete _linsolver_type_map;
     21    // ObjectFactory<CreationPolicy>::_factory->UnloadAllLibs(); todo solver lib wird in linsolver factory entlanden
     22  }
    1023
    11 public:
    12   LinSolverOMCFactory(PATH library_path, PATH modelicasystem_path,PATH config_path)
    13   :ObjectFactory<CreationPolicy>(library_path,modelicasystem_path,config_path)
    14   ,_last_selected_solver("empty")
    15   {
    16     _linsolver_type_map = new type_map();
    17   }
    18   virtual ~LinSolverOMCFactory()
    19   {
    20       delete _linsolver_type_map;
    21    // ObjectFactory<CreationPolicy>::_factory->UnloadAllLibs(); todo solver lib wird in linsolver factory entlanden
    22   }
     24  virtual boost::shared_ptr<ILinSolverSettings> createLinSolverSettings(string lin_solver)
     25    {
     26    string lin_solver_key;
    2327
    24   virtual boost::shared_ptr<ILinSolverSettings> createLinSolverSettings(string lin_solver)
    25     {
    26        string lin_solver_key;
    27 
    28         if(lin_solver.compare("umfpack")==0)
     28        if(lin_solver.compare("umfpack") == 0)
    2929        {
    30 
    3130            PATH umfpack_path = ObjectFactory<CreationPolicy>::_library_path;
    3231            PATH umfpack_name(UMFPACK_LIB);
     
    4241            throw std::invalid_argument("Selected linear solver is not available");
    4342
    44         _last_selected_solver =  lin_solver;
     43        _last_selected_solver = lin_solver;
    4544        string linsolversettings = lin_solver.append("Settings");
    4645        std::map<std::string, factory<ILinSolverSettings> >::iterator iter;
     
    5150            throw std::invalid_argument("No such linear solver Settings");
    5251        }
    53         boost::shared_ptr<ILinSolverSettings> linsolversetting= boost::shared_ptr<ILinSolverSettings>(iter->second.create());
     52        boost::shared_ptr<ILinSolverSettings> linsolversetting = boost::shared_ptr<ILinSolverSettings>(iter->second.create());
    5453        return linsolversetting;
    55    }
     54  }
    5655
    57    virtual boost::shared_ptr<IAlgLoopSolver> createLinSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<ILinSolverSettings> solver_settings)
    58    {
    59        if(_last_selected_solver.compare(solver_name)==0)
    60        {
     56  virtual boost::shared_ptr<IAlgLoopSolver> createLinSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<ILinSolverSettings> solver_settings)
     57  {
     58    if(_last_selected_solver.compare(solver_name) == 0)
     59    {
    6160            std::map<std::string, factory<IAlgLoopSolver,IAlgLoop*, ILinSolverSettings*> >::iterator iter;
    6261            std::map<std::string, factory<IAlgLoopSolver,IAlgLoop*, ILinSolverSettings*> >& linSolverFactory(_linsolver_type_map->get());
     
    6968
    7069            return solver;
    71        }
    72        else
     70    }
     71    else
    7372           throw std::invalid_argument("Selected linear solver is not available");
    74    }
     73  }
     74 
    7575protected:
    76      string _last_selected_solver;
     76  string _last_selected_solver;
     77 
    7778private:
    7879    type_map* _linsolver_type_map;
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/Policies/StaticSystemOMCFactory.h

    r22024 r22981  
    1313{
    1414public:
    15     StaticSystemOMCFactory(PATH library_path,PATH modelicasystem_path,PATH config_path)
    16         :SystemOMCFactory<CreationPolicy>(library_path,modelicasystem_path,config_path)
    17     {
     15  StaticSystemOMCFactory(PATH library_path, PATH modelicasystem_path, PATH config_path)
     16    :SystemOMCFactory<CreationPolicy>(library_path, modelicasystem_path, config_path)
     17  {
     18  }
    1819
    19     }
     20  virtual ~StaticSystemOMCFactory()
     21  {
     22  }
    2023
    21     virtual ~StaticSystemOMCFactory()
    22     {
    23     }
    24 
    25     virtual boost::shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactory(IGlobalSettings* globalSettings)
    26     {
    27       boost::shared_ptr<IAlgLoopSolverFactory>  algloopsolverfactory = boost::shared_ptr<IAlgLoopSolverFactory>(new AlgLoopSolverFactory(globalSettings,ObjectFactory<CreationPolicy>::_library_path,ObjectFactory<CreationPolicy>::_modelicasystem_path));
    28         return algloopsolverfactory;
    29     }
     24  virtual boost::shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactory(IGlobalSettings* globalSettings)
     25  {
     26    boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory = boost::shared_ptr<IAlgLoopSolverFactory>(new AlgLoopSolverFactory(globalSettings, ObjectFactory<CreationPolicy>::_library_path, ObjectFactory<CreationPolicy>::_modelicasystem_path));
     27    return algloopsolverfactory;
     28  }
    3029
    3130protected:
    32     virtual void initializeLibraries(PATH library_path,PATH modelicasystem_path,PATH config_path)
    33     {
    34     }
     31  virtual void initializeLibraries(PATH library_path, PATH modelicasystem_path, PATH config_path)
     32  {
     33  }
    3534};
  • trunk/SimulationRuntime/cpp/Include/SimCoreFactory/Policies/SystemOMCFactory.h

    r21584 r22981  
    99
    1010public:
    11     SystemOMCFactory(PATH library_path,PATH modelicasystem_path,PATH config_path)
    12         :ObjectFactory<CreationPolicy>(library_path,modelicasystem_path,config_path)
    13     {
    14         _use_modelica_compiler = false;
    15         _system_type_map = new type_map();
     11  SystemOMCFactory(PATH library_path,PATH modelicasystem_path,PATH config_path)
     12    :ObjectFactory<CreationPolicy>(library_path,modelicasystem_path,config_path)
     13  {
     14    _use_modelica_compiler = false;
     15    _system_type_map = new type_map();
    1616#ifndef ANALYZATION_MODE
    17         initializeLibraries(library_path, modelicasystem_path, config_path);
     17    initializeLibraries(library_path, modelicasystem_path, config_path);
    1818#endif
    19     }
     19  }
    2020
    21     virtual ~SystemOMCFactory()
    22     {
    23         delete _system_type_map;
    24         ObjectFactory<CreationPolicy>::_factory->UnloadAllLibs();
     21  virtual ~SystemOMCFactory()
     22  {
     23    delete _system_type_map;
     24    ObjectFactory<CreationPolicy>::_factory->UnloadAllLibs();
     25  }
    2526
    26     }
     27  virtual boost::shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactory(IGlobalSettings* globalSettings)
     28  {
     29    std::map<std::string, factory<IAlgLoopSolverFactory,IGlobalSettings*,PATH,PATH> >::iterator iter;
     30    std::map<std::string, factory<IAlgLoopSolverFactory,IGlobalSettings*,PATH,PATH> >& algloopsolver_factory(_system_type_map->get());
     31    iter = algloopsolver_factory.find("AlgLoopSolverFactory");
     32    if (iter ==algloopsolver_factory.end())
     33    {
     34      throw std::invalid_argument("No AlgLoopSolverFactory  found");
     35    }
     36    boost::shared_ptr<IAlgLoopSolverFactory>  algloopsolverfactory = boost::shared_ptr<IAlgLoopSolverFactory>(iter->second.create(globalSettings,ObjectFactory<CreationPolicy>::_library_path,ObjectFactory<CreationPolicy>::_modelicasystem_path));
    2737
    28     virtual boost::shared_ptr<IAlgLoopSolverFactory> createAlgLoopSolverFactory(IGlobalSettings* globalSettings)
    29     {
    30         std::map<std::string, factory<IAlgLoopSolverFactory,IGlobalSettings*,PATH,PATH> >::iterator iter;
    31         std::map<std::string, factory<IAlgLoopSolverFactory,IGlobalSettings*,PATH,PATH> >& algloopsolver_factory(_system_type_map->get());
    32         iter = algloopsolver_factory.find("AlgLoopSolverFactory");
    33         if (iter ==algloopsolver_factory.end())
    34          {
    35             throw std::invalid_argument("No AlgLoopSolverFactory  found");
    36         }
    37         boost::shared_ptr<IAlgLoopSolverFactory>  algloopsolverfactory = boost::shared_ptr<IAlgLoopSolverFactory>(iter->second.create(globalSettings,ObjectFactory<CreationPolicy>::_library_path,ObjectFactory<CreationPolicy>::_modelicasystem_path));
     38    return algloopsolverfactory;
     39  }
    3840
    39         return algloopsolverfactory;
    40     }
     41  virtual std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> > createSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory)
     42  {
     43    boost::shared_ptr<ISimData> simData = createSimDataCallback();
     44    boost::shared_ptr<IMixedSystem> system = createSystemCallback(globalSettings, algloopsolverfactory, simData);
     45    return std::make_pair(system,simData);
     46  }
    4147
    42     virtual std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > createSystem(boost::shared_ptr<ISimData> (*createSimDataCallback)(), boost::shared_ptr<IMixedSystem> (*createSystemCallback)(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>), IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory)
    43   {
    44       boost::shared_ptr<ISimData> simData = createSimDataCallback();
    45       boost::shared_ptr<IMixedSystem> system = createSystemCallback(globalSettings, algloopsolverfactory, simData);
    46       return std::make_pair(system,simData);
    47   }
     48  std::pair<boost::shared_ptr<IMixedSystem>, boost::shared_ptr<ISimData> >  createSystem(string modelLib,string modelKey,IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory)
     49  {
     50    PATH modelica_path = ObjectFactory<CreationPolicy>::_modelicasystem_path;
     51    PATH modelica_name(modelLib);
     52    modelica_path/=modelica_name;
     53    LOADERRESULT result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(modelica_path.string(),*_system_type_map);
     54    if (result != LOADER_SUCCESS)
     55    {
     56      std::stringstream tmp;
     57      tmp << "Failed loading System library!" << std::endl << modelica_path.string();
     58      throw std::runtime_error(tmp.str());
     59    }
    4860
    49     std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> >  createSystem(string modelLib,string modelKey,IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory)
    50     {
    51        PATH modelica_path = ObjectFactory<CreationPolicy>::_modelicasystem_path;
    52         PATH modelica_name(modelLib);
    53         modelica_path/=modelica_name;
    54         LOADERRESULT result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(modelica_path.string(),*_system_type_map);
    55         if (result != LOADER_SUCCESS)
    56         {
    57             std::stringstream tmp;
    58             tmp << "Failed loading System library!" << std::endl << modelica_path.string();
    59             throw std::runtime_error(tmp.str());
    60         }
     61    std::map<std::string, factory<IMixedSystem, IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData> > >::iterator system_iter;
     62    std::map<std::string, factory<IMixedSystem, IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData> > >& factories(_system_type_map->get());
     63    system_iter = factories.find(modelKey);
     64    if (system_iter == factories.end())
     65    {
     66      throw std::invalid_argument("No system found");
     67    }
    6168
    62         std::map<std::string, factory<IMixedSystem,IGlobalSettings*,boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData> > >::iterator system_iter;
    63         std::map<std::string, factory<IMixedSystem,IGlobalSettings*,boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData> > >& factories(_system_type_map->get());
    64         system_iter = factories.find(modelKey);
    65         if (system_iter ==factories.end())
    66         {
    67             throw std::invalid_argument("No system found");
    68         }
     69    std::map<std::string, factory<ISimData> >::iterator simdata_iter;
     70    std::map<std::string, factory<ISimData > >& simdata_factory(_system_type_map->get());
     71    simdata_iter = simdata_factory.find("SimData");
     72    if (simdata_iter == simdata_factory.end())
     73    {
     74      throw std::invalid_argument("No simdata found");
     75    }
     76    boost::shared_ptr<ISimData> simData(simdata_iter->second.create());
     77    boost::shared_ptr<IMixedSystem> system(system_iter->second.create(globalSettings,algloopsolverfactory,simData));
     78    return std::make_pair(system, simData);
     79  }
    6980
    70 
    71         std::map<std::string, factory<ISimData> >::iterator simdata_iter;
    72         std::map<std::string, factory<ISimData > >& simdata_factory(_system_type_map->get());
    73         simdata_iter = simdata_factory.find("SimData");
    74         if (simdata_iter ==simdata_factory.end())
    75         {
    76             throw std::invalid_argument("No simdata found");
    77         }
    78         boost::shared_ptr<ISimData> simData(simdata_iter->second.create());
    79         boost::shared_ptr<IMixedSystem> system(system_iter->second.create(globalSettings,algloopsolverfactory,simData));
    80         return std::make_pair(system,simData);
    81     }
    82 
    83     std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> >  createModelicaSystem(PATH modelica_path,string modelKey, IGlobalSettings* globalSettings,boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory)
    84     {
    85         throw std::runtime_error("Modelica is not supported");
    86     }
     81  std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > createModelicaSystem(PATH modelica_path, string modelKey, IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> algloopsolverfactory)
     82  {
     83    throw std::runtime_error("Modelica is not supported");
     84  }
    8785
    8886protected:
    89     virtual void initializeLibraries(PATH library_path,PATH modelicasystem_path,PATH config_path)
    90     {
    91         PATH systemfactory_path = ObjectFactory<CreationPolicy>::_library_path;
    92         PATH system_name(SYSTEM_LIB);
    93         systemfactory_path/=system_name;
     87  virtual void initializeLibraries(PATH library_path,PATH modelicasystem_path,PATH config_path)
     88  {
     89    PATH systemfactory_path = ObjectFactory<CreationPolicy>::_library_path;
     90    PATH system_name(SYSTEM_LIB);
     91    systemfactory_path/=system_name;
    9492
    95         LOADERRESULT result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(systemfactory_path.string(),*_system_type_map);
    96         if (result != LOADER_SUCCESS)
    97         {
    98             std::stringstream tmp;
    99             tmp << "Failed loading System library!" << std::endl << systemfactory_path.string();
    100             throw std::runtime_error(tmp.str());
    101         }
     93    LOADERRESULT result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(systemfactory_path.string(), *_system_type_map);
     94    if (result != LOADER_SUCCESS)
     95    {
     96      std::stringstream tmp;
     97      tmp << "Failed loading System library!" << std::endl << systemfactory_path.string();
     98      throw std::runtime_error(tmp.str());
     99    }
    102100
    103         PATH dataexchange_path = ObjectFactory<CreationPolicy>::_library_path;
    104         PATH dataexchange_name(DATAEXCHANGE_LIB);
    105         dataexchange_path/=dataexchange_name;
     101    PATH dataexchange_path = ObjectFactory<CreationPolicy>::_library_path;
     102    PATH dataexchange_name(DATAEXCHANGE_LIB);
     103    dataexchange_path/=dataexchange_name;
    106104
    107         result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(dataexchange_path.string(),*_system_type_map);
    108         if (result != LOADER_SUCCESS)
    109         {
    110             throw std::runtime_error("Failed loading Dataexchange library!");
    111         }
    112     }
     105    result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(dataexchange_path.string(), *_system_type_map);
     106    if (result != LOADER_SUCCESS)
     107    {
     108      throw std::runtime_error("Failed loading Dataexchange library!");
     109    }
     110  }
    113111
    114     bool _use_modelica_compiler;
    115     type_map* _system_type_map;
    116 
     112  bool _use_modelica_compiler;
     113  type_map* _system_type_map;
    117114};
Note: See TracChangeset for help on using the changeset viewer.