From bb559fc4f42c34d464fca03ada23fc27a07bf359 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Mon, 6 Nov 2023 19:45:20 -0800 Subject: [PATCH] Add interface to new svzerod solver 1034 (#1040) * Add 0D solver to SV Preferences page for ROM simulation. * Modify the sv4guiROMSimulationView class to execute the 0D solver binary. * Remove references to Python svZeroDSolver. * Add a more detailed arror message if the 0d solver can't be found. --- .../sv4gui_ROMSimulationPreferencePage.cxx | 48 ++++++++++ .../sv4gui_ROMSimulationPreferencePage.h | 3 + .../sv4gui_ROMSimulationPreferencePage.ui | 81 ++++++++++++++++ .../sv4gui_ROMSimulationPreferences.cxx | 75 ++++++++++++++- .../sv4gui_ROMSimulationPreferences.h | 3 + .../sv4gui_ROMSimulationPython.cxx | 87 ----------------- .../sv4gui_ROMSimulationPython.h | 5 - .../sv4gui_ROMSimulationView.cxx | 95 +++++++++++++++---- .../sv4gui_ROMSimulationView.h | 7 +- .../sv4gui_SolverProcessHandlerROM.cxx | 2 +- 10 files changed, 286 insertions(+), 120 deletions(-) diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.cxx b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.cxx index d47169a56..ed2c82b03 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.cxx +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.cxx @@ -59,6 +59,7 @@ sv4guiROMSimulationPreferencePage::~sv4guiROMSimulationPreferencePage() void sv4guiROMSimulationPreferencePage::InitializeSolverLocations() { SetOneDSolver(); + SetZeroDSolver(); } void sv4guiROMSimulationPreferencePage::CreateQtControl(QWidget* parent) @@ -71,7 +72,10 @@ void sv4guiROMSimulationPreferencePage::CreateQtControl(QWidget* parent) Q_ASSERT(prefService); m_Preferences = prefService->GetSystemPreferences()->Node("/org.sv.views.romsimulation"); + connect( m_Ui->SolverExecutablePath_Button, SIGNAL(clicked()), this, SLOT(SetOneDSolverFile()) ); + connect( m_Ui->ZeroDSolverExecutablePath_Button, SIGNAL(clicked()), this, SLOT(SetZeroDSolverFile()) ); + this->Update(); // Set the locations of the solver binary. @@ -85,6 +89,7 @@ void sv4guiROMSimulationPreferencePage::CreateQtControl(QWidget* parent) // void sv4guiROMSimulationPreferencePage::SetOneDSolverFile() { + std::cout << "sv4guiROMSimulationPreferencePage::SetOneDSolverFile()" << std::endl; QString filePath = QFileDialog::getOpenFileName(m_Control, "Select the 1D solver executable"); if (!filePath.isEmpty()) { @@ -100,6 +105,7 @@ void sv4guiROMSimulationPreferencePage::SetOneDSolverFile() // void sv4guiROMSimulationPreferencePage::SetOneDSolver() { + std::cout << "sv4guiROMSimulationPreferencePage::SetOneDSolver()" << std::endl; QString solver = m_Ui->SolverExecutablePath_LineEdit->text().trimmed(); if (!solver.isEmpty() && (solver != m_DefaultPrefs.UnknownBinary)) { return; @@ -109,6 +115,42 @@ void sv4guiROMSimulationPreferencePage::SetOneDSolver() m_Ui->SolverExecutablePath_LineEdit->setText(solver); } +//-------------------- +// SetZeroDSolverFile +//-------------------- +// Set the location of the 9D solver executable using a file browser. +// +void sv4guiROMSimulationPreferencePage::SetZeroDSolverFile() +{ + std::cout << "sv4guiROMSimulationPreferencePage::SetZeroDSolverFile()" << std::endl; + + QString filePath = QFileDialog::getOpenFileName(m_Control, "Select the 0D solver executable"); + + if (!filePath.isEmpty()) { + m_Ui->ZeroDSolverExecutablePath_LineEdit->setText(filePath); + } +} + +//--------------- +// SetZeroDSolver +//--------------- +// Set the 0D solver executable from the GUI line edit widget +// or from the default value. +// +void sv4guiROMSimulationPreferencePage::SetZeroDSolver() +{ + std::cout << "sv4guiROMSimulationPreferencePage::SetZeroDSolver()" << std::endl; + + QString solver = m_Ui->ZeroDSolverExecutablePath_LineEdit->text().trimmed(); + if (!solver.isEmpty() && (solver != m_DefaultPrefs.UnknownBinary)) { + return; + } + + solver = m_DefaultPrefs.GetZeroDSolver(); + m_Ui->ZeroDSolverExecutablePath_LineEdit->setText(solver); +} + + QWidget* sv4guiROMSimulationPreferencePage::GetQtControl() const { return m_Control; @@ -125,13 +167,19 @@ void sv4guiROMSimulationPreferencePage::PerformCancel() bool sv4guiROMSimulationPreferencePage::PerformOk() { using namespace sv4guiROMSimulationPreferenceDBKey; + QString oneDSolverPath = m_Ui->SolverExecutablePath_LineEdit->text().trimmed(); m_Preferences->Put(ONED_SOLVER_PATH, oneDSolverPath); + + QString zeroDSolverPath = m_Ui->ZeroDSolverExecutablePath_LineEdit->text().trimmed(); + m_Preferences->Put(ZEROD_SOLVER_PATH, zeroDSolverPath); + return true; } void sv4guiROMSimulationPreferencePage::Update() { m_Ui->SolverExecutablePath_LineEdit->setText(m_Preferences->Get("1d solver executable path","")); + m_Ui->ZeroDSolverExecutablePath_LineEdit->setText(m_Preferences->Get("0d solver executable path","")); } diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.h b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.h index e0efbfcdb..e8ac8f9f6 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.h +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.h @@ -47,6 +47,7 @@ class sv4guiROMSimulationPreferencePage; // namespace sv4guiROMSimulationPreferenceDBKey { const QString ONED_SOLVER_PATH = "oned solver path"; + const QString ZEROD_SOLVER_PATH = "zerod solver path"; }; @@ -69,6 +70,7 @@ class sv4guiROMSimulationPreferencePage : public QObject, public berry::IQtPrefe private slots: void SetOneDSolverFile(); + void SetZeroDSolverFile(); private: berry::IPreferences::Pointer m_Preferences; @@ -76,6 +78,7 @@ private slots: QWidget* m_Control; sv4guiROMSimulationPreferences m_DefaultPrefs; void SetOneDSolver(); + void SetZeroDSolver(); }; diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.ui b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.ui index 7442b8b2f..02cbed6a4 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.ui +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferencePage.ui @@ -95,6 +95,87 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Path to 0D Solver executable + + + + + + + ... + + + + + + + + + + + + + + + + diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.cxx b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.cxx index 93dee6f4e..4f07c472e 100755 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.cxx +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.cxx @@ -66,7 +66,8 @@ sv4guiROMSimulationPreferences::~sv4guiROMSimulationPreferences() // void sv4guiROMSimulationPreferences::InitializeSolverLocations() { - // Set the default install location of the solver. + // Set the default install location of the 1D solver. + // QString solverInstallPath = "/usr/local/sv/oneDSolver"; QStringList dirList = QDir(solverInstallPath).entryList(QDir::Dirs|QDir::NoDotAndDotDot|QDir::NoSymLinks,QDir::Name); if (dirList.size() != 0) { @@ -75,12 +76,25 @@ void sv4guiROMSimulationPreferences::InitializeSolverLocations() // Set the path to the SimVascular-build/bin directory. QString applicationPath = ""; - //QString applicationPath = QCoreApplication::applicationDirPath(); - - //sv4gui_parse_registry_for_svsolver(); // Set the solver binaries. SetOneDSolver(solverInstallPath, applicationPath); + + + // Set the default install location of the 0D solver. + // + solverInstallPath = "/usr/local/sv/ZeroDSolver"; + dirList = QDir(solverInstallPath).entryList(QDir::Dirs|QDir::NoDotAndDotDot|QDir::NoSymLinks,QDir::Name); + if (dirList.size() != 0) { + solverInstallPath += "/" + dirList.back(); + } + + // Set the path to the SimVascular-build/bin directory. + applicationPath = ""; + + // Set the solver binaries. + SetZeroDSolver(solverInstallPath, applicationPath); + } //--------------- @@ -138,6 +152,59 @@ QString sv4guiROMSimulationPreferences::GetOneDSolver() return m_svOneDSolver; } +//---------------- +// SetZeroDSolver +//---------------- +// Set the ZeroDSolver binary. +// +void sv4guiROMSimulationPreferences::SetZeroDSolver(const QString& solverInstallPath, const QString& applicationPath) +{ + QString svZeroDSolver = UnknownBinary; + +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) + QString filePath = ""; + QString svZeroDSolverName = "/svzerodsolver"; + + // For the flow solver with mpi, prefer to use the script one which sets + // paths to libs needed in Ubuntu 16. + // + if(QFile(filePath=solverInstallPath+svZeroDSolverName).exists()) { + svZeroDSolver = filePath; + } else if(QFile(filePath=solverInstallPath+"/bin/"+svZeroDSolverName).exists()) { + svZeroDSolver = filePath; + + } else if(QFile(filePath=applicationPath+svZeroDSolverName).exists()) { + svZeroDSolver = filePath; + + } else if(QFile(filePath=applicationPath+"/bin/"+svZeroDSolverName).exists()) { + svZeroDSolver = filePath; + } + +#elif defined(Q_OS_WIN) + + char result[1024]; + result[0] = '\0'; + + // This returns the full path including the executable for the svZeroDSolver. + // + // The most recent installed solver is returned. + // + // The registry entry name is 'SVONEDSOLVER_EXE' and is located under WOW6432Node/SimVascular/Solvers/svZeroDSolver. + // + if (sv4gui_rom_parse_registry_for_svonedsolver("SVZERODSOLVER_EXE",result) == SV_OK) { + svZeroDSolver = result; + } + +#endif + + m_svZeroDSolver = svZeroDSolver; + std::cout << "svZeroDSolver executable: '" << m_svZeroDSolver.toStdString() << "'" << std::endl; +} + +QString sv4guiROMSimulationPreferences::GetZeroDSolver() +{ + return m_svZeroDSolver; +} diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.h b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.h index 99be82a40..578f7e3cf 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.h +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPreferences.h @@ -65,12 +65,15 @@ class sv4guiROMSimulationPreferences void InitializeSolverLocations(); QString GetOneDSolver(); + QString GetZeroDSolver(); static const QString UnknownBinary; private: QString m_svOneDSolver; + QString m_svZeroDSolver; void SetOneDSolver(const QString& solverInstallPath, const QString& applicationPath); + void SetZeroDSolver(const QString& solverInstallPath, const QString& applicationPath); }; #endif // SV4GUI_SIMULATIONPREFERENCES_H diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.cxx b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.cxx index 99b9e5d50..6964eb3dd 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.cxx +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.cxx @@ -284,93 +284,6 @@ bool sv4guiROMSimulationPython::GenerateSolverInput(const std::string outputDire return SV_OK; } -//------------------------ -// ExecuteZeroDSimulation -//------------------------ -// Execute a 0D simulation. -// -// The svZeroDSolver.py Python script is executed by calling the 'run_from_c' function. -// -bool sv4guiROMSimulationPython::ExecuteZeroDSimulation(const std::string outputDirectory, const sv4guiROMSimJob* job) -{ - std::string msg = "[sv4guiROMSimulationPython::ExecuteZeroDSimulation] "; - MITK_INFO << msg << "---------- ExecuteZeroDSimulation ----------"; - sv4guiROMSimulationPythonParamNames paramNames; - - // Import the svZeroDSolver module. - // - auto moduleName = m_PythonZeroDSolverModuleName; - auto pyName = PyUnicode_DecodeFSDefault((char*)moduleName.c_str()); - auto pyModule = PyImport_Import(pyName); - - if (pyModule == nullptr) { - auto msg = "Unable to load the Python '" + QString(moduleName.c_str()) + "' module."; - MITK_ERROR << msg; - QMessageBox::warning(NULL, sv4guiROMSimulationView::MsgTitle, msg); - return false; - } - - // Get the module interface function that executes - // module functions based on input arguments. - // - auto pyFuncName = (char*)"run_from_c"; - auto pyDict = PyModule_GetDict(pyModule); - auto pyFunc = PyDict_GetItemString(pyDict, (char*)pyFuncName); - - if (!PyCallable_Check(pyFunc)) { - auto msg = "Can't find the function '" + QString(pyFuncName) + "' in the '" + QString(moduleName.c_str()) + "' module."; - MITK_ERROR << msg; - QMessageBox::warning(NULL, sv4guiROMSimulationView::MsgTitle, msg); - return false; - } - - // Create an argument containing the name of the solver.in file. - // - auto fileName = outputDirectory + "/" + m_PythonZeroDSolverFileName; - auto args = PyTuple_New(1); - auto argValue = PyUnicode_DecodeFSDefault(fileName.c_str()); - PyTuple_SetItem(args, 0, argValue); - - // Create the **kwarg arguments that are the input arguments to the module. - // - // No parameters are currently passed. - // - auto kwargs = PyDict_New(); - - // Execute the Python script. - // - MITK_INFO << msg << "Execute script ..."; - auto result = PyObject_Call(pyFunc, args, kwargs); - MITK_INFO << msg << "Done."; - - // Check for errors. - PyErr_Print(); - - // Search for the Python ERROR or WARNING messages in the - // returned result string to determine if the script failed. - // - if (result) { - auto uResult = PyUnicode_FromObject(result); - auto sResult = std::string(PyUnicode_AsUTF8(uResult)); - - if (sResult.find("ERROR") != std::string::npos) { - MITK_WARN << "The 0D solver has failed."; - MITK_WARN << "Returned message: " << QString(sResult.c_str()); - QMessageBox mb(nullptr); - mb.setWindowTitle(sv4guiROMSimulationView::MsgTitle); - mb.setText("The 0D solver has failed."); - mb.setIcon(QMessageBox::Critical); - mb.setDetailedText(QString(sResult.c_str())); - mb.setDefaultButton(QMessageBox::Ok); - mb.exec(); - } else { - QMessageBox::information(NULL, sv4guiROMSimulationView::MsgTitle, "The 0D solver has completed."); - } - } - - return true; -} - //-------------- // StartCommand //-------------- diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.h b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.h index 868ac813d..a4e4dcff9 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.h +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationPython.h @@ -141,14 +141,9 @@ class SV_QT_ROMSIMULATION sv4guiROMSimulationPython // The name of the ROM Python package in SimVascular/Python/site-packages. const std::string m_PythonROMSimulationModuleName = "sv_rom_simulation"; - // The 0D solver Python package name. - const std::string m_PythonZeroDSolverModuleName = "svZeroDSolver.svzerodsolver"; - const std::string m_PythonZeroDSolverFileName = "solver_0d.json"; - std::string AddArgument(const std::string& arg, const std::string& value, bool last=false); bool AddParameter(const std::string& name, const std::string& value); bool AddParameterList(const std::string& name, const std::vector& values); - bool ExecuteZeroDSimulation(const std::string outputDirectory, const sv4guiROMSimJob* job); bool GenerateMesh(const std::string& outputDir, const std::string& centerlinesFile, const std::string& meshFile); bool GenerateSolverInput(const std::string outputDirectory, const sv4guiROMSimJob* job); std::string StartCommand(); diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.cxx b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.cxx index 53064d813..e5abe1622 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.cxx +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.cxx @@ -200,6 +200,7 @@ const QString sv4guiROMSimulationView::OUTLET_FACE_NAMES_FILE_NAME = "outlet_fac const QString sv4guiROMSimulationView::RCR_BC_FILE_NAME = "rcrt.dat"; const QString sv4guiROMSimulationView::RESISTANCE_BC_FILE_NAME = "resistance.dat"; const QString sv4guiROMSimulationView::SOLVER_0D_FILE_NAME = "solver_0d.json"; +const QString sv4guiROMSimulationView::SOLVER_0D_OUTPUT_FILE_NAME = "solver_0d.csv"; const QString sv4guiROMSimulationView::SOLVER_1D_FILE_NAME = "solver_1d.in"; const QString sv4guiROMSimulationView::SOLVER_LOG_FILE_NAME = "svromsolver.log"; @@ -1694,6 +1695,7 @@ void sv4guiROMSimulationView::OnPreferencesChanged(const berry::IBerryPreference // Set the 1D solver binary. m_SolverExecutable = prefs->Get(ONED_SOLVER_PATH, m_DefaultPrefs.GetOneDSolver()); + m_ZeroDSolverExecutable = prefs->Get(ZEROD_SOLVER_PATH, m_DefaultPrefs.GetZeroDSolver()); } //-------------------- @@ -3333,26 +3335,39 @@ void sv4guiROMSimulationView::RunJob() // void sv4guiROMSimulationView::RunZeroDSimulationJob(const QString& jobPath) { + // Get the solver executable. + auto solverExecutable = GetZeroDSolverExecutable(); + if (solverExecutable == nullptr) { + return; + } + // Set job properties used to write solver log. // - m_JobNode->SetStringProperty("output directory", GetJobPath().toStdString().c_str()); + auto outputDir = GetJobPath().toStdString(); + m_JobNode->SetStringProperty("output directory", outputDir.c_str()); m_JobNode->SetStringProperty("solver log file", sv4guiROMSimulationView::SOLVER_LOG_FILE_NAME.toStdString().c_str()); - sv4guiROMSimJob* job = m_MitkJob->GetSimJob(); + // Execute the 0D solver. + // + mitk::StatusBar::GetInstance()->DisplayText("Running 0D simulation ..."); - QDir dir(jobPath); - dir.mkpath(jobPath); + QProcess* solverProcess = new QProcess(m_Parent); + solverProcess->setWorkingDirectory(jobPath); + solverProcess->setProgram(solverExecutable); - // Execute the 0D solver. - auto pythonInterface = sv4guiROMSimulationPython(); - auto statusMsg = "Executing a 0D simulation ..."; - ui->JobStatusValueLabel->setText(statusMsg); - mitk::StatusBar::GetInstance()->DisplayText(statusMsg); - auto status = pythonInterface.ExecuteZeroDSimulation(jobPath.toStdString(), job); + // Set the solver arguments: input JSON file and output CSV file. + QStringList arguments; + arguments << m_SolverInputFile; + arguments << GetJobPath() + "/" + SOLVER_0D_OUTPUT_FILE_NAME; + solverProcess->setArguments(arguments); - statusMsg = "The 0D simulation has completed."; - ui->JobStatusValueLabel->setText(statusMsg); - mitk::StatusBar::GetInstance()->DisplayText(statusMsg); + int startStep = 0; + int totalSteps = 2000; + + // Run the solver job. + sv4guiSolverProcessHandlerROM* handler = new sv4guiSolverProcessHandlerROM(solverProcess, m_JobNode, startStep, totalSteps, + jobPath, m_Parent); + handler->Start(); } //---------------------- @@ -3438,6 +3453,42 @@ QString sv4guiROMSimulationView::GetSolverExecutable() return m_SolverExecutable; } +//-------------------------- +// GetZeroDSolverExecutable +//-------------------------- +// Get the 0d solver executable set in the preferences page. +// +QString sv4guiROMSimulationView::GetZeroDSolverExecutable() +{ + if (m_Parent == NULL) { + return nullptr; + } + + if (m_ZeroDSolverExecutable == "") { + QString msg1 = "The 0D solver executable can't be found.\n\n"; + QString msg3 = "The 0D solver is a separate svZeroDSolver application downloaded from SimTK (https://simtk.org/projects/simvascular).\n"; + QString msg2 = "Set the path to the 0D solver executable in the SimVascular Preferences / SimVascular ROM Simulation paneli:\n"; + QMessageBox::warning(m_Parent, MsgTitle, msg1+msg2+msg3); + return nullptr; + } + + QFileInfo check_file(m_ZeroDSolverExecutable); + + if (!check_file.exists()) { + auto msg = "The 0D solver executable '" + m_ZeroDSolverExecutable + "' does not exist.\n"; + QMessageBox::warning(m_Parent, MsgTitle, msg); + return nullptr; + } + + if (!check_file.isFile()) { + auto msg = "The 0D solver executable '" + m_ZeroDSolverExecutable + "' is not a file.\n"; + QMessageBox::warning(m_Parent, MsgTitle, msg); + return nullptr; + } + + return m_ZeroDSolverExecutable; +} + //----------------- // CreateDataFiles //----------------- @@ -3552,13 +3603,15 @@ bool sv4guiROMSimulationView::CreateDataFiles(QString outputDir, bool outputAllF pythonInterface.AddParameter(params.OUTFLOW_BC_INPUT_FILE, outputDir.toStdString()); WriteBCFiles(outputDir, job, pythonInterface); - QString solverFileName; - if (modelOrder == "0") - solverFileName = SOLVER_0D_FILE_NAME; - if (modelOrder == "1") - solverFileName = SOLVER_1D_FILE_NAME; - pythonInterface.AddParameter(params.SOLVER_OUTPUT_FILE, - solverFileName.toStdString()); + QString solverFileName; + + if (modelOrder == "0") + solverFileName = SOLVER_0D_FILE_NAME; + + if (modelOrder == "1") + solverFileName = SOLVER_1D_FILE_NAME; + + pythonInterface.AddParameter(params.SOLVER_OUTPUT_FILE, solverFileName.toStdString()); // Add basic physical parameters. auto density = m_TableModelBasic->item(TableModelBasicRow::Density,1)->text().trimmed().toStdString(); @@ -3588,7 +3641,7 @@ bool sv4guiROMSimulationView::CreateDataFiles(QString outputDir, bool outputAllF return false; } - m_SolverInputFile = outputDir + "/" + solverFileName; + m_SolverInputFile = outputDir + "/" + solverFileName; ui->RunSimulationPushButton->setEnabled(true); statusMsg = "Simulation files have been created."; diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.h b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.h index cdf2e2372..613f51e82 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.h +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_ROMSimulationView.h @@ -93,8 +93,9 @@ class SV_QT_ROMSIMULATION sv4guiROMSimulationView : public sv4guiQmitkFunctional static const QString OUTLET_FACE_NAMES_FILE_NAME; static const QString RCR_BC_FILE_NAME; static const QString RESISTANCE_BC_FILE_NAME; - static const QString SOLVER_0D_FILE_NAME; - static const QString SOLVER_1D_FILE_NAME; + static const QString SOLVER_0D_FILE_NAME; + static const QString SOLVER_0D_OUTPUT_FILE_NAME; + static const QString SOLVER_1D_FILE_NAME; sv4guiROMSimulationView(); @@ -428,6 +429,7 @@ public slots: QString m_SolverInputFile; QString m_SolverExecutable; + QString m_ZeroDSolverExecutable; QString m_SolverTemplatePath; bool m_UseCustom; @@ -463,6 +465,7 @@ public slots: bool SetWallProperites(sv4guiROMSimJob* job, std::string& msg, bool checkValidity); bool SetSolverParameters(sv4guiROMSimJob* job, std::string& msg, bool checkValidity); QString GetSolverExecutable(); + QString GetZeroDSolverExecutable(); bool CheckBCsInputState(bool checkValidity=true); bool CheckInputState(DataInputStateType type = DataInputStateType::ALL); diff --git a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_SolverProcessHandlerROM.cxx b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_SolverProcessHandlerROM.cxx index 97f307fce..2e452a5c0 100644 --- a/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_SolverProcessHandlerROM.cxx +++ b/Code/Source/sv4gui/Plugins/org.sv.gui.qt.romsimulation/sv4gui_SolverProcessHandlerROM.cxx @@ -103,7 +103,7 @@ void sv4guiSolverProcessHandlerROM::ProcessError(QProcess::ProcessError error) if (error == QProcess::FailedToStart) { title = "Simulation cannot be started"; - text = "Unable to execute the 1D solver."; + text = "Unable to execute the solver."; MITK_ERROR << text; } else { title = "Simulation failed";