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 face de peau"""
24 from .geomsmesh import geompy
25 from .geomsmesh import smesh
26 from salome.smesh import smeshBuilder
29 from .putName import putName
31 def insereFissureLongue_b (facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
32 groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
33 nbSegGenLong, nbSegGenBout, profondeur):
34 """maillage face de peau"""
37 meshFacePeau = smesh.Mesh(facePeau)
38 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
39 hypo2d = algo2d.Parameters()
40 hypo2d.SetMaxSize( 1000 )
41 hypo2d.SetOptimize( 1 )
42 hypo2d.SetFineness( 2 )
43 hypo2d.SetMinSize( 2 )
44 hypo2d.SetQuadAllowed( 0 )
45 putName(algo2d.GetSubMesh(), "facePeau")
46 putName(algo2d, "algo2d_facePeau")
47 putName(hypo2d, "hypo2d_facePeau")
49 lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
50 frac = profondeur/lenEdgePeauFiss
51 nbSeg = nbSegGenLong +2*nbSegGenBout
52 ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
53 logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
55 algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
56 hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ])
57 hypo1d.SetDistrType( 2 )
58 hypo1d.SetConversionMode( 1 )
59 hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
60 putName(algo1d.GetSubMesh(), "edgePeauFiss")
61 putName(algo1d, "algo1d_edgePeauFiss")
62 putName(hypo1d, "hypo1d_edgePeauFiss")
64 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
65 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
66 putName(algo1d.GetSubMesh(), "bordsLibres")
67 putName(algo1d, "algo1d_bordsLibres")
68 putName(hypo1d, "hypo1d_bordsLibres")
71 algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i])
72 hypo1d = algo1d.SourceEdges([ groups_demiCercles[i] ],0,0)
73 putName(algo1d.GetSubMesh(), "DemiCercles", i)
74 putName(algo1d, "algo1d_groupDemiCercles", i)
75 putName(hypo1d, "hypo1d_groupDemiCercles", i)
77 _ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
78 _ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
80 groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
82 is_done = meshFacePeau.Compute()
83 text = "meshFacePeau.Compute"
85 logging.info(text+" OK")
87 text = "Erreur au calcul du maillage.\n" + text
91 peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
92 _ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
94 return meshFacePeau, groupEdgesPeauFiss