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"""
25 from salome.smesh import smeshBuilder
28 from .geomsmesh import geompy
29 from .geomsmesh import smesh
31 from .putName import putName
33 def insereFissureLongue_d (facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
34 groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
35 nbSegGenLong, nbSegGenBout, profondeur, \
37 """maillage face de peau"""
40 meshFacePeau = smesh.Mesh(facePeau)
41 logging.info("Maillage avec %s", mailleur)
42 if ( mailleur == "MeshGems"):
43 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
44 hypo2d = algo2d.Parameters()
45 hypo2d.SetPhySize( 1000 )
46 hypo2d.SetMinSize( 100 )
47 hypo2d.SetMaxSize( 3000. )
48 hypo2d.SetChordalError( 250. )
49 hypo2d.SetVerbosity( 0 )
51 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
52 hypo2d = algo2d.Parameters()
53 hypo2d.SetMaxSize( 1000 )
54 hypo2d.SetOptimize( 1 )
55 hypo2d.SetFineness( 2 )
56 hypo2d.SetMinSize( 2 )
57 hypo2d.SetQuadAllowed( 0 )
58 putName(algo2d.GetSubMesh(), "facePeau")
59 putName(algo2d, "algo2d_facePeau")
60 putName(hypo2d, "hypo2d_facePeau")
62 lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
63 frac = profondeur/lenEdgePeauFiss
64 nbSeg = nbSegGenLong +2*nbSegGenBout
65 ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
66 logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
68 algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
69 hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ])
70 hypo1d.SetDistrType( 2 )
71 hypo1d.SetConversionMode( 1 )
72 hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
73 putName(algo1d.GetSubMesh(), "edgePeauFiss")
74 putName(algo1d, "algo1d_edgePeauFiss")
75 putName(hypo1d, "hypo1d_edgePeauFiss")
77 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
78 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
79 putName(algo1d.GetSubMesh(), "bordsLibres")
80 putName(algo1d, "algo1d_bordsLibres")
81 putName(hypo1d, "hypo1d_bordsLibres")
84 algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i])
85 hypo1d = algo1d.SourceEdges([ groups_demiCercles[i] ],0,0)
86 putName(algo1d.GetSubMesh(), "DemiCercles", i)
87 putName(algo1d, "algo1d_groupDemiCercles", i)
88 putName(hypo1d, "hypo1d_groupDemiCercles", i)
90 _ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
91 _ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
93 groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
95 is_done = meshFacePeau.Compute()
96 text = "meshFacePeau.Compute"
98 logging.info(text+" OK")
100 text = "Erreur au calcul du maillage.\n" + text
102 raise Exception(text)
104 peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
105 _ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
107 return meshFacePeau, groupEdgesPeauFiss