[FEM] fix binary check
- the current implementation only considers explicitly given binaries (with full path) and ignores the setting to check the environment paths - also remove 2 trailing whitespaces
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QFileInfo>
|
||||
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <Geom_BezierCurve.hxx>
|
||||
@@ -41,6 +43,8 @@
|
||||
# include <TopoDS_Face.hxx>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
#include "FemTools.h"
|
||||
|
||||
|
||||
@@ -278,3 +282,41 @@ gp_XYZ Fem::Tools::getDirection(const TopoDS_Edge& edge)
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
// function to determine 3rd-party binaries used by the FEM WB
|
||||
std::string Fem::Tools::checkIfBinaryExists(std::string prefSection,
|
||||
std::string prefBinaryName,
|
||||
std::string binaryName)
|
||||
{
|
||||
// if "Search in known binary directories" is set in the preferences, we ignore custom path
|
||||
auto paramPath = "User parameter:BaseApp/Preferences/Mod/Fem/" + prefSection;
|
||||
auto knownDirectoriesString = "UseStandard" + prefSection + "Location";
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(paramPath.c_str());
|
||||
bool knownDirectories = hGrp->GetBool(knownDirectoriesString.c_str(), true);
|
||||
|
||||
if (knownDirectories) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
binaryName = binaryName + ".exe";
|
||||
#endif
|
||||
// first check the environment paths by QFileInfo
|
||||
if (QFileInfo::exists(QString::fromLatin1(binaryName.c_str()))) {
|
||||
return binaryName;
|
||||
}
|
||||
// check the folder of the FreeCAD binary
|
||||
else {
|
||||
auto homePathBinary = App::Application::getHomePath() + "bin/" + binaryName;
|
||||
if (QFileInfo::exists(QString::fromLatin1(homePathBinary.c_str())))
|
||||
return binaryName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto binaryPathString = prefBinaryName + "BinaryPath";
|
||||
ParameterGrp::handle hGrp =
|
||||
App::GetApplication().GetParameterGroupByPath(paramPath.c_str());
|
||||
auto binaryPath = hGrp->GetASCII(binaryPathString.c_str(), "");
|
||||
QFileInfo::exists(QString::fromLatin1(binaryPath.c_str()));
|
||||
if (QFileInfo::exists(QString::fromLatin1(binaryPath.c_str())))
|
||||
return binaryPath;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -67,6 +67,13 @@ public:
|
||||
@see isPlanar
|
||||
*/
|
||||
static gp_XYZ getDirection(const TopoDS_Face&);
|
||||
/*!
|
||||
function to determine 3rd-party binaries used by the FEM WB
|
||||
The result is either the full path if available or just the binary
|
||||
name if it was found in a system path
|
||||
*/
|
||||
static std::string checkIfBinaryExists(std::string prefSection, std::string prefBinaryPath,
|
||||
std::string prefBinaryName);
|
||||
};
|
||||
|
||||
} //namespace Fem
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
#include <Python.h>
|
||||
#include <QFileInfo>
|
||||
|
||||
// Salomesh
|
||||
#include <SMDS_MeshElement.hxx>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
|
||||
#include "DlgSettingsFemGeneralImp.h"
|
||||
#include "ui_DlgSettingsFemGeneral.h"
|
||||
@@ -42,25 +43,16 @@ DlgSettingsFemGeneralImp::DlgSettingsFemGeneralImp(QWidget* parent)
|
||||
ui->cmb_def_solver->clear();
|
||||
std::vector<std::string> Solvers = {"None"};
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Ccx");
|
||||
auto ccxBinaryPath = hGrp->GetASCII("ccxBinaryPath", "");
|
||||
if (!ccxBinaryPath.empty())
|
||||
if (!Fem::Tools::checkIfBinaryExists("CCX", "ccx", "ccx").empty())
|
||||
Solvers.push_back("CalculiX");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Elmer");
|
||||
auto elmerBinaryPath = hGrp->GetASCII("elmerBinaryPath", "");
|
||||
if (!elmerBinaryPath.empty())
|
||||
if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty())
|
||||
Solvers.push_back("Elmer");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/mystran");
|
||||
auto MystranBinaryPath = hGrp->GetASCII("MystranBinaryPath", "");
|
||||
if (!MystranBinaryPath.empty())
|
||||
// also check the multi-CPU Elmer build
|
||||
else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty())
|
||||
Solvers.push_back("Elmer");
|
||||
if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty())
|
||||
Solvers.push_back("Mystran");
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Z88");
|
||||
auto z88BinaryPath = hGrp->GetASCII("z88BinaryPath", "");
|
||||
if (!z88BinaryPath.empty())
|
||||
if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty())
|
||||
Solvers.push_back("Z88");
|
||||
|
||||
QStringList solversList;
|
||||
@@ -71,7 +63,7 @@ DlgSettingsFemGeneralImp::DlgSettingsFemGeneralImp(QWidget* parent)
|
||||
|
||||
// if the "DefaultSolver" parameter is not yet set and there is only
|
||||
// one available solver, set this solver
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/General");
|
||||
auto DefaultSolver = hGrp->GetInt("DefaultSolver", 0);
|
||||
if (!DefaultSolver && ui->cmb_def_solver->count() == 2)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <Gui/MenuManager.h>
|
||||
#include <Gui/ToolBarManager.h>
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
|
||||
#include "Workbench.h"
|
||||
|
||||
@@ -175,25 +176,16 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
|
||||
Gui::ToolBarItem* solve = new Gui::ToolBarItem(root);
|
||||
solve->setCommand("Solve");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Ccx");
|
||||
auto ccxBinaryPath = hGrp->GetASCII("ccxBinaryPath", "");
|
||||
if (!ccxBinaryPath.empty())
|
||||
if (!Fem::Tools::checkIfBinaryExists("CCX", "ccx", "ccx").empty())
|
||||
*solve << "FEM_SolverCalculixCxxtools";
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Elmer");
|
||||
auto elmerBinaryPath = hGrp->GetASCII("elmerBinaryPath", "");
|
||||
if (!elmerBinaryPath.empty())
|
||||
if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty())
|
||||
*solve << "FEM_SolverElmer";
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/mystran");
|
||||
auto MystranBinaryPath = hGrp->GetASCII("MystranBinaryPath", "");
|
||||
if (!MystranBinaryPath.empty())
|
||||
// also check the multi-CPU Elmer build
|
||||
else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty())
|
||||
*solve << "FEM_SolverElmer";
|
||||
if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty())
|
||||
*solve << "FEM_SolverMystran";
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/Z88");
|
||||
auto z88BinaryPath = hGrp->GetASCII("z88BinaryPath", "");
|
||||
if (!z88BinaryPath.empty())
|
||||
if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty())
|
||||
*solve << "FEM_SolverZ88";
|
||||
*solve << "Separator"
|
||||
<< "FEM_CompMechEquations"
|
||||
|
||||
@@ -248,7 +248,7 @@ class Results(run.Results):
|
||||
self._handleStedyStateResult()
|
||||
else:
|
||||
self._handleTransientResults()
|
||||
|
||||
|
||||
def _handleStedyStateResult(self):
|
||||
if self.solver.ElmerResult is None:
|
||||
self._createResults()
|
||||
@@ -351,7 +351,7 @@ class Results(run.Results):
|
||||
)
|
||||
self.solver.ElmerTimeResults = tmplist
|
||||
self._finishTimeResults(time, counter-1)
|
||||
|
||||
|
||||
def _finishTimeResults(self, time, counter):
|
||||
# we purposely use the decimal dot in the label
|
||||
self.solver.ElmerTimeResults[counter].Label\
|
||||
|
||||
Reference in New Issue
Block a user