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

Diff of /trunk/pygtk/integrator.cpp

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

revision 1451 by jpye, Sat Apr 7 14:43:31 2007 UTC revision 1452 by jpye, Mon May 28 14:01:51 2007 UTC
# Line 170  Integrator::writeDebug(FILE *fp) const{ Line 170  Integrator::writeDebug(FILE *fp) const{
170  }  }
171    
172  void  void
173  Integrator::setEngine(IntegratorEngine engine){  Integrator::setEngine(const string &name){
174      int res = integrator_set_engine(this->blsys, engine);      int res = integrator_set_engine(this->blsys, name.c_str());
175      if(!res)return;      if(!res)return; // all OK
176      if(res==1)throw range_error("Unknown integrator");      if(res==1)throw range_error("Unknown integrator");
177      if(res==2)throw range_error("Invalid integrator");      if(res==2)throw range_error("Invalid integrator");
178    
179      stringstream ss;      stringstream ss;
180      ss << "Unknown error in setEngine (res = " << res << ")";      ss << "Unknown error in setEngine (res = " << res << ")";
181      throw runtime_error(ss.str());      throw runtime_error(ss.str());
182  }  }
183    
 void  
 Integrator::setEngine(int engine){  
     setEngine((IntegratorEngine)engine);  
 }  
   
 void  
 Integrator::setEngine(const string &name){  
     CONSOLE_DEBUG("Setting integration engine to '%s'",name.c_str());  
     IntegratorEngine engine = INTEG_UNKNOWN;  
 #ifdef ASC_WITH_LSODE  
     if(name=="LSODE")engine = INTEG_LSODE;  
 #endif  
 #ifdef ASC_WITH_IDA  
     if(name=="IDA")engine = INTEG_IDA;  
 #endif  
     if(engine==INTEG_UNKNOWN){  
         throw runtime_error("Unkown integrator name");  
     }  
     setEngine(engine);  
 }  
   
184  /**  /**
185      Ideally this list would be dynamically generated based on what solvers      Ideally this list would be dynamically generated based on what solvers
186      are available or are in memory.      are available or are in memory.
187  */  */
188  map<int,string>  vector<string>
189  Integrator::getEngines(){  Integrator::getEngines(){
190      map<int,string> m;      vector<string> m;
191      const IntegratorLookup *list = integrator_get_engines();      const gl_list_t *L = integrator_get_engines();
192      while(list->id != INTEG_UNKNOWN){      for(unsigned long i=1; i<=gl_length(L); ++i){
193          if(list->name==NULL)throw runtime_error("list->name is NULL");          const IntegratorInternals *I = (const IntegratorInternals *)gl_fetch(L,i);
194          m.insert(pair<int,string>(list->id,list->name));          m.push_back(I->name);
         ++list;  
195      }      }
196      return m;      return m;
197  }  }
198    
199  string  string
200  Integrator::getName() const{  Integrator::getName() const{
201      map<int,string> m=getEngines();      const IntegratorInternals *I = integrator_get_engine(blsys);
202      map<int,string>::iterator f = m.find(integrator_get_engine(blsys));      if(I==NULL){
     if(f==m.end()){  
203          throw runtime_error("No engine selected");          throw runtime_error("No engine selected");
204      }      }
205      return f->second;      return I->name;
206  }  }
207    
208  /**  /**

Legend:
Removed from v.1451  
changed lines
  Added in v.1452

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