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, \
41 """maillage pipe fond fissure"""
44 meshFondFiss = smesh.Mesh(pipeFondFiss)
45 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.QUADRANGLE)
46 algo3d = meshFondFiss.Prism()
47 putName(algo3d.GetSubMesh(), "pipe", i_pref=nro_cas)
48 putName(algo3d, "algo3d_pipe", i_pref=nro_cas)
49 putName(algo2d, "algo2d_pipe", i_pref=nro_cas)
51 for i_aux, face in enumerate(disques):
52 algo2d = meshFondFiss.Quadrangle(algo=smeshBuilder.RADIAL_QUAD,geom=face)
53 putName(algo2d.GetSubMesh(), "disque", i_aux, nro_cas)
54 putName(algo2d, "algo2d_disque", i_aux, nro_cas)
56 for i_aux, edge in enumerate(rayons):
57 algo1d = meshFondFiss.Segment(geom=edge)
58 hypo1d = algo1d.NumberOfSegments(4)
59 putName(algo1d.GetSubMesh(), "rayon", i_aux, nro_cas)
60 putName(algo1d, "algo1d_rayon", i_aux, nro_cas)
61 putName(hypo1d, "hypo1d_rayon", i_aux, nro_cas)
63 for i_aux, edge in enumerate(demiCercles):
64 algo1d = meshFondFiss.Segment(geom=edge)
65 hypo1d = algo1d.NumberOfSegments(6)
66 putName(algo1d.GetSubMesh(), "demiCercle", i_aux, nro_cas)
67 putName(algo1d, "algo1d_demiCercle", i_aux, nro_cas)
68 putName(hypo1d, "hypo1d_demiCercle", i_aux, nro_cas)
70 generSorted, minlg, maxlg = sortEdges(generatrices)
71 nbSegGenLong = int(math.sqrt(3.0)*maxlg/(profondeur - rayonPipe)) # on veut 2 triangles equilateraux dans la largeur de la face
73 logging.info("min %s, max %s, nombre de segments %s, nombre de generatrices %s", minlg, maxlg, nbSegGenLong, len(generSorted))
74 for i_aux, edge in enumerate(generSorted):
75 algo1d = meshFondFiss.Segment(geom=edge)
77 hypo1d = algo1d.NumberOfSegments(nbSegGenBout)
79 hypo1d = algo1d.NumberOfSegments(nbSegGenLong)
80 putName(algo1d.GetSubMesh(), "generatrice", i_aux, nro_cas)
81 putName(algo1d, "algo1d_generatrice", i_aux, nro_cas)
82 putName(hypo1d, "hypo1d_generatrice", i_aux, nro_cas)
85 for i_aux, face in enumerate(disques[:4]):
86 name = "disk{}".format(i_aux)
87 disks.append(meshFondFiss.GroupOnGeom(face, name, SMESH.FACE))
88 _ = meshFondFiss.GetMesh().UnionListOfGroups( disks, 'PEAUEXT' )
90 _ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[0], "PFOR", SMESH.NODE)
91 _ = meshFondFiss.GroupOnGeom(VerticesEndPipeFiss[1], "PFEX", SMESH.NODE)
93 _ = meshFondFiss.GroupOnGeom(groupFaceFissInPipe, "fisInPi", SMESH.FACE)
94 _ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "FONDFISS", SMESH.EDGE)
95 _ = meshFondFiss.GroupOnGeom(groupEdgeFondFiss, "nfondfis", SMESH.NODE)
97 groups_demiCercles = list()
98 groupnodes_demiCercles = list()
99 for i_aux, group in enumerate(groupsDemiCerclesPipe):
100 name = "Cercle{}".format(i_aux)
101 groups_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.EDGE))
102 name = "nCercle{}".format(i_aux)
103 groupnodes_demiCercles.append(meshFondFiss.GroupOnGeom(group, name, SMESH.NODE))
104 group_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.EDGE)
105 groupnode_generFiss = meshFondFiss.GroupOnGeom(groupGenerFiss, "GenFiss", SMESH.NODE)
107 is_done = meshFondFiss.Compute()
108 text = "meshFondFiss.Compute"
110 logging.info(text+" OK")
112 text = "Erreur au calcul du maillage.\n" + text
114 raise Exception(text)
116 grpNode0 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[0], "Node0")
117 grpNode1 = meshFondFiss.IntersectGroups(groupnode_generFiss, groupnodes_demiCercles[1], "Node1")
118 idNode0 = grpNode0.GetID(1)
119 idNode1 = grpNode1.GetID(1)
121 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode0))
122 coordsMesh.append(meshFondFiss.GetNodeXYZ(idNode1))
124 for vertex in verticesEdgePeauFiss:
125 coord = geompy.PointCoordinates(vertex)
126 if distance2(coord, coordsMesh[0]) < 0.1:
127 meshFondFiss.MoveNode(idNode0, coord[0], coord[1], coord[2])
128 if distance2(coord, coordsMesh[1]) < 0.1:
129 meshFondFiss.MoveNode(idNode1, coord[0], coord[1], coord[2])
131 for groupNodes in groupnodes_demiCercles:
132 for idNode in groupNodes.GetListOfID():
133 coordMesh = meshFondFiss.GetNodeXYZ(idNode)
134 vertex = geompy.MakeVertex(coordMesh[0], coordMesh[1], coordMesh[2])
138 for i_aux, edge in enumerate(demiCerclesPeau):
139 discoord = geompy.MinDistanceComponents(vertex, edge)
140 if discoord[0] <minDist:
141 minDist = discoord[0]
142 minCoord = discoord[1:]
144 if imin >= 0 and minDist > 1.E-6:
145 logging.debug("node id moved : %s distance=%s", idNode, minDist)
146 meshFondFiss.MoveNode(idNode, coordMesh[0] + minCoord[0], coordMesh[1] + minCoord[1], coordMesh[2] + minCoord[2])
148 return meshFondFiss, groups_demiCercles, group_generFiss, nbSegGenLong, nbSegGenBout