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 salome.smesh import smeshBuilder
27 from .geomsmesh import geompy
28 from .geomsmesh import smesh
30 from .putName import putName
32 def insereFissureLongue_d (facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
33 groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
34 nbSegGenLong, nbSegGenBout, profondeur, \
35 mailleur="MeshGems", nro_cas=None):
36 """maillage face de peau"""
38 logging.info("Maillage avec %s pour le cas n°%s", mailleur, nro_cas)
40 meshFacePeau = smesh.Mesh(facePeau)
41 putName(meshFacePeau, "facePeau", i_pref=nro_cas)
43 if ( mailleur == "MeshGems"):
44 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
45 hypo2d = algo2d.Parameters()
46 hypo2d.SetPhySize( 1000 )
47 hypo2d.SetMinSize( 100 )
48 hypo2d.SetMaxSize( 3000. )
49 hypo2d.SetChordalError( 250. )
50 hypo2d.SetVerbosity( 0 )
52 algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
53 hypo2d = algo2d.Parameters()
54 hypo2d.SetMaxSize( 1000 )
55 hypo2d.SetOptimize( 1 )
56 hypo2d.SetFineness( 2 )
57 hypo2d.SetMinSize( 2 )
58 hypo2d.SetChordalErrorEnabled (True)
59 hypo2d.SetChordalError( 250. )
60 hypo2d.SetUseSurfaceCurvature (True)
61 hypo2d.SetQuadAllowed( 0 )
62 putName(algo2d.GetSubMesh(), "facePeau", i_pref=nro_cas)
63 putName(hypo2d, "facePeau", i_pref=nro_cas)
65 lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
66 frac = profondeur/lenEdgePeauFiss
67 nbSeg = nbSegGenLong +2*nbSegGenBout
68 ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
69 logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
71 algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
72 hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[ ])
73 hypo1d.SetDistrType( 2 )
74 hypo1d.SetConversionMode( 1 )
75 hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
76 putName(algo1d.GetSubMesh(), "edgePeauFiss", i_pref=nro_cas)
77 putName(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(hypo1d, "bordsLibres", i_pref=nro_cas)
84 for i_aux in range(2):
85 algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i_aux])
86 hypo1d = algo1d.SourceEdges([ groups_demiCercles[i_aux] ],0,0)
87 putName(algo1d.GetSubMesh(), "DemiCercles", i_aux, nro_cas)
88 putName(hypo1d, "groupDemiCercles", i_aux, nro_cas)
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