def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     part = self.obj.Part
     if self.mesh_obj.MeshRegionList:
         if part.Shape.ShapeType == "Compound" and hasattr(part, "Proxy"):  # other part obj might not have a Proxy, thus an exception would be raised
             if (part.Proxy.Type == "FeatureBooleanFragments" or part.Proxy.Type == "FeatureSlice" or part.Proxy.Type == "FeatureXOR"):
                 error_message = "The mesh to shape is a boolean split tools Compound and the mesh has mesh region list. Gmsh could return unexpected meshes in such circumstances. It is strongly recommended to extract the shape to mesh from the Compound and use this one."
                 QtGui.QMessageBox.critical(None, "Shape to mesh is a BooleanFragmentsCompound and mesh regions are defined", error_message)
     self.Start = time.time()
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.console_message_gmsh = ''
     self.gmsh_runs = True
     self.console_log("We are going to start ...")
     self.get_active_analysis()
     import femmesh.gmshtools as gmshtools
     gmsh_mesh = gmshtools.GmshTools(self.obj, self.analysis)
     self.console_log("Start Gmsh ...")
     error = ''
     try:
         error = gmsh_mesh.create_mesh()
     except:
         import sys
         print("Unexpected error when creating mesh: ", sys.exc_info()[0])
     if error:
         print(error)
         self.console_log('Gmsh had warnings ...')
         self.console_log(error, '#FF0000')
     else:
         self.console_log('Clean run of Gmsh')
     self.console_log("Gmsh done!")
     self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
예제 #2
0
 def get_gmsh_version(self):
     from femmesh import gmshtools
     version, full_message = gmshtools.GmshTools(self.mesh_obj, self.analysis).get_gmsh_version()
     QtGui.QMessageBox.information(
         None,
         "Gmsh - Information",
         full_message
     )
예제 #3
0
 def run_gmsh(self):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     part = self.mesh_obj.Part
     if (
         self.mesh_obj.MeshRegionList and part.Shape.ShapeType == "Compound"
         and (
             is_of_type(part, "FeatureBooleanFragments")
             or is_of_type(part, "FeatureSlice")
             or is_of_type(part, "FeatureXOR")
         )
     ):
         error_message = (
             "The shape to mesh is a boolean split tools Compound "
             "and the mesh has mesh region list. "
             "Gmsh could return unexpected meshes in such circumstances. "
             "It is strongly recommended to extract the shape "
             "to mesh from the Compound and use this one."
         )
         qtbox_title = (
             "Shape to mesh is a BooleanFragmentsCompound "
             "and mesh regions are defined"
         )
         QtGui.QMessageBox.critical(
             None,
             qtbox_title,
             error_message
         )
     self.Start = time.time()
     self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start))
     self.console_message_gmsh = ""
     self.gmsh_runs = True
     self.console_log("We are going to start ...")
     self.get_active_analysis()
     from femmesh import gmshtools
     gmsh_mesh = gmshtools.GmshTools(self.mesh_obj, self.analysis)
     self.console_log("Start Gmsh ...")
     error = ""
     try:
         error = gmsh_mesh.create_mesh()
     except Exception:
         error = sys.exc_info()[1]
         FreeCAD.Console.PrintMessage(
             "Unexpected error when creating mesh: {}\n"
             .format(error)
         )
     if error:
         FreeCAD.Console.PrintMessage("Gmsh had warnings ...\n")
         FreeCAD.Console.PrintMessage("{}\n".format(error))
         self.console_log("Gmsh had warnings ...")
         self.console_log(error, "#FF0000")
     else:
         FreeCAD.Console.PrintMessage("Clean run of Gmsh\n")
         self.console_log("Clean run of Gmsh")
     self.console_log("Gmsh done!")
     self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start))
     self.Timer.stop()
     self.update()
     QApplication.restoreOverrideCursor()
예제 #4
0
 def get_gmsh_version(self):
     from femmesh import gmshtools
     version, full_message = gmshtools.GmshTools(
         self.mesh_obj, self.analysis).get_gmsh_version()
     if version[0] and version[1] and version[2]:
         messagebox = QtGui.QMessageBox.information
     else:
         messagebox = QtGui.QMessageBox.warning
     messagebox(None, "Gmsh - Information", full_message)
예제 #5
0
파일: writer.py 프로젝트: gwicke/FreeCAD
    def _exportToUnv(self, groups, mesh, meshPath):
        unvGmshFd, unvGmshPath = tempfile.mkstemp(suffix=".unv")
        brepFd, brepPath = tempfile.mkstemp(suffix=".brep")
        geoFd, geoPath = tempfile.mkstemp(suffix=".geo")
        os.close(brepFd)
        os.close(geoFd)
        os.close(unvGmshFd)

        tools = gmshtools.GmshTools(mesh)
        tools.group_elements = {g: [g] for g in groups}
        tools.group_nodes_export = False
        tools.ele_length_map = {}
        tools.temp_file_geometry = brepPath
        tools.temp_file_geo = geoPath
        tools.temp_file_mesh = unvGmshPath

        tools.get_dimension()
        tools.get_region_data()
        tools.get_boundary_layer_data()
        tools.write_part_file()
        tools.write_geo()
        if self.testmode:
            Console.PrintMessage(
                "Solver Elmer testmode, Gmsh will not be used. "
                "It might not be installed.\n")
            import shutil
            shutil.copyfile(geoPath,
                            os.path.join(self.directory, "group_mesh.geo"))
        else:
            tools.get_gmsh_command()
            tools.run_gmsh_with_geo()

            ioMesh = Fem.FemMesh()
            ioMesh.read(unvGmshPath)
            ioMesh.write(meshPath)

        os.remove(brepPath)
        os.remove(geoPath)
        os.remove(unvGmshPath)
예제 #6
0
 def create_mesh(self):
     self.mesh = ObjectsFem.makeMeshGmsh(self.doc, "Mesh")
     self.doc.Mesh.Part = self.doc.Geometry
     g = gmshtools.GmshTools(self.doc.Mesh)
     g.create_mesh()
     self.analysis.addObject(self.mesh)