def RebuildData(theStudy): smesh.SetCurrentStudy(theStudy) import StdMeshers import NETGENPlugin Mesh_1 = smesh.Mesh(Cut_1) Regular_1D = Mesh_1.Segment() Max_Size_1 = Regular_1D.MaxSize(20.2301) MEFISTO_2D = Mesh_1.Triangle() Tetrahedron_Netgen = Mesh_1.Tetrahedron(algo=smesh.NETGEN) isDone = Mesh_1.Compute() Mesh_1.Clear() isDone = Mesh_1.Compute() Mesh_2 = smesh.Mesh(Y) Regular_1D_1 = Mesh_2.Segment() ns_1 = Regular_1D_1.NumberOfSegments(50, 10, []) isDone = Mesh_2.Compute() Mesh_2.ExtrusionSweepObject1D( Mesh_2, SMESH.DirStruct(SMESH.PointStruct(0, 0, 100)), 5) Mesh_2.RotationSweepObject1D(Mesh_2, SMESH.AxisStruct(0, 0, 0, 0, 0, 10), 0.0872665, 6, 1e-05) ## set object names smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') smesh.SetName(Max_Size_1, 'Max Size_1') smesh.SetName(MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D') smesh.SetName(Tetrahedron_Netgen.GetAlgorithm(), 'Tetrahedron (Netgen)') smesh.SetName(Mesh_2.GetMesh(), 'Mesh_2') smesh.SetName(ns_1, 'ns_1') if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters( theStudy.GetModuleParameters("Interface Applicative", "SMESH", 1)) #Set up entries: # set up entry SMESH_4 (Mesh_2) parameters ipar.setParameter("SMESH_4", "VTKViewer_0_Visibility", "On") ipar.setParameter("SMESH_4", "VTKViewer_0_Representation", "2") ipar.setParameter("SMESH_4", "VTKViewer_0_IsShrunk", "0") ipar.setParameter("SMESH_4", "VTKViewer_0_Entities", "e:1:f:1:v:0") ipar.setParameter( "SMESH_4", "VTKViewer_0_Colors", "surface:0:0.666667:1:backsurface:0:0:1:edge:0:0.666667:1:node:1:0:0") ipar.setParameter("SMESH_4", "VTKViewer_0_Sizes", "line:1:shrink:0.75") ipar.setParameter("SMESH_4", "VTKViewer_0_PointMarker", "std:1:9") ipar.setParameter("SMESH_4", "VTKViewer_0_Opacity", "1") ipar.setParameter("SMESH_4", "VTKViewer_0_ClippingPlane", "Off") pass
def CreateSalomeMesh(newnode, newline, groupline=[], groupnode=[]): """creation a la volle d un mesh dans salome n'est disponible que depuis salome""" mesh = smesh.Mesh() liennoeudsalome = {} for i in range(0, newnode.shape[0]): liennoeudsalome[i] = mesh.AddNode(newnode[i, 0], newnode[i, 1], newnode[i, 2]) lienlinesalome = {} for i in range(0, len(newline)): lienlinesalome[i] = mesh.AddEdge( [liennoeudsalome[newline[i][0]], liennoeudsalome[newline[i][1]]]) #creation des groupes for groupe in groupline: if (len(groupe[1]) > 0): grtemp = [] for a in groupe[1]: grtemp.append(lienlinesalome[a]) a = mesh.MakeGroupByIds(groupe[0], smesh.EDGE, grtemp) for groupe in groupnode: if (len(groupe[1]) > 0): grtemp = [] for a in groupe[1]: grtemp.append(liennoeudsalome[a]) a = mesh.MakeGroupByIds(groupe[0], smesh.NODE, grtemp) salome.sg.updateObjBrowser(1) print "salome mesh done"
def __init__(self, dim, gridDensity, anodebiPolarChannelWidth, anodebiPolarLandWidth, gdlWidth, mplWidth, aclWidth, membraneWidth, cclWidth, cathodebiPolarChannelWidth, cathodebiPolarLandWidth, totalHeight, anodechannelHeight, cathodechannelHeight, depth): mkSalomeMEA2d.__init__(self, dim, gridDensity, anodebiPolarChannelWidth, anodebiPolarLandWidth, gdlWidth, mplWidth, aclWidth, membraneWidth, cclWidth, cathodebiPolarChannelWidth, cathodebiPolarLandWidth, totalHeight, anodechannelHeight, cathodechannelHeight) self.__depth = depth self.compoundMeshThreeD = smesh.Mesh()
def TakeMesh(context): global sp, smesh, salome, subprocess, QtGui, pdb, spawn, myMesh # get active module and check if SMESH if InMeshModule(context): active_module = context.sg.getActiveComponent() exporting_submesh = False sub_mesh_shape = None # get selection selCount = sp.sg.SelectedCount() if selCount == 0: QtGui.QMessageBox.warning(None, str(active_module), "Nothing selected. Please select a mesh.") return # check if selection == mesh elif selCount > 1: QtGui.QMessageBox.warning(None, str(active_module), "More than one mesh selected. Please select only one mesh.") return else: objID = sp.sg.getSelected(0) salomeObj = sp.salome.myStudy.FindObjectID(objID) ref = salome.IDToObject(objID) if (DEBUG): print(ref) name = salomeObj.GetName() # With this you can see which methods are available # WARNING: It prints quite some output! #for method_name in dir(ref): # print(method_name) try: myMesh = smesh.Mesh(ref) except AttributeError as e: try: if (DEBUG): print("it is a submesh:", e) sub_mesh_shape = ref.GetSubShape() exporting_submesh = True except AttributeError: QtGui.QMessageBox.warning(None, str(active_module), "Selection is not a mesh.") return return {"name": name,"myMesh": myMesh, "exporting_submesh": exporting_submesh, "sub_mesh_shape": sub_mesh_shape}
def makeRectanglarMesh(self, dList, width, height): if len(dList) < 3: dList.append(0) Vertex_1 = geompy.MakeVertex(dList[0], dList[1], dList[2]) Vertex_2 = geompy.MakeVertex(dList[0] + width, dList[1], dList[2]) Vertex_3 = geompy.MakeVertex(dList[0] + width, dList[1] + height, dList[2]) Vertex_4 = geompy.MakeVertex(dList[0], dList[1] + height, dList[2]) rect = geompy.MakeQuad4Vertices(Vertex_1, Vertex_2, Vertex_3, Vertex_4) Mesh_1 = smesh.Mesh(rect) Regular_1D = Mesh_1.Segment() Local_Length_1 = Regular_1D.LocalLength(self.meshDensity) Local_Length_1.SetPrecision(1e-07) Mesh_1.Quadrangle() Mesh_1.Compute() return Mesh_1
geompy.addToStudy( Ligne_9, 'Ligne_9' ) geompy.addToStudyInFather( Ligne_1, Ligne_1_vertex_2, 'Ligne_1:vertex_2' ) geompy.addToStudyInFather( Ligne_8, Ligne_8_vertex_3, 'Ligne_8:vertex_3' ) geompy.addToStudy( Ligne_10, 'Ligne_10' ) geompy.addToStudy( Ligne_11, 'Ligne_11' ) geompy.addToStudy( Treillis, 'Treillis' ) ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import StdMeshers Maillage_1 = smesh.Mesh(Treillis) Regular_1D = Maillage_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(1) Nb_Segments_1.SetDistrType( 0 ) isDone = Maillage_1.Compute() Treillis_1 = Maillage_1.GroupOnGeom(Treillis,'Treillis',SMESH.EDGE) Liaison = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'Liaison' ) nbAdd = Liaison.Add( [ 1, 4 ] ) Efforts = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'Efforts' ) nbAdd = Efforts.Add( [ 2, 3 ] ) isDone = Maillage_1.Compute() ## set object names smesh.SetName(Maillage_1.GetMesh(), 'Maillage_1') smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
NETGEN_3D_Parameters.SetMaxSize(mesh_size) NETGEN_3D_Parameters.SetSecondOrder(255) NETGEN_3D_Parameters.SetOptimize(1) NETGEN_3D_Parameters.SetFineness(3) NETGEN_3D_Parameters.SetMinSize(0.053447) NETGEN_3D_Parameters.SetSecondOrder(77) NETGEN_2D_Parameters = smesh.CreateHypothesis('NETGEN_Parameters_2D_ONLY', 'NETGENEngine') NETGEN_2D_Parameters.SetMaxSize(mesh_size) NETGEN_2D_Parameters.SetSecondOrder(255) NETGEN_2D_Parameters.SetOptimize(1) NETGEN_2D_Parameters.SetFineness(3) NETGEN_2D_Parameters.SetMinSize(0.053447) NETGEN_2D_Parameters.SetQuadAllowed(0) NETGEN_2D_Parameters.SetSecondOrder(77) Part_2_hole_1 = smesh.Mesh(Part_w_hole) Regular_1D = Part_2_hole_1.Segment() Max_Size_1 = Regular_1D.MaxSize(mesh_size) status = Part_2_hole_1.AddHypothesis(NETGEN_2D_Parameters) NETGEN_2D_ONLY = Part_2_hole_1.Triangle(algo=smesh.NETGEN_2D) status = Part_2_hole_1.AddHypothesis(NETGEN_3D_Parameters) NETGEN_3D = Part_2_hole_1.Tetrahedron(algo=smesh.NETGEN) isDone = Part_2_hole_1.Compute() ################################################ # Creation of the group on nodes/elements # ################################################ Embeddinf = smesh.GetFilter(SMESH.NODE, smesh.FT_BelongToCylinder, face_bc_emb) Embeddin = Part_2_hole_1.GroupOnFilter(SMESH.NODE, "Embeddin", Embeddinf)
def createMesh(context): """Context sensitive window for setting for mesh export. Only a mesh-node in the object tree of salome will create the correct output - unv-mesh and ElmerGrid mesh. Args: ----- context: salome context Context variable provided by the Salome environment """ global main, sp, smesh, salome, subprocess, QtGui, pdb, spawn # get active module and check if SMESH active_module = context.sg.getActiveComponent() if active_module != "SMESH": QtGui.QMessageBox.information(None, str(active_module), "Functionality is only provided in mesh module.") return # get selection selCount = sp.sg.SelectedCount() if selCount == 0: QtGui.QMessageBox.warning(None, str(active_module), "Nothing selected. Please select a mesh.") return # check if selection == mesh else: objID = sp.sg.getSelected(0) ref = salome.IDToObject(objID) try: myMesh = smesh.Mesh(ref) except AttributeError: QtGui.QMessageBox.warning(None, str(active_module), "Selection is not a mesh.") return # get a filename for saving the unv-mesh title = 'Export mesh to file' fname = QtGui.QFileDialog.getSaveFileName(parent=None, caption=title, filter='Mesh files (*.unv)') # Salome 8.2 behavior if isinstance(fname, tuple): fname = fname[0] # pdb.set_trace() # call to ElmerGrid for converting the unv-file to Elmer-readable file if fname: fname = os.path.normpath(str(fname)) path = os.path.dirname(fname) # Linux does not add file ending automatically if not fname.endswith('.unv'): fname = '{}.unv'.format(fname) if os.path.exists(fname): os.remove(fname) myMesh.ExportUNV(fname) prgm = spawn.find_executable('ElmerGrid') if prgm != None: try: # on Linux shell=True required, # see http://stackoverflow.com/a/18962815/4141279 subprocess.Popen("ElmerGrid 8 2 {0} -autoclean -out {1}".format(fname, path), shell=True) main.meshDirectory = path except OSError: QtGui.QMessageBox.about(None, "File IO error", "fname: {}, path: {}".format(fname, path)) print fname print path return else: QtGui.QMessageBox.warning(None, str(active_module), "ElmerGrid executable not found. Check system variables.") return
geompy.addToStudyInFather(Anneau, Haut, 'Haut') geompy.addToStudyInFather(Anneau, Bas, 'Bas') ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters( theStudy.GetModuleParameters("Interface Applicative", "GEOM", 1)) #Set up entries: # set up entry GEOM_1 (Sommet_1) parameters import smesh, SMESH, SALOMEDS # Definition du maillage smesh.SetCurrentStudy(theStudy) import StdMeshers Maillage_1 = smesh.Mesh(Anneau) Regular_1D = Maillage_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(15, [], []) Nb_Segments_1.SetDistrType(0) isDone = Maillage_1.Compute() TOUT = Maillage_1.GroupOnGeom(Anneau, 'Anneau', SMESH.EDGE) Bas_1 = Maillage_1.GroupOnGeom(Bas, 'Bas', SMESH.NODE) Haut_1 = Maillage_1.GroupOnGeom(Haut, 'Haut', SMESH.NODE) TOUT.SetName('TOUT') [TOUT, Bas_1, Haut_1] = Maillage_1.GetGroups() smesh.SetName(Maillage_1, 'Maillage_1') Maillage_1.ExportMED(currentPath, 0, SMESH.MED_V2_2, 1) ## set object names smesh.SetName(Maillage_1.GetMesh(), 'Maillage_1') smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
# Create a group of faces group = CreateGroup(piece, ShapeType["FACE"]) group_name = name + "_grp" addToStudy(group, group_name) group.SetName(group_name) # Add faces to the group faces = SubShapeAllIDs(piece, ShapeType["FACE"]) UnionIDs(group, faces) ### # Create a mesh ### # Define a mesh on a geometry tetra = smesh.Mesh(piece, name) # Define 1D hypothesis algo1d = tetra.Segment() algo1d.LocalLength(10) # Define 2D hypothesis algo2d = tetra.Triangle() algo2d.LengthFromEdges() # Define 3D hypothesis algo3d = tetra.Tetrahedron() algo3d.MaxElementVolume(100) # Compute the mesh tetra.Compute()
ipar.setParameter(objId, "OCCViewer_0_Color", "1:1:0") # set up entry GEOM_1:3 (tout) parameters objId = geompy.getObjectID(tout) ipar.setParameter(objId, "OCCViewer_0_Visibility", "On") ipar.setParameter(objId, "OCCViewer_0_Color", "1:1:0") ### ### SMESH component ### import smesh, SMESH, SALOMEDS aMeasurements = smesh.CreateMeasurements() smesh.SetCurrentStudy(theStudy) import StdMeshers Mesh_1 = smesh.Mesh(Box_1) CompositeSegment_1D = Mesh_1.Segment(algo=smesh.COMPOSITE) Local_Length_1 = CompositeSegment_1D.LocalLength(0.2) Local_Length_1.SetPrecision( 1e-07 ) Quadrangle_2D = Mesh_1.Quadrangle() Hexa_3D = smesh.CreateHypothesis('Hexa_3D') status = Mesh_1.AddHypothesis(Hexa_3D) forc_1 = Mesh_1.GroupOnGeom(forc,'forc',SMESH.FACE) toutface_1 = Mesh_1.GroupOnGeom(toutface,'toutface',SMESH.FACE) tout_1 = Mesh_1.GroupOnGeom(tout,'tout',SMESH.VOLUME) isDone = Mesh_1.Compute() Local_Length_1.SetLength( 0.25 ) Local_Length_1.SetPrecision( 1e-07 ) ## set object names smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
Edge_L5 = edgeGroups[6] #7 Edge_L6 = edgeGroups[7] #8 Edge_A1 = edgeGroups[8] Edge_A2 = edgeGroups[9] Edge_R1 = edgeGroups[10] Edge_R2 = edgeGroups[11] # # 0 1 2 3 4 5 6 7 LenNS = [50, 50, 20, 40, 40, 40, 20, 20] # AzlNS = [5, 10] # RadNS = [15, 5] # #creating mesh injMesh = smesh.Mesh(injGeom, "injMesh") #default 1D hypothesis default1D = injMesh.Segment() default1D.NumberOfSegments(5) #quadrangle 2D meshing injMesh.Quadrangle() # Parallel to X algo_Edge_L1 = injMesh.Segment(Edge_L1) algo_Edge_L1.NumberOfSegments(LenNS[0], 0.08) algo_Edge_L1.Propagation() # algo_Edge_L1a= injMesh.Segment(Edge_L1a) algo_Edge_L1a.NumberOfSegments(LenNS[1], 0.08) algo_Edge_L1a.Propagation() # algo_Edge_L2 = injMesh.Segment(Edge_L2)
geompy.addToStudy(Partition_2, 'Partition_2') geompy.addToStudy(Tuyau_2, 'Tuyau_2') geompy.addToStudyInFather(Partition_1, Face_5, 'Face_5') geompy.addToStudyInFather(Partition_1, Face_6, 'Face_6') ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import NETGENPlugin import StdMeshers Maillage_1 = smesh.Mesh(joint) NETGEN_2D = Maillage_1.Triangle(algo=smesh.NETGEN_1D2D) NETGEN_2D_Simple_Parameters = NETGEN_2D.Parameters(smesh.SIMPLE) NETGEN_2D_Simple_Parameters.SetNumberOfSegments(15) NETGEN_2D_Simple_Parameters.LengthFromEdges() NETGEN_2D_Simple_Parameters.SetAllowQuadrangles(0) isDone = Maillage_1.Compute() ## set object names smesh.SetName(Maillage_1.GetMesh(), 'Maillage_1') smesh.SetName(NETGEN_2D.GetAlgorithm(), 'NETGEN_2D') smesh.SetName(NETGEN_2D_Simple_Parameters, 'NETGEN 2D Simple Parameters_1') if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1)
### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters( theStudy.GetModuleParameters("Interface Applicative", "GEOM", 1)) #Set up entries: ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import NETGENPlugin Mesh_1 = smesh.Mesh(Plaque) NETGEN_2D = Mesh_1.Triangle(algo=smesh.NETGEN_1D2D) NETGEN_2D_Parameters = NETGEN_2D.Parameters() NETGEN_2D_Parameters.SetMaxSize(1) NETGEN_2D_Parameters.SetMinSize(0.5) isDone = Mesh_1.Compute() Encastre_1 = Mesh_1.GroupOnGeom(Encastre, 'Encastre', SMESH.EDGE) Moment_1 = Mesh_1.GroupOnGeom(Moment, 'Moment', SMESH.EDGE) Plaque_1 = Mesh_1.GroupOnGeom(Plaque, 'Plaque', SMESH.FACE) ## set object names smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') smesh.SetName(NETGEN_2D.GetAlgorithm(), 'NETGEN_2D') smesh.SetName(NETGEN_2D_Parameters, 'NETGEN 2D Parameters') smesh.SetName(Encastre_1, 'Encastre') smesh.SetName(Moment_1, 'Moment')
### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import StdMeshers Nb_Segments_1 = smesh.CreateHypothesis('NumberOfSegments') Nb_Segments_1.SetNumberOfSegments(10) Nb_Segments_1.SetDistrType(0) Regular_1D = smesh.CreateHypothesis('Regular_1D') Maillage_1 = smesh.Mesh(Cadre) status = Maillage_1.AddHypothesis(Nb_Segments_1) status = Maillage_1.AddHypothesis(Regular_1D) isDone = Maillage_1.Compute() TOUT = Maillage_1.CreateEmptyGroup(SMESH.EDGE, 'TOUT') nbAdd = TOUT.Add([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140 ]) TOUT.SetColor(SALOMEDS.Color(0, 0.666667, 1))
################################################# ## DISPLAY ################################################# #gg.createAndDisplayGO(id_p1) #gg.setDisplayMode(id_p1,1) #gg.setColor(id_p1, 150, 150, 180) #gg.setTransparency(id_p1, 0.8) ################################################# ## MESHING ################################################# import smesh, SMESH, SALOMEDS print("\n" * 100) print "meshing..." # create a mesh tetraN = smesh.Mesh(p1, "Mesh_1") # create a Netgen_2D3D algorithm for solids algo3D = tetraN.Tetrahedron(smesh.FULL_NETGEN) # define hypotheses n23_params = algo3D.Parameters() #START MESH PARAM SECTION n23_params.SetMaxSize(MaxMeshSize / 1000) # here specify in m n23_params.SetMinSize(MinMeshSize / 1000) n23_params.SetNbSegPerEdge(MeshSegPerEdge) n23_params.SetGrowthRate(MeshGrowthRate) n23_params.SetOptimize(MeshOptimize) #END MESH PARAM SECTION
# display the results gg.createAndDisplayGO(id_air) gg.setDisplayMode(id_air, 2) # ==================================================================================== # ===== Creates outer mesh of the "box" ===== objectBox = salome.myStudy.FindObjectByPath("/Geometry/box").GetObject() listBox = geompy.ExtractShapes(objectBox, geompy.ShapeType["SHELL"], True) Box = geompy.ExtractShapes(listBox[1], geompy.ShapeType["FACE"], True) boxNames = ['minX', 'minY', 'minZ', 'maxZ', 'maxY', 'maxX'] for i, v in enumerate(Box): id_temp_common = geompy.addToStudy(v, boxNames[i]) gg.createAndDisplayGO(id_temp_common) gg.setDisplayMode(id_temp_common, 2) triaN = smesh.Mesh(v, boxNames[i]) algo2D = triaN.Triangle(smesh.NETGEN_1D2D) n12_params = algo2D.Parameters() # decrease parameter if during computation files "domain*" are produced, # it means that two region surfaces intersect and more fine .stl mesh is needed n12_params.SetMaxSize(0.03) triaN.Compute() # command saves all surfaces of "box" region in separate files # !!! change "/home/juris/Desktop" to appropriate location triaN.ExportSTL( "/home/juris/Desktop/multiRegionPlasma/multiRegionPlasmaTest/geometry/draft/" + boxNames[i] + ".stl", 1)
geompy.addToStudy(Ligne_9, 'Ligne_9') geompy.addToStudy(Ligne_10, 'Ligne_10') geompy.addToStudy(Ligne_11, 'Ligne_11') geompy.addToStudy(Ligne_12, 'Ligne_12') geompy.addToStudy(Assemblage_1, 'Assemblage_1') ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import StdMeshers Maillage_1 = smesh.Mesh(Assemblage_1) Regular_1D = Maillage_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(1) Nb_Segments_1.SetDistrType(0) isDone = Maillage_1.Compute() TOUT = Maillage_1.CreateEmptyGroup(SMESH.EDGE, 'TOUT') nbAdd = TOUT.AddFrom(Maillage_1.GetMesh()) Group_1 = Maillage_1.CreateEmptyGroup(SMESH.NODE, 'Group_1') nbAdd = Group_1.Add([6]) Group_1.SetColor(SALOMEDS.Color(1, 0.666667, 0)) Group_2 = Maillage_1.CreateEmptyGroup(SMESH.NODE, 'Group_2') nbAdd = Group_2.Add([5]) Group_2.SetColor(SALOMEDS.Color(1, 0.666667, 0)) Group_2 = Maillage_1.CreateEmptyGroup(SMESH.NODE, 'Group_3') nbAdd = Group_2.Add([1]) Group_2.SetColor(SALOMEDS.Color(1, 0.666667, 0))
''' Python script for removing internal edge numbering in Salome Created by: Philip Wardlaw 30 Oct 2012 ''' import geompy, salome, smesh, SMESH #Rename mesh_name to the desired mesh that you wish to remove internal edges from #------------------------------------# mesh_name = "one_by_one_square_mesh.unv" #------------------------------------# #Get mesh mesh1 = smesh.Mesh(salome.myStudy.FindObject(mesh_name).GetObject()) #Get external edges search_filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces) external_faces = mesh1.GetIdsFromFilter(search_filter) #get all faces all_Faces = mesh1.GetElementsByType(SMESH.FACE) faces_to_remove = [] #find the difference for f in all_Faces: if f in external_faces: pass else: faces_to_remove.append(f)
geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import StdMeshers Maillage_1 = smesh.Mesh(Ligne_1) Regular_1D = Maillage_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(20) Nb_Segments_1.SetDistrType( 0 ) isDone = Maillage_1.Compute() POUTRE = Maillage_1.GroupOnGeom(Ligne_1,'Ligne_1',SMESH.EDGE) POUTRE_1 = Maillage_1.GroupOnGeom(Ligne_1,'Ligne_1',SMESH.NODE) POUTRE_1.SetName( 'POU§TRE' ) POUTRE_1.SetName( 'POUTRE' ) POUTRE.SetName( 'POUTRE' ) Encastre = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'Encastre' ) nbAdd = Encastre.Add( [ 1 ] ) Effort = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'Effort' ) nbAdd = Effort.Add( [ 2 ] ) isDone = Maillage_1.Compute() [ POUTRE, POUTRE_1, Encastre, Effort ] = Maillage_1.GetGroups()
geompy.addToStudyInFather(Plaque, droite, 'droite') geompy.addToStudyInFather(Plaque, Fin, 'Fin') geompy.addToStudyInFather(Plaque, centre, 'centre') geompy.addToStudyInFather(Plaque, ext, 'ext') ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import StdMeshers import NETGENPlugin Maillage_1 = smesh.Mesh(Plaque) NETGEN_2D = Maillage_1.Triangle(algo=smesh.NETGEN_1D2D) NETGEN_2D_Parameters = NETGEN_2D.Parameters() NETGEN_2D_Parameters.SetMaxSize(50) NETGEN_2D_Parameters.SetSecondOrder(0) NETGEN_2D_Parameters.SetOptimize(1) NETGEN_2D_Parameters.SetFineness(2) NETGEN_2D_Parameters.SetMinSize(1) NETGEN_2D_Parameters.SetQuadAllowed(0) Regular_1D = Maillage_1.Segment(geom=centre) Nb_Segments_1 = Regular_1D.NumberOfSegments(250) Nb_Segments_1.SetDistrType(0) Regular_1D_1 = Maillage_1.Segment(geom=gauche) Arithmetic_1D_1 = Regular_1D_1.Arithmetic1D(1, 5, []) Regular_1D_2 = Maillage_1.Segment(geom=droite) Arithmetic_1D_2 = Regular_1D_2.Arithmetic1D(1, 5, [])
geompy.addToStudy(Quadrangle_Face_3, 'Quadrangle Face_3') geompy.addToStudy(Quadrangle_Face_4, 'Quadrangle Face_4') geompy.addToStudy(Quadrangle_Face_5, 'Quadrangle Face_5') geompy.addToStudy(Quadrangle_Face_6, 'Quadrangle Face_6') geompy.addToStudy(Quadrangle_Face_7, 'Quadrangle Face_7') ### ### SMESH component ### import smesh, SMESH, SALOMEDS aMeasurements = smesh.CreateMeasurements() smesh.SetCurrentStudy(theStudy) import StdMeshers Mesh_1 = smesh.Mesh(Quadrangle_Face_1) Regular_1D = Mesh_1.Segment() Local_Length_1 = Regular_1D.LocalLength(mesh_length) Local_Length_1.SetPrecision(1e-07) Quadrangle_2D = Mesh_1.Quadrangle() isDone = Mesh_1.Compute() Mesh_2 = smesh.Mesh(Quadrangle_Face_2) status = Mesh_2.AddHypothesis(Local_Length_1) Regular_1D_1 = Mesh_2.Segment() Quadrangle_2D_1 = Mesh_2.Quadrangle() isDone = Mesh_2.Compute() Mesh_3 = smesh.Mesh(Quadrangle_Face_3) status = Mesh_3.AddHypothesis(Local_Length_1) Regular_1D_2 = Mesh_3.Segment() Quadrangle_2D_2 = Mesh_3.Quadrangle() isDone = Mesh_3.Compute()