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

Contents of /trunk/pygtk/solver.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 900 - (show annotations) (download) (as text)
Wed Oct 25 06:03:04 2006 UTC (13 years, 11 months ago) by johnpye
File MIME type: text/x-c++src
File size: 2284 byte(s)
The 'sim' object is correctly accessible from script methods now, even if run during on_load.
Added 'getSimulation' to registry.cpp, added 'runDefaultMethod' to Simulation, added 'getMethod' to Type.
Running of 'on_load' is instigated at the Python level now, so that relevent python variables are set at simulations are built, etc. This appears to have cause some changes to the way the solver behaves, possibly.
Added SearchProcList to exports in libascend.

1 #include "config.h"
2 #include "reporter.h"
3 #include "solver.h"
4
5 #include <stdexcept>
6 #include <iostream>
7 #include <sstream>
8 using namespace std;
9
10 extern "C"{
11 #include <solver/system.h>
12 #include <solver/slvDOF.h>
13 #include <solver/slv_stdcalls.h>
14 }
15
16 /**
17 Create a solver by name (it must already be registered)
18 Warning, this ctor throws an exception if the name is invalid!
19 */
20 Solver::Solver(const string &name){
21 cerr << "CREATING SOLVER, name = " << name << endl;
22 this->name = name;
23 }
24
25 Solver::Solver(const Solver &old){
26 this->name = old.name;
27 cerr << "COPIED SOLVER, name = " << name << endl;
28 }
29
30 Solver::Solver(){
31 cerr << "RETREIVING SOLVER NAME" << name << endl;
32 this->name = "";
33 }
34
35 const int
36 Solver::getIndex() const{
37 int index = slv_lookup_client(name.c_str());
38 if(index < 0){
39 stringstream ss;
40 ss << "Unknown or unregistered solver '" << name << "'";
41 throw runtime_error(ss.str());
42 }
43 //cerr << "))))))))))))))SOLVER INDEX RETURNED IS " << index << endl;
44 return index;
45 }
46
47 const string &
48 Solver::getName() const{
49 return name;
50 }
51
52 //---------------------------------
53 // >>>> GLOBAL FUNCTIONS <<<<
54 // for registering solvers and querying the complete list
55
56 void
57 registerSolver(SlvRegistration regfuncptr){
58 int newclient =-1;
59 int res = slv_register_client(regfuncptr,NULL,NULL,&newclient);
60 if(res!=0){
61 ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"Unable to register solver");
62 throw runtime_error("Solver::registerSolver: Unable to register solver");
63 }else{
64 string name = slv_solver_name(newclient);
65 cerr << "Registered solver '" << name << "' (index " << newclient << ")" << endl;
66 }
67 }
68
69 const vector<Solver>
70 getSolvers(){
71 ASC_DLLSPEC(int) g_SlvNumberOfRegisteredClients;
72 vector<Solver> v;
73 for(int i=0; i < g_SlvNumberOfRegisteredClients; ++i){
74 v.push_back(Solver(slv_solver_name(i)));
75 }
76 return v;
77 }
78
79 /**
80 Register the solvers which will be accessible via index number. The order you
81 register them determines the resulting index ids, so don't mess around with the
82 order of stuff in this function.
83
84 Add to this list as you feel necessary...
85 */
86 void
87 registerStandardSolvers(){
88 //cerr << "------------- REGISTERING SOLVERS -----------------" << endl;
89 SlvRegisterStandardClients();
90 /*
91 registerSolver(slv3_register);
92 registerSolver(slv9_register);
93 */
94 }
95

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