00001 00024 #ifndef CALCULATEMANAGER_H 00025 #define CALCULATEMANAGER_H 00026 00027 #include <QObject> 00028 #include <QFile> 00029 #include <QTextStream> 00030 #include <QString> 00031 #include <QVariant> 00032 #include <QMessageBox> 00033 00034 #include <vector> 00035 00036 #include "calculateflowthread.h" 00037 #include "../../Support/calculatefunctions.h" 00038 #include "../../Support/data.h" 00039 #include "../../Support/frictionfunctions.h" 00040 #include "../../Support/calculateregimeinterface.h" 00041 #include "defines.h" 00042 00043 class CalculateManager : public QObject 00044 { 00045 Q_OBJECT 00046 public: 00047 CalculateManager(QWidget *parent, int simulationId, Data *data, FrictionFunctions *frictionFunctions, CalculateFunctions *calculateFunctions, bool useMinimumHoldupCriterion, unsigned int resolution, 00048 unsigned int threads = 1, scale_t scaleType = SCALE_LIN, double tolerance = 0.0000001, QString calculationName = ""); 00049 CalculateManager(QWidget *parent, int simulationId, Data *data, FrictionFunctions *frictionFunctions, RegimeTransitionInterface *regimeTransitionPlugin, 00050 CalculateFunctions *calculateFunctions, unsigned int resolution, 00051 unsigned int threads = 1, scale_t scaleType = SCALE_LIN, double tolerance = 0.0000001, QString calculationName = ""); 00052 ~CalculateManager(); 00053 void run(); 00054 void quit(); 00056 inline bool isRunning() { return _isRunning; }; 00058 inline bool isFinished() { return _isFinished; }; 00060 inline bool isTerminated() { return _isTerminated; }; 00062 inline int simulationID() { return _simulationId; }; 00064 inline const Data * data() { return _data; }; 00065 00066 std::vector<double> diameterGasList(); 00067 std::vector<double> xList(); 00068 std::vector<double> yList(); 00069 std::vector<double> holdupList(); 00070 std::vector<double> alphaList(); 00071 std::vector<double> dpdxList(); 00072 00073 int progress(); 00074 00075 QString calculationName(); 00076 QString pluginName(); 00077 00078 QString xVariableName(); 00079 double xVariableMin(); 00080 double xVariableMax(); 00081 00082 private: 00083 void generateXList(std::vector<double> &xList); 00084 00085 QWidget *_parent; 00086 int _simulationId; 00087 Data *_data; 00088 FrictionFunctions *_frictionFunctions; 00089 CalculateFunctions *_calculateFunctions; 00090 RegimeTransitionInterface *_regimeTransitionPlugin; 00091 bool _isFinished; 00092 bool _isTerminated; 00093 bool _isTerminating; 00094 bool _isRunning; 00095 bool _useMinimumHoldupCriterion; 00096 int _progress; 00097 std::vector<CalculateFlowThread *> _ctVector; 00098 CalculateFlowThread *_ct; 00099 int _nThreadsLeft; 00100 variable_t _variableWhat; 00101 unsigned int _resolution; 00102 unsigned int _threads; 00103 scale_t _scaleType; 00104 double _tolerance; 00105 QString _calculationName; 00106 QString _pluginName; 00107 QStringList errorMsgs; 00108 00109 unsigned int _finishedSimulations; 00110 unsigned int _simulationsStarted; 00111 00112 std::vector<double> _diameterGasList; 00113 std::vector<double> _xList; 00114 std::vector<double> _yList; 00115 std::vector<double> _holdupList; 00116 std::vector<double> _alphaList; 00117 std::vector<double> _dpdxList; 00118 00119 private slots: 00120 void on_calculateFlowThreadFinished(); 00121 void on_calculateRegimeTransitionThreadFinished(); 00122 void on_simulationError(QString errorMsg); 00123 00124 signals: 00125 void simulationProgressed(int percent); 00126 void simulationError(QString errorMsg); 00127 void finished(); 00128 void terminated(); 00129 }; 00130 00131 #endif // CALCULATEMANAGER_H