Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00017 #ifndef __DSIM_INTEGRATOR__
00018 #define __DSIM_INTEGRATOR__
00019
00020 #include "dsim_variable.h"
00021 class dsim_simulation;
00022 class ds_dictionary;
00023
00033 class dsim_integrator
00034 {
00035 public:
00037 dsim_integrator(const char *name);
00038 static dsim_integrator *load_integrator(const char *name,const char *type,const char *library);
00040 virtual ~dsim_integrator();
00041
00047 enum dsim_integrator_result { dsim_integ_none = 0,
00048 dsim_integ_continue = 1,
00049 dsim_integ_finished = 2
00050 };
00051 const char *name() const { return _name; }
00052
00054 virtual void *describe_setup(void *ds);
00056 void describe_setup_command(void *ds,const char *command,const char *description);
00058 virtual bool parse_setup(const char *command,const char *data);
00059
00061 virtual void setup_variable(dsim_variable &variable);
00063 virtual void cleanup_variable(dsim_variable &variable);
00064
00066 virtual double effective_time_for_step(int step,double t,double dt);
00068 virtual dsim_integrator::dsim_integrator_result step_integration(dsim_variable &variable,int step,double t,double dt);
00069
00070
00071
00072
00073
00075 void request_new_time_delta(double dt,bool restart = false);
00076
00077
00079 void error(const char *msg,...) const;
00081 void warning(const char *msg,...) const;
00083 void log(const char *msg,...) const;
00084 private:
00085 void add_variable(dsim_variable &variable);
00086
00087 void start_integration(double t,double dt);
00088 void step_variable(dsim_variable &variable,int step,double t,double dt);
00089 enum dsim_integrator_result complete_integration_step(int step,double t,double dt);
00090 bool complete_integration(double &new_timestep);
00091
00092 void annotate_description(ds_dictionary *desc);
00093
00094 char *_name;
00095 dsim_integrator::dsim_integrator_result _result;
00096 std::vector<dsim_variable> _variables;
00097 double _next_dt;
00098 bool _need_restart;
00099 dsim_simulation *_simulation;
00100
00101 friend class dsim_simulation;
00102 friend class dsim_model;
00103 };
00104
00110 typedef dsim_integrator *(*dsim_integrator_factory_t)(const char *);
00111
00112 #endif