/
simulationsupportpythonwrapper.h
142 lines (97 loc) · 5.36 KB
/
simulationsupportpythonwrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
//==============================================================================
// Simulation support Python wrapper
//==============================================================================
#pragma once
//==============================================================================
#include <QList>
#include <QObject>
//==============================================================================
#include "pythonbegin.h"
#include "PythonQt/PythonQtPythonInclude.h"
#include "pythonend.h"
//==============================================================================
namespace OpenCOR {
//==============================================================================
namespace DataStore {
class DataStoreVariable;
} // namespace DataStore
//==============================================================================
namespace SimulationSupport {
//==============================================================================
class Simulation;
class SimulationData;
class SimulationResults;
//==============================================================================
// Note: we bind the SimulationData object to the the first parameter of
// updateParameters() to create a function object to be called when
// simulation parameters are updated...
#if defined(Q_OS_WIN)
using SimulationDataUpdatedFunction = std::_Binder<std::_Unforced, void (*)(SimulationData *), SimulationData *>;
#elif defined(Q_OS_LINUX)
using SimulationDataUpdatedFunction = std::_Bind_helper<false, void (*)(SimulationData *), SimulationData *>::type;
#else
using SimulationDataUpdatedFunction = std::__bind<void (*)(SimulationData *), SimulationData *>;
#endif
//==============================================================================
class SimulationSupportPythonWrapper : public QObject
{
Q_OBJECT
public:
explicit SimulationSupportPythonWrapper(PyObject *pModule,
QObject *pParent);
private:
qint64 mElapsedTime;
QString mErrorMessage;
public slots:
bool valid(OpenCOR::SimulationSupport::Simulation *pSimulation);
PyObject * issues(OpenCOR::SimulationSupport::Simulation *pSimulation) const;
void clearResults(OpenCOR::SimulationSupport::Simulation *pSimulation);
void resetParameters(OpenCOR::SimulationSupport::Simulation *pSimulation);
bool run(OpenCOR::SimulationSupport::Simulation *pSimulation);
// Set a simulation's point data
void setStartingPoint(OpenCOR::SimulationSupport::SimulationData *pSimulationData,
const double &pStartingPoint,
const bool &pRecompute = true);
void setEndingPoint(OpenCOR::SimulationSupport::SimulationData *pSimulationData,
const double &pEndingPoint);
void setPointInterval(OpenCOR::SimulationSupport::SimulationData *pSimulationData,
const double &pPointInterval);
// Assign a solver
void setOdeSolver(OpenCOR::SimulationSupport::SimulationData *pSimulationData, const QString &pOdeSolverName);
void setNlaSolver(OpenCOR::SimulationSupport::SimulationData *pSimulationData, const QString &pNlaSolverName);
// Access a simulation's parameter data
PyObject * algebraic(OpenCOR::SimulationSupport::SimulationData *pSimulationData) const;
PyObject * constants(OpenCOR::SimulationSupport::SimulationData *pSimulationData) const;
PyObject * rates(OpenCOR::SimulationSupport::SimulationData *pSimulationData) const;
PyObject * states(OpenCOR::SimulationSupport::SimulationData *pSimulationData) const;
// Access a simulation's result data
const OpenCOR::DataStore::DataStoreVariable * points(OpenCOR::SimulationSupport::SimulationResults *pSimulationResults) const;
PyObject * algebraic(OpenCOR::SimulationSupport::SimulationResults *pSimulationResults) const;
PyObject * constants(OpenCOR::SimulationSupport::SimulationResults *pSimulationResults) const;
PyObject * states(OpenCOR::SimulationSupport::SimulationResults *pSimulationResults) const;
PyObject * rates(OpenCOR::SimulationSupport::SimulationResults *pSimulationResults) const;
private slots:
void error(const QString &pErrorMessage);
void simulationFinished(const qint64 &pElapsedTime);
signals:
void gotElapsedTime();
};
//==============================================================================
} // namespace SimulationSupport
} // namespace OpenCOR
//==============================================================================
// End of file
//==============================================================================