def run_elmergrid(export_path, mesh_object, out_dir=None): """ Run ElmerGrid as an external process if it found in the operating system. :param export_path: path where the result is written :param mesh_object: FreeCAD mesh object that is to be exported :param out_dir: directory where to write mesh files (if not given unv file name is used) """ # Export to UNV file for Elmer export_objects = [mesh_object] Fem.export(export_objects, export_path) optional_path_to_elmer = '' # optional path to ElmerGrid elmerGrid_command = optional_path_to_elmer + 'ElmerGrid 8 2 ' + export_path + ' -autoclean -names' if out_dir is not None: elmerGrid_command += ' -out ' + out_dir from PySide import QtCore, QtGui try: process = QtCore.QProcess() process.startDetached(elmerGrid_command) FreeCAD.Console.PrintMessage('Running ' + elmerGrid_command + '\n') FreeCAD.Console.PrintMessage('Finished ' + elmerGrid_command + '\n') except: FreeCAD.Console.PrintError('Error') QtGui.QMessageBox.critical(None, 'Error', 'Error!!', QtGui.QMessageBox.Abort)
def run_elmergrid(export_path, mesh_object): """ Run ElmerGrid as an external process if it found in the operating system. :param export_path: path where the result is written :param mesh_object: FreeCAD mesh object that is to be exported """ #Export to UNV file for Elmer export_objects = [] export_objects.append(mesh_object) Fem.export(export_objects, export_path) optional_path_to_elmer = '' # optional path to ElmerGrid elmerGrid_command = optional_path_to_elmer + 'ElmerGrid 8 2 ' + export_path + ' -autoclean -names' #print elmerGrid_command from PySide import QtCore, QtGui from platform import system import os process = QtCore.QProcess() try: process = QtCore.QProcess() process.startDetached(elmerGrid_command) FreeCAD.Console.PrintMessage('Running ' + elmerGrid_command + '\n') FreeCAD.Console.PrintMessage('Finished ' + elmerGrid_command + '\n') except: FreeCAD.Console.PrintError('Error') QtGui.QMessageBox.critical(None, 'Error', 'Error!!', QtGui.QMessageBox.Abort)
def export_unv(export_path, mesh_object): """ Exports UNV file for Elmer. :param export_path: string :param mesh_object: Mesh object """ Fem.export([mesh_object], export_path)
def write_unv_mesh(mesh_obj, bc_group, mesh_file_name): __objs__ = [] __objs__.append(mesh_obj) FreeCAD.Console.PrintMessage("Export FemMesh to UNV format file: {}\n".format(mesh_file_name)) Fem.export(__objs__, mesh_file_name) del __objs__ # repen this unv file and write the boundary faces _write_unv_bc_mesh(mesh_obj, bc_group, mesh_file_name)
def write_unv_mesh(mesh_obj, bc_group, mesh_file_name, is_gmsh = False): # if bc_group is specified as empty or None, it means UNV boundary mesh has been write by Fem.export(), no need to write twice __objs__ = [] __objs__.append(mesh_obj) FreeCAD.Console.PrintMessage("Export FemMesh to UNV format file: {}\n".format(mesh_file_name)) Fem.export(__objs__, mesh_file_name) del __objs__ # repen this unv file and write the boundary faces if not is_gmsh: _write_unv_bc_mesh(mesh_obj, bc_group, mesh_file_name) else: # adjust exported boundary name in UNV file to match those names of FemConstraint derived class _update_unv_boundary_names(bc_group, mesh_file_name)