Skip to content

Commit 53cc754

Browse files
committed
Enable solver start/stop/kill actions based on per-model solver state
1 parent bf8ed92 commit 53cc754

9 files changed

Lines changed: 56 additions & 14 deletions

‎src/fea/doc/RELEASE_NOTES.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@
218218
accepted alternatives. An acoustic entity carrying a density and a speed of
219219
sound is no longer flagged for missing a modulus of elasticity
220220

221+
#### Solver control
222+
223+
- **Stop solver** and **Kill solver** are enabled only while a solver is
224+
running. They used to stay enabled after the solver finished, failed or was
225+
killed
226+
- **Start solver** is enabled only when none of the selected models has a
227+
solver running or queued, so a solver can no longer be started twice for the
228+
same model. It becomes available again as soon as that model's solver
229+
finishes, fails or is killed
230+
221231
#### 3D view and picking
222232

223233
- A picked node is visible. It was marked with a single point whose size the

‎src/fea/src/action.cpp‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,6 @@
6161
Action::Action(RAction::Definition definition, QObject *parent)
6262
: RAction{definition,parent}
6363
{
64-
65-
if (this->name == Action::getName(ACTION_SOLVER_START))
66-
{
67-
QObject::connect(&SolverManager::getInstance(), &SolverManager::jobStarted, this, &Action::disable);
68-
QObject::connect(&SolverManager::getInstance(), &SolverManager::jobFinished, this, &Action::enable);
69-
}
70-
if (this->name == Action::getName(ACTION_SOLVER_STOP) || this->name == Action::getName(ACTION_SOLVER_KILL))
71-
{
72-
QObject::connect(&SolverManager::getInstance(), &SolverManager::jobStarted, this, &Action::enable);
73-
QObject::connect(&SolverManager::getInstance(), &SolverManager::jobFinished, this, &Action::disable);
74-
}
7564
}
7665

7766
QString Action::getGroupName(GroupType groupType)

‎src/fea/src/action_list.cpp‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,16 @@ void ActionList::processAvailability()
166166
this->getAction(Action::ACTION_PROBLEM_SOLVER_SETUP)->setEnabled(true);
167167
this->getAction(Action::ACTION_PROBLEM_DEFINE_MONITORING_POINTS)->setEnabled(true);
168168
this->getAction(Action::ACTION_PROBLEM_RESET)->setEnabled(true);
169-
this->getAction(Action::ACTION_SOLVER_START)->setEnabled(true);
169+
bool solverActive = false;
170+
for (uint modelID : std::as_const(selectedModelIDs))
171+
{
172+
if (SolverManager::getInstance().isSolverRunning(modelID) || SolverManager::getInstance().isSolverQueued(modelID))
173+
{
174+
solverActive = true;
175+
break;
176+
}
177+
}
178+
this->getAction(Action::ACTION_SOLVER_START)->setEnabled(!solverActive);
170179
this->getAction(Action::ACTION_REPORT_MODEL_STATISTICS)->setEnabled(true);
171180
this->getAction(Action::ACTION_REPORT_SOLVER_LOG)->setEnabled(true);
172181
this->getAction(Action::ACTION_REPORT_CONVERGENCE_GRAPH)->setEnabled(true);

‎src/fea/src/central_tab_widget.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void CentralTabWidget::onInfoPrinted(const RMessage &message)
197197

198198
void CentralTabWidget::onNoticePrinted(const RMessage &message)
199199
{
200-
RMessageBox::information(this,tr("Notice"),QString(RMessage::messageToLogString(message)).replace("NOTICE: ",""));
200+
RMessageBox::information(this,tr("Notice"),QString(message).replace("NOTICE: ","").trimmed());
201201
}
202202

203203
void CentralTabWidget::onWarningPrinted(const RMessage &message)

