QSS Solver GUI  4.5.3
runform.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #include <Qt>
21 #include <QtGui>
22 #include <QListView>
23 
24 #include <runform.hpp>
25 #include <utils.hpp>
26 
27 RunDlg::RunDlg(QWidget *parent) : QDialog(parent)
28 {
29  setupUi(this);
30  _utils = new Utils();
31  _validate = new QDoubleValidator();
32  _startTime->setValidator(_validate);
33  _stopTime->setValidator(_validate);
34  _tolerance->setValidator(_validate);
35  _dt->setValidator(_validate);
36  _absTolerance->setValidator(_validate);
37  _minStep->setValidator(_validate);
38  _derDelta->setValidator(_validate);
39  _zcHyst->setValidator(_validate);
40  _extendedFrame->setVisible(false);
41  _debugChk->setCheckState(Qt::Unchecked);
42  on__parallel_currentIndexChanged(_parallel->currentIndex());
43  connect(_test_methods_cbx, &QCheckBox::stateChanged, this, &RunDlg::updateTestMethods);
44  // Not needed for the moment, if adding test methods we should enable it.
45  // updateTestMethods(_test_methods_cbx->checkState());
46  _test_methods_cbx->setVisible(false);
47  _test_methods_lbl->setVisible(false);
48 }
49 
51 {
52  switch (state) {
53  case Qt::Unchecked:
54  _extendedFrame->setVisible(false);
55  break;
56  case Qt::Checked:
57  _extendedFrame->setVisible(true);
58  break;
59  default:
60  break;
61  }
62 }
63 
65 {
66  if (index == 0) {
67  _period->setEnabled(false);
68  } else {
69  _period->setEnabled(true);
70  }
71 }
72 
74 {
75  if (index == 0) {
76  _dtLbl->setText("Dt tolerance");
77  } else {
78  _dtLbl->setText("Dt value");
79  }
80 }
81 
83 {
84  if (index == 1) {
85  _lps->setEnabled(true);
86  _partitionMethod->setEnabled(true);
87  _dt->setEnabled(true);
88  _dtSynch->setEnabled(true);
89  _scotchSettings->setEnabled(true);
90  _metisSettings->setEnabled(true);
91  _patohSettings->setEnabled(true);
92  _semiStaticChk->setEnabled(true);
93  _generateArchCbx->setEnabled(true);
94  _debugGraphCbx->setEnabled(true);
95  _reorderPartitionCbx->setEnabled(true);
96  _imbalance->setEnabled(true);
97  } else {
98  _lps->setEnabled(false);
99  _partitionMethod->setEnabled(false);
100  _dt->setEnabled(false);
101  _dtSynch->setEnabled(false);
102  _scotchSettings->setEnabled(false);
103  _metisSettings->setEnabled(false);
104  _patohSettings->setEnabled(false);
105  _semiStaticChk->setEnabled(false);
106  _generateArchCbx->setEnabled(false);
107  _debugGraphCbx->setEnabled(false);
108  _reorderPartitionCbx->setEnabled(false);
109  _imbalance->setEnabled(false);
110  }
111 }
112 
113 int RunDlg::getSolverIdx(QString str)
114 {
115  if (str.trimmed() == "QSS") return 0;
116  if (str.trimmed() == "CQSS") return 1;
117  if (str.trimmed() == "LIQSS") return 2;
118  if (str.trimmed() == "QSS2") return 3;
119  if (str.trimmed() == "LIQSS2") return 4;
120  if (str.trimmed() == "LIQSS_BDF") return 5;
121  if (str.trimmed() == "QSS3") return 6;
122  if (str.trimmed() == "LIQSS3") return 7;
123  if (str.trimmed() == "QSS4") return 8;
124  if (str.trimmed() == "DASSL") return 9;
125  if (str.trimmed() == "DOPRI") return 10;
126  if (str.trimmed() == "CVODE_BDF") return 11;
127  if (str.trimmed() == "CVODE_AM") return 12;
128  if (str.trimmed() == "IDA") return 13;
129  if (str.trimmed() == "mLIQSS") return 14;
130  if (str.trimmed() == "mLIQSS2") return 15;
131  return -1;
132 }
133 
134 QString RunDlg::getSolverString(int idx)
135 {
136  switch (idx) {
137  case 0:
138  return "QSS";
139  case 1:
140  return "CQSS";
141  case 2:
142  return "LIQSS";
143  case 3:
144  return "QSS2";
145  case 4:
146  return "LIQSS2";
147  case 5:
148  return "LIQSS_BDF";
149  case 6:
150  return "QSS3";
151  case 7:
152  return "LIQSS3";
153  case 8:
154  return "QSS4";
155  case 9:
156  return "DASSL";
157  case 10:
158  return "DOPRI";
159  case 11:
160  return "CVODE_BDF";
161  case 12:
162  return "CVODE_AM";
163  case 13:
164  return "IDA";
165  case 14:
166  _test_methods_cbx->setCheckState(Qt::Checked);
167  return "mLIQSS";
168  case 15:
169  _test_methods_cbx->setCheckState(Qt::Checked);
170  return "mLIQSS2";
171  }
172  return QString();
173 }
174 
176 {
177  switch (idx) {
178  case 0:
179  return "Sparse";
180  case 1:
181  return "Dense";
182  }
183  return "Sparse";
184 }
185 
186 int RunDlg::getOutputTypeIdx(QString str)
187 {
188  if (str.trimmed() == "CI_Step") return 0;
189  if (str.trimmed() == "CI_Sampled") return 1;
190  if (str.trimmed() == "CI_Dense") return 2;
191  return 0;
192 }
193 
195 {
196  switch (idx) {
197  case 0:
198  return "CI_Step";
199  case 1:
200  return "CI_Sampled";
201  case 2:
202  return "CI_Dense";
203  }
204  return QString();
205 }
206 
207 int RunDlg::getSchedulerIdx(QString str)
208 {
209  if (str.trimmed() == "ST_Binary") return 0;
210  if (str.trimmed() == "ST_Random") return 1;
211  if (str.trimmed() == "ST_Linear") return 2;
212  return 0;
213 }
214 
216 {
217  switch (idx) {
218  case 0:
219  return "ST_Binary";
220  case 1:
221  return "ST_Random";
222  case 2:
223  return "ST_Linear";
224  }
225  return QString();
226 }
227 
228 int RunDlg::getComboBoolIdx(QString str)
229 {
230  if (str.trimmed() == "false") return 0;
231  if (str.trimmed() == "true") return 1;
232  return 0;
233 }
234 
236 {
237  switch (idx) {
238  case 0:
239  return "false";
240  case 1:
241  return "true";
242  }
243  return "false";
244 }
245 
247 {
248  if (str.trimmed() == "Metis") return 0;
249  if (str.trimmed() == "HMetis") return 1;
250  if (str.trimmed() == "Scotch") return 2;
251  if (str.trimmed() == "Patoh") return 3;
252  if (str.trimmed() == "KaHIP") return 4;
253  if (str.trimmed() == "Manual") return 5;
254  return 0;
255 }
256 
258 {
259  switch (idx) {
260  case 0:
261  return "Metis";
262  case 1:
263  return "HMetis";
264  case 2:
265  return "Scotch";
266  case 3:
267  return "Patoh";
268  case 4:
269  return "KaHIP";
270  case 5:
271  return "Manual";
272  }
273  return "Scotch";
274 }
275 
276 int RunDlg::getJacobianIdx(QString str)
277 {
278  if (str.trimmed() == "Dense") return 1;
279  if (str.trimmed() == "Sparse") return 0;
280  return 0;
281 }
282 
283 int RunDlg::getDtSynchIdx(QString str)
284 {
285  if (str.trimmed() == "SD_DT_Fixed") return 1;
286  if (str.trimmed() == "SD_DT_Asynchronous") return 0;
287  return 0;
288 }
289 
290 QString RunDlg::getDtSynchString(int idx)
291 {
292  switch (idx) {
293  case 1:
294  return "SD_DT_Fixed";
295  case 0:
296  return "SD_DT_Asynchronous";
297  }
298  return "SD_DT_Asynchronous";
299 }
300 
302 {
303  bool hide = state == Qt::Unchecked;
304  // To hide a test method use:
305  // QListView *solver_list = qobject_cast<QListView *>(_solver->view());
306  // solver_list->setRowHidden(getSolverIdx("my_test_method"), hide);
307  if (hide) {
308  setSolver("QSS");
309  }
310 }
RunDlg::on__dtSynch_currentIndexChanged
void on__dtSynch_currentIndexChanged(int index)
Definition: runform.cpp:73
RunDlg::getPartitionMethodIdx
int getPartitionMethodIdx(QString str)
Definition: runform.cpp:246
utils.hpp
RunDlg::getSolverString
QString getSolverString(int idx)
Definition: runform.cpp:134
RunDlg::setSolver
void setSolver(QString str)
Definition: runform.hpp:74
runform.hpp
RunDlg::_utils
Utils * _utils
Definition: runform.hpp:135
RunDlg::getDtSynchString
QString getDtSynchString(int idx)
Definition: runform.cpp:290
Utils
Definition: utils.hpp:60
RunDlg::on__parallel_currentIndexChanged
void on__parallel_currentIndexChanged(int index)
Definition: runform.cpp:82
RunDlg::getComboBoolIdx
int getComboBoolIdx(QString str)
Definition: runform.cpp:228
RunDlg::getOutputTypeIdx
int getOutputTypeIdx(QString str)
Definition: runform.cpp:186
RunDlg::getJacobianIdx
int getJacobianIdx(QString str)
Definition: runform.cpp:276
RunDlg::RunDlg
RunDlg(QWidget *parent=nullptr)
Definition: runform.cpp:27
RunDlg::getPartitionMethodString
QString getPartitionMethodString(int idx)
Definition: runform.cpp:257
RunDlg::getSchedulerIdx
int getSchedulerIdx(QString str)
Definition: runform.cpp:207
RunDlg::getDtSynchIdx
int getDtSynchIdx(QString str)
Definition: runform.cpp:283
RunDlg::updateTestMethods
void updateTestMethods(int state)
Definition: runform.cpp:301
RunDlg::on__showAll_stateChanged
void on__showAll_stateChanged(int state)
Definition: runform.cpp:50
RunDlg::on__commInterval_currentIndexChanged
void on__commInterval_currentIndexChanged(int index)
Definition: runform.cpp:64
RunDlg::getSchedulerString
QString getSchedulerString(int idx)
Definition: runform.cpp:215
RunDlg::getComboBoolString
QString getComboBoolString(int idx)
Definition: runform.cpp:235
RunDlg::getOutputTypeString
QString getOutputTypeString(int idx)
Definition: runform.cpp:194
RunDlg::getSolverIdx
int getSolverIdx(QString str)
Definition: runform.cpp:113
RunDlg::_validate
QDoubleValidator * _validate
Definition: runform.hpp:136
RunDlg::getJacobianString
QString getJacobianString(int idx)
Definition: runform.cpp:175