/[ascend]/trunk/pygtk/simulation.cpp
ViewVC logotype

Diff of /trunk/pygtk/simulation.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 899 by johnpye, Tue Oct 24 11:05:18 2006 UTC revision 900 by johnpye, Wed Oct 25 06:03:04 2006 UTC
# Line 44  extern "C"{ Line 44  extern "C"{
44  #include <compiler/check.h>  #include <compiler/check.h>
45  #include <compiler/name.h>  #include <compiler/name.h>
46  #include <compiler/pending.h>  #include <compiler/pending.h>
47    #include <compiler/importhandler.h>
48    
49  #include <utilities/readln.h>  #include <utilities/readln.h>
50  #include <solver/mtx.h>  #include <solver/mtx.h>
# Line 151  Simulation::run(const Method &method){ Line 152  Simulation::run(const Method &method){
152  }  }
153    
154  void  void
155    Simulation::runDefaultMethod(){
156        Method m = getType().getMethod(SymChar("on_load"));
157        run(m);
158    }  
159    
160    void
161  Simulation::run(const Method &method, Instanc &model){  Simulation::run(const Method &method, Instanc &model){
162    
163        // set the 'sim' pointer to our local variable...
164        CONSOLE_DEBUG("Setting shared pointer 'sim'");
165        importhandler_setsharedpointer("sim",this);
166    
167      cerr << "RUNNING PROCEDURE " << method.getName() << endl;      cerr << "RUNNING PROCEDURE " << method.getName() << endl;
168      Nam name = Nam(method.getSym());      Nam name = Nam(method.getSym());
169      //cerr << "CREATED NAME '" << name.getName() << "'" << endl;      //cerr << "CREATED NAME '" << name.getName() << "'" << endl;
170    
171    
172      Proc_enum pe;      Proc_enum pe;
173      pe = Initialize(      pe = Initialize(
174          &*(model.getInternalType()) ,name.getInternalType(), "__not_named__"          &*(model.getInternalType()) ,name.getInternalType(), "__not_named__"
# Line 163  Simulation::run(const Method &method, In Line 176  Simulation::run(const Method &method, In
176          ,0, NULL, NULL          ,0, NULL, NULL
177      );      );
178    
179        // clear out the 'sim' pointer (soon it will be invalid)
180        importhandler_setsharedpointer("sim",NULL);
181        CONSOLE_DEBUG("Cleared shared pointer 'sim'");
182    
183      if(pe == Proc_all_ok){      if(pe == Proc_all_ok){
184          ERROR_REPORTER_NOLINE(ASC_PROG_NOTE,"Method '%s' was run (check above for errors)\n",method.getName());          ERROR_REPORTER_NOLINE(ASC_PROG_NOTE,"Method '%s' was run (check above for errors)\n",method.getName());
185          //cerr << "METHOD " << method.getName() << " COMPLETED OK" << endl;          //cerr << "METHOD " << method.getName() << " COMPLETED OK" << endl;
# Line 391  Simulation::getSingularityInfo() const{ Line 408  Simulation::getSingularityInfo() const{
408    
409  void  void
410  Simulation::setSolver(Solver &solver){  Simulation::setSolver(Solver &solver){
411      //cerr << "SETTING SOLVER ON SIMULATION TO " << solver.getName() << endl;      CONSOLE_DEBUG("Setting solver on sim %p, root inst %p",this,this->simroot.getInternalType());
412        if(!is_built)throw runtime_error("Can't setSolver: simulation has not been built yet");
413        if(!sys)throw runtime_error("Can't setSolver: 'sys' is not assigned.");
414    
     if(!sys)throw runtime_error("Can't solve: Simulation system has not been built yet.");  
415      // Update the solver object because sometimes an alternative solver can be returned, apparently.      // Update the solver object because sometimes an alternative solver can be returned, apparently.
416    
417      int selected = slv_select_solver(sys, solver.getIndex());      int selected = slv_select_solver(sys, solver.getIndex());
# Line 433  Simulation::getSolver() const{ Line 451  Simulation::getSolver() const{
451  void  void
452  Simulation::build(){  Simulation::build(){
453      //cerr << "BUILDING SIMULATION..." << endl;      //cerr << "BUILDING SIMULATION..." << endl;
454        if(is_built){
455            throw runtime_error("Simulation is already built");
456        }
457    
458      Instance *i1 = getModel().getInternalType();      Instance *i1 = getModel().getInternalType();
459      sys = system_build(&*i1);      sys = system_build(&*i1);
460      if(!sys){      if(!sys){
# Line 451  Simulation::build(){ Line 473  Simulation::build(){
473  */  */
474  SolverParameters  SolverParameters
475  Simulation::getSolverParameters() const{  Simulation::getSolverParameters() const{
476      if(!sys)throw runtime_error("Can't getSolverParameters: Simulation system has not been built yet.");      if(!is_built)throw runtime_error("Can't getSolverParameters: Simulation system has not been built yet.");
477        if(!sys)throw runtime_error("Can't getSolverParameters: Simulation system has no 'sys' assigned.");
478    
479      slv_parameters_t p;      slv_parameters_t p;
480      slv_get_parameters(sys,&p);      slv_get_parameters(sys,&p);

Legend:
Removed from v.899  
changed lines
  Added in v.900

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22