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, \
36 mailleur="MeshGems", nro_cas=-1):
37 """maillage face de peau"""
39 logging.info("Maillage avec %s pour le cas n°%d", mailleur, nro_cas)
41 meshFacePeau = smesh.Mesh(facePeau)
42 putName(meshFacePeau, "facePeau", i_pref=nro_cas)
44 if ( mailleur == "MeshGems"):
45 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
46 hypo2d = algo2d.Parameters()
47 hypo2d.SetPhySize( 1000 )
48 hypo2d.SetMinSize( 100 )
49 hypo2d.SetMaxSize( 3000. )
50 hypo2d.SetChordalError( 250. )
51 hypo2d.SetVerbosity( 0 )
53 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
54 hypo2d = algo2d.Parameters()
55 hypo2d.SetMaxSize( 1000 )
56 hypo2d.SetOptimize( 1 )
57 hypo2d.SetFineness( 2 )
58 hypo2d.SetMinSize( 2 )
59 hypo2d.SetQuadAllowed( 0 )
60 putName(algo2d.GetSubMesh(), "facePeau", i_pref=nro_cas)
61 putName(algo2d, "algo2d_facePeau", i_pref=nro_cas)
62 putName(hypo2d, "hypo2d_facePeau", i_pref=nro_cas)
64 lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
65 frac = profondeur/lenEdgePeauFiss
66 nbSeg = nbSegGenLong +2*nbSegGenBout
67 ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
68 logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
70 algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
71 hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ])
72 hypo1d.SetDistrType( 2 )
73 hypo1d.SetConversionMode( 1 )
74 hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
75 putName(algo1d.GetSubMesh(), "edgePeauFiss", i_pref=nro_cas)
76 putName(algo1d, "algo1d_edgePeauFiss", i_pref=nro_cas)
77 putName(hypo1d, "hypo1d_edgePeauFiss", i_pref=nro_cas)
79 algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
80 hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
81 putName(algo1d.GetSubMesh(), "bordsLibres", i_pref=nro_cas)
82 putName(algo1d, "algo1d_bordsLibres", i_pref=nro_cas)
83 putName(hypo1d, "hypo1d_bordsLibres", i_pref=nro_cas)
85 for i_aux in range(2):
86 algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i_aux])
87 hypo1d = algo1d.SourceEdges([ groups_demiCercles[i_aux] ],0,0)
88 putName(algo1d.GetSubMesh(), "DemiCercles", i_aux, nro_cas)
89 putName(algo1d, "algo1d_groupDemiCercles", i_aux, nro_cas)
90 putName(hypo1d, "hypo1d_groupDemiCercles", i_aux, nro_cas)
92 _ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
93 _ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
95 groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
97 is_done = meshFacePeau.Compute()
98 text = "meshFacePeau.Compute"
100 logging.info(text+" OK")
102 text = "Erreur au calcul du maillage.\n" + text
104 raise Exception(text)
106 peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
107 _ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
109 return meshFacePeau, groupEdgesPeauFiss