6 |
#include <solver/integrator.h> |
#include <solver/integrator.h> |
7 |
} |
} |
8 |
|
|
9 |
|
#include <vector> |
10 |
#include <stdexcept> |
#include <stdexcept> |
11 |
|
#include <iostream> |
12 |
|
#include <iterator> |
13 |
|
#include <sstream> |
14 |
using namespace std; |
using namespace std; |
15 |
|
|
16 |
//--------------------------------------------- |
//--------------------------------------------- |
41 |
return 1; |
return 1; |
42 |
} |
} |
43 |
|
|
44 |
|
//------------------------------------------------------------------------------ |
45 |
|
// SIMPLE CONSOLE INTEGRATOR REPORTER |
46 |
|
|
47 |
|
IntegratorReporterConsole::IntegratorReporterConsole(Integrator *integrator) |
48 |
|
: IntegratorReporterCxx(integrator), f(cout){ |
49 |
|
// nothing else |
50 |
|
} |
51 |
|
|
52 |
|
IntegratorReporterConsole::~IntegratorReporterConsole(){ |
53 |
|
// nothing else |
54 |
|
} |
55 |
|
|
56 |
|
int |
57 |
|
IntegratorReporterConsole::initOutput(){ |
58 |
|
long nobs = integrator->getNumObservedVars(); |
59 |
|
stringstream ss; |
60 |
|
for(long i=0; i<nobs; ++i){ |
61 |
|
if(i){ |
62 |
|
f << "\t"; |
63 |
|
ss << "\t"; |
64 |
|
} |
65 |
|
Variable v = integrator->getObservedVariable(i); |
66 |
|
f << v.getName(); |
67 |
|
ss << "-------"; |
68 |
|
} |
69 |
|
f << endl; |
70 |
|
f << ss.str() << endl; |
71 |
|
return 1; |
72 |
|
} |
73 |
|
|
74 |
|
int IntegratorReporterConsole::closeOutput(){ |
75 |
|
return 1; |
76 |
|
} |
77 |
|
|
78 |
|
int IntegratorReporterConsole::updateStatus(){ |
79 |
|
return 1; |
80 |
|
} |
81 |
|
|
82 |
|
int IntegratorReporterConsole::recordObservedValues(){ |
83 |
|
vector<double> data(integrator->getNumObservedVars()); |
84 |
|
integrator_get_observations(integrator->getInternalType(),&data[0]); |
85 |
|
copy(data.begin(),data.end(),ostream_iterator<double>(f,"\t")); |
86 |
|
f << endl; |
87 |
|
return 1; |
88 |
|
} |
89 |
|
|
90 |
//---------------------------------------------------- |
//---------------------------------------------------- |
91 |
// DEFAULT INTEGRATOR REPORTER (reporter start and end, outputs time at each step) |
// DEFAULT INTEGRATOR REPORTER (reporter start and end, outputs time at each step) |