‎src/fea/src/main_window.cpp‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ MainWindow::MainWindow(Session *session,
136136

137137
// Solver manager signals.
138138
QObject::connect(&SolverManager::getInstance(),&SolverManager::jobBlocking,this,&MainWindow::onJobBlocking);
139+
QObject::connect(&SolverManager::getInstance(),&SolverManager::jobStarted,this,&MainWindow::onSolverJobStateChanged);
140+
QObject::connect(&SolverManager::getInstance(),&SolverManager::jobFinished,this,&MainWindow::onSolverJobStateChanged);
141+
QObject::connect(&SolverManager::getInstance(),&SolverManager::jobFailed,this,&MainWindow::onSolverJobStateChanged);
139142

140143
// Draw engine signals.
141144
QObject::connect(this->session->getDrawEngine(),&DrawEngine::objectAdded,this,&MainWindow::onDrawObjectAdded);
@@ -904,7 +907,11 @@ void MainWindow::setEnabled(bool enabled)
904907
this->ecTab->setEnabled(enabled);
905908
this->materialTab->setEnabled(enabled);
906909
this->resultsTab->setEnabled(enabled);
907-
this->actionList->setEnabled(enabled);;
910+
this->actionList->setEnabled(enabled);
911+
if (enabled)
912+
{
913+
this->actionList->processAvailability();
914+
}
908915
}
909916

910917
void MainWindow::enable()
@@ -975,6 +982,12 @@ void MainWindow::onJobEnded()
975982
R_LOG_TRACE;
976983
}
977984

985+
void MainWindow::onSolverJobStateChanged()
986+
{
987+
R_LOG_TRACE;
988+
this->actionList->processAvailability();
989+
}
990+
978991
void MainWindow::onModelAdded(uint position)
979992
{
980993
R_LOG_TRACE;

‎src/fea/src/main_window.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ class MainWindow : public QMainWindow
210210
//! Job has ended.
211211
void onJobEnded();
212212

213+
//! Solver job has started, finished or failed.
214+
void onSolverJobStateChanged();
215+
213216
//! New model has been added.
214217
void onModelAdded(uint position);
215218

‎src/fea/src/report_generator.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void ReportGenerator::generateTitle()
4141
cursor.insertText(problemTypeList,ReportGenerator::getH3Format());
4242
cursor.insertBlock(blockFormat);
4343
cursor.insertBlock(blockFormat);
44+
cursor.insertText(tr("Author") + ": ",ReportGenerator::getTextFormat());
4445
cursor.insertText(Application::instance()->getApplicationSettings()->getUserFullName(),ReportGenerator::getH4Format());
4546
cursor.insertBlock(blockFormat);
4647
cursor.insertText(Application::instance()->getApplicationSettings()->getUserEmail(),ReportGenerator::getTextFormat());

‎src/fea/src/solver_manager.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ bool SolverManager::isSolverQueued(uint modelID) const
5858
return false;
5959
}
6060

61+
bool SolverManager::isSolverRunning(uint modelID) const
62+
{
63+
QMutexLocker<QRecursiveMutex> locker(&this->jobsMutex);
64+
for (int i=0;i<this->runningJobs.size();i++)
65+
{
66+
SolverTask *solverTask = static_cast<SolverTask*>(this->runningJobs[i]);
67+
if (!solverTask->isFinished() && solverTask->getModelID() == modelID)
68+
{
69+
return true;
70+
}
71+
}
72+
return false;
73+
}
74+
6175
void SolverManager::stopRunningTasks()
6276
{
6377
if (!this->runningJobs.isEmpty())

‎src/fea/src/solver_manager.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class SolverManager : public RJobManager
4444
//! Check if solver for given model ID is queued.
4545
bool isSolverQueued(uint modelID) const;
4646

47+
//! Check if solver for given model ID is running.
48+
bool isSolverRunning(uint modelID) const;
49+
4750
//! Stop current solvers.
4851
void stopRunningTasks();
4952

0 commit comments

Comments
 (0)