def __init__(self): import CfdTools self.__class__.Icon = CfdTools.getModulePath() + "/Resources/icons/CfdWorkbench.svg" self.__class__.MenuText = "CFD" self.__class__.ToolTip = "CFD workbench" from PySide import QtCore ICONS_PATH = CfdTools.getModulePath() + "/Resources/icons" QtCore.QDir.addSearchPath("icons", ICONS_PATH) import CfdPreferencePage FreeCADGui.addPreferencePage(CfdPreferencePage.CfdPreferencePage, "CFD")
def GetResources(self): icon_path = os.path.join(CfdTools.getModulePath(), "Resources", "icons", "cfd-foam-boundary.svg") return { 'Pixmap': icon_path, 'MenuText': QtCore.QT_TRANSLATE_NOOP("Cfd_FluidBoundary", "fluid boundary"), 'Accel': "C, F", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Cfd_FluidBoundary", "Creates boundary condition for CFD")}
def __init__(self, obj): self.mesh_obj = obj self.form = FreeCADGui.PySideUic.loadUi(CfdTools.getModulePath() + "/TaskPanelCaeMesherGmsh.ui") self.Timer = QtCore.QTimer() self.Timer.start(100) # 100 milli seconds self.gmsh_runs = False self.console_message_gmsh = '' QtCore.QObject.connect(self.form.if_max, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.max_changed) QtCore.QObject.connect(self.form.if_min, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.min_changed) QtCore.QObject.connect(self.form.cb_dimension, QtCore.SIGNAL("activated(int)"), self.choose_dimension) QtCore.QObject.connect(self.Timer, QtCore.SIGNAL("timeout()"), self.update_timer_text) self.form.cb_dimension.addItems( _CaeMeshGmsh._CaeMeshGmsh.known_element_dimensions) self.get_mesh_params() self.get_active_analysis() self.update()
def get_solver_cmd(self): # get full path to solver script #solver_script_path = os.path.dirname(__file__) + os.path.sep + "main.py" import CfdTools solver_script_path = CfdTools.getModulePath( ) + os.path.sep + "FenicsSolver/main.py" cmd = 'python2 "{}" "{}"'.format(solver_script_path, self.case_file) # mpirun -np {} FreeCAD.Console.PrintMessage("Solver run command: " + cmd + "\n") return cmd
def threadFinished(self, status): if self.thread.task == DEPENDENCY_CHECK: QApplication.restoreOverrideCursor() elif self.thread.task == DOWNLOAD_GNUPLOTPY: self.consoleMessage("Attempting to install Gnuplot-py package:") if platform.system() == 'Windows': python_exe = os.path.join(FreeCAD.getHomePath(), 'bin', 'python.exe') else: python_exe = 'python' cmd = [python_exe, '-u', 'setup.py', 'install'] working_dir = os.path.join(tempfile.gettempdir(), GNUPLOTPY_FILE_BASE) self.install_process = CfdConsoleProcess.CfdConsoleProcess( finishedHook=self.installFinished) print("Running {} in {}".format(' '.join(cmd), working_dir)) self.install_process.start(cmd, working_dir=working_dir) if not self.install_process.waitForStarted(): self.consoleMessage("Unable to run command " + ' '.join(cmd), '#FF0000') elif self.thread.task == DOWNLOAD_CFMESH: if status: self.consoleMessage("Download completed") user_dir = self.thread.user_dir self.consoleMessage( "Building cfMesh. Lengthy process - please wait...") if CfdFoamTools.getFoamRuntime() == "BlueCFD": script_name = "buildCfMeshOnBlueCFD.sh" self.consoleMessage("Log file: {}\\log.{}".format( user_dir, script_name)) shutil.copy( os.path.join(CfdTools.getModulePath(), 'data', script_name), os.path.join(user_dir, script_name)) self.install_process = CfdFoamTools.startFoamApplication( "./" + script_name, "$WM_PROJECT_USER_DIR", self.installFinished) else: self.consoleMessage("Log file: {}/{}/log.Allwmake".format( user_dir, CFMESH_FILE_BASE)) self.install_process = CfdFoamTools.startFoamApplication( "./Allwmake", "$WM_PROJECT_USER_DIR/" + CFMESH_FILE_BASE, self.installFinished) else: self.consoleMessage("Download unsuccessful")
def __init__(self): super(_CommandCfdAnalysisFromMesh, self).__init__() icon_path = os.path.join(CfdTools.getModulePath(), "Resources", "icons", "cfd-analysis-from-mesh.svg") self.resources = { 'Pixmap': icon_path, 'MenuText': QtCore.QT_TRANSLATE_NOOP("Cfd_AnalysisFromMesh", "Analysis container"), 'Accel': "N, I", 'ToolTip': QtCore.QT_TRANSLATE_NOOP( "Cfd_AnalysisFromMesh", "Creates a analysis container from existing geometry and mesh files" ) } self.is_active = 'with_document'
def get_solver_cmd(self): #os.path.dirname(os.path.abspath(a_module.__file__)) to get module install path # python3 -m FenicsSolver/main.py case_file # see example in /usr/lib/python3.6/unittest/__init__.py import CfdTools solver_script_path = CfdTools.getModulePath() + os.path.sep + "FenicsSolver/FenicsSolver/main.py" if sys.version_info.major == 2: python_bin = "python2" elif sys.version_info.major == 3: python_bin = "python3" elif sys.version_info.major == 4: python_bin = "python4" else: python_bin = "python" cmd = '{} "{}" "{}"'.format(python_bin, solver_script_path, self.case_file) # mpirun -np {} FreeCAD.Console.PrintMessage("Solver run command: " + cmd + "\n") return cmd
def getIcon(self): icon_path = os.path.join(CfdTools.getModulePath(), "Resources", "icons", "cfd-foam-boundary.svg") return icon_path
def __init__(self): import CfdTools self.__class__.Icon = CfdTools.getModulePath( ) + "/Resources/icons/CfdWorkbench.svg" self.__class__.MenuText = "CFD" self.__class__.ToolTip = "CFD workbench"
def getIcon(self): """after load from FCStd file, self.icon does not exist, return constant path instead""" icon_path = os.path.join(CfdTools.getModulePath(), "Resources", "icons", "cfd-solver-fenics.svg") return icon_path