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

Contents of /trunk/pygtk/integratorreporter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 711 - (show annotations) (download) (as text)
Thu Jun 29 16:18:54 2006 UTC (17 years, 11 months ago) by johnpye
File MIME type: text/x-c++src
File size: 2232 byte(s)
ExtRel_Evaluate_RHS is working now! (At least for my 1+1=2 example).
Working now on fixing ExtRel_Evaluate_LHS.
1 #include "integrator.h"
2 #include "integratorreporter.h"
3
4 extern "C"{
5 #include <utilities/error.h>
6 #include <solver/integrator.h>
7 }
8
9 #include <stdexcept>
10 using namespace std;
11
12 IntegratorReporterCxx::IntegratorReporterCxx(Integrator *integrator){
13 // Initialise the C-API structure with flat function pointers
14 reporter.init = &ascxx_integratorreporter_init;
15 reporter.write = &ascxx_integratorreporter_write;
16 reporter.write_obs = &ascxx_integratorreporter_write_obs;
17 reporter.close = &ascxx_integratorreporter_close;
18 this->integrator=integrator;
19 }
20
21 IntegratorReporterCxx::~IntegratorReporterCxx(){
22 // nothing, just virtual destructor
23 CONSOLE_DEBUG("DESTROYING INTEGRATOR REPORTER CXX");
24 }
25
26 IntegratorReporter *
27 IntegratorReporterCxx::getInternalType(){
28 return &reporter;
29 }
30
31 int
32 IntegratorReporterCxx::initOutput(){
33 return ERROR_REPORTER_NOLINE(ASC_USER_NOTE,"Starting integration reporting...");
34 }
35
36 int
37 IntegratorReporterCxx::closeOutput(){
38 return ERROR_REPORTER_NOLINE(ASC_USER_NOTE,"Closing integration reporting...");
39 }
40
41 int
42 IntegratorReporterCxx::updateStatus(){
43 double t = integrator->getCurrentTime();
44 return ERROR_REPORTER_NOLINE(ASC_USER_NOTE,"t = %f",t);
45
46 }
47
48 int
49 IntegratorReporterCxx::recordObservedValues(){
50 CONSOLE_DEBUG("...");
51 double *data = ASC_NEW_ARRAY(double,integrator->getNumObservedVars());
52 integrator_get_observations(integrator->getInternalType(),data);
53 return 0;
54 }
55
56 Integrator *
57 IntegratorReporterCxx::getIntegrator(){
58 return integrator;
59 }
60
61 int ascxx_integratorreporter_init(IntegratorSystem *blsys){
62 CONSOLE_DEBUG("...");
63 IntegratorReporterCxx *r = (IntegratorReporterCxx *)blsys->clientdata;
64 if(r==NULL){
65 throw runtime_error("blsys->clientdata was null");
66 }
67 return r->initOutput();
68 }
69
70 int ascxx_integratorreporter_write(IntegratorSystem *blsys){
71 IntegratorReporterCxx *r = (IntegratorReporterCxx *)blsys->clientdata;
72 return r->updateStatus();
73 }
74
75 int ascxx_integratorreporter_write_obs(IntegratorSystem *blsys){
76 IntegratorReporterCxx *r = (IntegratorReporterCxx *)blsys->clientdata;
77 return r->recordObservedValues();
78 }
79
80 int ascxx_integratorreporter_close(IntegratorSystem *blsys){
81 IntegratorReporterCxx *r = (IntegratorReporterCxx *)blsys->clientdata;
82 return r->closeOutput();
83 }

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