1 # -*- coding: utf-8 -*-
5 from .geomsmesh import geompy
6 from .geomsmesh import smesh
9 def construitMaillagePipe(gptsdisks, idisklim, nbsegCercle, nbsegRad):
11 maillage effectif du pipe
14 meshPipe = smesh.Mesh(None, "meshPipe")
15 fondFissGroup = meshPipe.CreateEmptyGroup(SMESH.EDGE, "FONDFISS")
16 nodesFondFissGroup = meshPipe.CreateEmptyGroup(SMESH.NODE, "nfondfis")
17 faceFissGroup = meshPipe.CreateEmptyGroup(SMESH.FACE, "fisInPi")
18 edgeFaceFissGroup = meshPipe.CreateEmptyGroup(SMESH.EDGE, "edgeFaceFiss")
19 edgeCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.EDGE, "edgeCircPipe0")
20 edgeCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.EDGE, "edgeCircPipe1")
21 faceCircPipe0Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe0")
22 faceCircPipe1Group = meshPipe.CreateEmptyGroup(SMESH.FACE, "faceCircPipe1")
24 mptsdisks = [] # vertices maillage de tous les disques
25 mEdges = [] # identifiants edges maillage fond de fissure
26 mEdgeFaces = [] # identifiants edges maillage edge face de fissure externe
27 mFaces = [] # identifiants faces maillage fissure
28 mVols = [] # identifiants volumes maillage pipe
31 for idisk in range(idisklim[0], idisklim[1]+1): # boucle sur les disques internes
33 # -----------------------------------------------------------------------
36 gptdsk = gptsdisks[idisk]
37 if idisk > idisklim[0]:
39 mptdsk = [] # vertices maillage d'un disque
40 for k in range(nbsegCercle):
43 for j, pt in enumerate(points):
47 coords = geompy.PointCoordinates(pt)
48 id = meshPipe.AddNode(coords[0], coords[1], coords[2])
51 mptsdisks.append(mptdsk)
53 # -----------------------------------------------------------------------
54 # --- groupes edges cercles debouchants
56 if idisk == idisklim[0]:
58 for k in range(nbsegCercle):
59 pts.append(mptdsk[k][-1])
61 for k in range(len(pts)):
63 idEdge = meshPipe.AddEdge([pts[k], pts[k1]])
65 edgeCircPipe0Group.Add(edges)
67 if idisk == idisklim[1]:
69 for k in range(nbsegCercle):
70 pts.append(mptdsk[k][-1])
72 for k in range(len(pts)):
74 idEdge = meshPipe.AddEdge([pts[k], pts[k1]])
76 edgeCircPipe1Group.Add(edges)
78 # -----------------------------------------------------------------------
79 # --- groupes faces debouchantes
81 if idisk == idisklim[0]:
83 for j in range(nbsegRad):
84 for k in range(nbsegCercle):
86 if k == nbsegCercle-1:
89 idf = meshPipe.AddFace([mptdsk[k][0], mptdsk[k][1], mptdsk[k1][1]]) # triangle
91 idf = meshPipe.AddFace([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j]]) # quadrangle
93 faceCircPipe0Group.Add(faces)
95 if idisk == idisklim[1]:
97 for j in range(nbsegRad):
98 for k in range(nbsegCercle):
100 if k == nbsegCercle-1:
103 idf = meshPipe.AddFace([mptdsk[k][0], mptdsk[k][1], mptdsk[k1][1]]) # triangle
105 idf = meshPipe.AddFace([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j]]) # quadrangle
107 faceCircPipe1Group.Add(faces)
109 # -----------------------------------------------------------------------
110 # --- mailles volumiques, groupes noeuds et edges de fond de fissure, groupe de face de fissure
112 if idisk == idisklim[0]:
117 nodesFondFissGroup.Add([mptdsk[0][0]])
119 ide = meshPipe.AddEdge([oldmpts[0][0], mptdsk[0][0]])
121 fondFissGroup.Add([ide])
122 nodesFondFissGroup.Add([mptdsk[0][0]])
123 ide2 = meshPipe.AddEdge([oldmpts[0][-1], mptdsk[0][-1]])
124 mEdgeFaces.append(ide2)
125 edgeFaceFissGroup.Add([ide2])
129 for j in range(nbsegRad):
130 idf = meshPipe.AddFace([oldmpts[0][j], mptdsk[0][j], mptdsk[0][j+1], oldmpts[0][j+1]])
131 faceFissGroup.Add([idf])
135 for k in range(nbsegCercle):
137 if k == nbsegCercle-1:
140 idv = meshPipe.AddVolume([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1],
141 oldmpts[k][j], oldmpts[k][j+1], oldmpts[k1][j+1]])
143 idv = meshPipe.AddVolume([mptdsk[k][j], mptdsk[k][j+1], mptdsk[k1][j+1], mptdsk[k1][j],
144 oldmpts[k][j], oldmpts[k][j+1], oldmpts[k1][j+1], oldmpts[k1][j]])
145 idVolCercle.append(idv)
146 idVols.append(idVolCercle)
148 mFaces.append(idFaces)
151 pipeFissGroup = meshPipe.CreateEmptyGroup( SMESH.VOLUME, 'PIPEFISS' )
152 nbAdd = pipeFissGroup.AddFrom( meshPipe.GetMesh() )
154 nb, new_mesh, new_group = meshPipe.MakeBoundaryElements(SMESH.BND_2DFROM3D, "pipeBoundaries")
155 edgesCircPipeGroup = [edgeCircPipe0Group, edgeCircPipe1Group]
157 meshPipeGroups = dict(fondFissGroup = fondFissGroup,
158 nodesFondFissGroup = nodesFondFissGroup,
159 faceFissGroup = faceFissGroup,
160 edgeFaceFissGroup = edgeFaceFissGroup,
161 edgeCircPipe0Group = edgeCircPipe0Group,
162 edgeCircPipe1Group = edgeCircPipe1Group,
163 faceCircPipe0Group = faceCircPipe0Group,
164 faceCircPipe1Group = faceCircPipe1Group,
165 pipeFissGroup = pipeFissGroup,
166 edgesCircPipeGroup = edgesCircPipeGroup
169 return (meshPipe, meshPipeGroups, edgesCircPipeGroup)