1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Insertion de fissure longue - maillage pipe fond fissure"""
24 from .geomsmesh import geompy
25 from .geomsmesh import smesh
26 from salome.smesh import smeshBuilder
29 from .sortEdges import sortEdges
30 from .putName import putName
34 def insereFissureLongue_a (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
35 VerticesEndPipeFiss, verticesEdgePeauFiss, \
36 groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
37 profondeur, rayonPipe, distance2):
38 """maillage pipe fond fissure"""
41 meshFondFiss = smesh.Mesh(pipeFondFiss)
42 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
43 algo3d = meshFondFiss.Prism()
44 putName(algo3d.GetSubMesh(), "pipe")
45 putName(algo3d, "algo3d_pipe")
46 putName(algo2d, "algo2d_pipe")
48 for i, face in enumerate(disques):
49 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face)
50 putName(algo2d.GetSubMesh(), "disque", i)
51 putName(algo2d, "algo2d_disque", i)
53 for i, edge in enumerate(rayons):
54 algo1d = meshFondFiss.Segment(geom=edge)
55 hypo1d = algo1d.NumberOfSegments(4)
56 putName(algo1d.GetSubMesh(), "rayon", i)
57 putName(algo1d, "algo1d_rayon", i)
58 putName(hypo1d, "hypo1d_rayon", i)
60 for i, edge in enumerate(demiCercles):
61 algo1d = meshFondFiss.Segment(geom=edge)
62 hypo1d = algo1d.NumberOfSegments(6)
63 putName(algo1d.GetSubMesh(), "demiCercle", i)
64 putName(algo1d, "algo1d_demiCercle", i)
65 putName(hypo1d, "hypo1d_demiCercle", i)
67 generSorted, minlg, maxlg = sortEdges(generatrices)
68 nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face
70 logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted))
71 for i, edge in enumerate(generSorted):
72 algo1d = meshFondFiss.Segment(geom=edge)
74 hypo1d = algo1d.NumberOfSegments(nbSegGenBout)
76 hypo1d = algo1d.NumberOfSegments(nbSegGenLong)
77 putName(algo1d.GetSubMesh(), "generatrice", i)
78 putName(algo1d, "algo1d_generatrice", i)
79 putName(hypo1d, "hypo1d_generatrice", i)
82 for i, face in enumerate(disques[:4]):
84 disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE))
85 _ = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
87 _ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE)
88 _ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE)
90 _ = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE)
91 _ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE)
92 _ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE)
94 groups_demiCercles = list()
95 groupnodes_demiCercles = list()
96 for i, group in enumerate(groupsDemiCerclesPipe):
98 groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE))
100 groupnodes_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.NODE))
101 group_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.EDGE)
102 groupnode_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.NODE)
104 is_done = meshFondFiss.Compute()
105 text = "meshFondFiss.Compute"
107 logging.info(text+" OK")
109 text = "Erreur au calcul du maillage.\n" + text
111 raise Exception(text)
113 grpNode0 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[0], "Node0")
114 grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1")
115 idNode0 = grpNode0.GetID(1)
116 idNode1 = grpNode1.GetID(1)
118 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0))
119 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1))
121 for vertex in verticesEdgePeauFiss:
122 coord = geompy.PointCoordinates(vertex)
123 if distance2(coord, coordsMesh[0]) < 0.1:
124 meshFondFiss.MoveNode(idNode0, coord[0], coord[1], coord[2])
125 if distance2(coord, coordsMesh[1]) < 0.1:
126 meshFondFiss.MoveNode(idNode1, coord[0], coord[1], coord[2])
128 for groupNodes in groupnodes_demiCercles:
129 for idNode in groupNodes.GetListOfID():
130 coordMesh = meshFondFiss.GetNodeXYZ(idNode)
131 vertex = geompy.MakeVertex(coordMesh[0], coordMesh[1], coordMesh[2])
135 for i, edge in enumerate(demiCerclesPeau):
136 discoord = geompy.MinDistanceComponents(vertex, edge)
137 if discoord[0] <minDist:
138 minDist = discoord[0]
139 minCoord = discoord[1:]
141 if imin >= 0 and minDist > 1.E-6:
142 logging.debug("node id moved : %s distance=%s", idNode, minDist)
143 meshFondFiss.MoveNode(idNode, coordMesh[0] + minCoord[0], coordMesh[1] + minCoord[1], coordMesh[2] + minCoord[2])
145 return meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout