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"""
26 from salome.smesh import smeshBuilder
29 from .geomsmesh import geompy
30 from .geomsmesh import smesh
32 from .sortEdges import sortEdges
33 from .putName import putName
34 from .distance2 import distance2
36 def insereFissureLongue_c (pipeFondFiss, disques, rayons, demiCercles, demiCerclesPeau, generatrices, \
37 VerticesEndPipeFiss, verticesEdgePeauFiss, \
38 groupFaceFissInPipe, groupEdgeFondFiss, groupsDemiCerclesPipe, groupGenerFiss, \
39 profondeur, rayonPipe):
40 """maillage pipe fond fissure"""
43 meshFondFiss = smesh.Mesh(pipeFondFiss)
44 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
45 algo3d = meshFondFiss.Prism()
46 putName(algo3d.GetSubMesh(), "pipe")
47 putName(algo3d, "algo3d_pipe")
48 putName(algo2d, "algo2d_pipe")
50 for i, face in enumerate(disques):
51 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face)
52 putName(algo2d.GetSubMesh(), "disque", i)
53 putName(algo2d, "algo2d_disque", i)
55 for i, edge in enumerate(rayons):
56 algo1d = meshFondFiss.Segment(geom=edge)
57 hypo1d = algo1d.NumberOfSegments(4)
58 putName(algo1d.GetSubMesh(), "rayon", i)
59 putName(algo1d, "algo1d_rayon", i)
60 putName(hypo1d, "hypo1d_rayon", i)
62 for i, edge in enumerate(demiCercles):
63 algo1d = meshFondFiss.Segment(geom=edge)
64 hypo1d = algo1d.NumberOfSegments(6)
65 putName(algo1d.GetSubMesh(), "demiCercle", i)
66 putName(algo1d, "algo1d_demiCercle", i)
67 putName(hypo1d, "hypo1d_demiCercle", i)
69 generSorted, minlg, maxlg = sortEdges(generatrices)
70 nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face
72 logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted))
73 for i, edge in enumerate(generSorted):
74 algo1d = meshFondFiss.Segment(geom=edge)
76 hypo1d = algo1d.NumberOfSegments(nbSegGenBout)
78 hypo1d = algo1d.NumberOfSegments(nbSegGenLong)
79 putName(algo1d.GetSubMesh(), "generatrice", i)
80 putName(algo1d, "algo1d_generatrice", i)
81 putName(hypo1d, "hypo1d_generatrice", i)
84 for i, face in enumerate(disques[:4]):
86 disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE))
87 _ = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
89 _ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE)
90 _ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE)
92 _ = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE)
93 _ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE)
94 _ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE)
96 groups_demiCercles = list()
97 groupnodes_demiCercles = list()
98 for i, group in enumerate(groupsDemiCerclesPipe):
100 groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE))
102 groupnodes_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.NODE))
103 group_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.EDGE)
104 groupnode_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.NODE)
106 is_done = meshFondFiss.Compute()
107 text = "meshFondFiss.Compute"
109 logging.info(text+" OK")
111 text = "Erreur au calcul du maillage.\n" + text
113 raise Exception(text)
115 grpNode0 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[0], "Node0")
116 grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1")
117 idNode0 = grpNode0.GetID(1)
118 idNode1 = grpNode1.GetID(1)
120 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0))
121 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1))
123 for vertex in verticesEdgePeauFiss:
124 coord = geompy.PointCoordinates(vertex)
125 if distance2(coord, coordsMesh[0]) < 0.1:
126 meshFondFiss.MoveNode(idNode0, coord[0], coord[1], coord[2])
127 if distance2(coord, coordsMesh[1]) < 0.1:
128 meshFondFiss.MoveNode(idNode1, coord[0], coord[1], coord[2])
130 for groupNodes in groupnodes_demiCercles:
131 for idNode in groupNodes.GetListOfID():
132 coordMesh = meshFondFiss.GetNodeXYZ(idNode)
133 vertex = geompy.MakeVertex(coordMesh[0], coordMesh[1], coordMesh[2])
137 for i, edge in enumerate(demiCerclesPeau):
138 discoord = geompy.MinDistanceComponents(vertex, edge)
139 if discoord[0] <minDist:
140 minDist = discoord[0]
141 minCoord = discoord[1:]
143 if imin >= 0 and minDist > 1.E-6:
144 logging.debug("node id moved : %s distance=%s", idNode, minDist)
145 meshFondFiss.MoveNode(idNode, coordMesh[0] + minCoord[0], coordMesh[1] + minCoord[1], coordMesh[2] + minCoord[2])
147 return meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout