Salome HOME
67eb3517586c4d8325100fe961efcae2513ccc3f
[modules/smesh.git] / src / Tools / blocFissure / gmu / insereFissureLongue_b.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """Insertion de fissure longue - maillage face de peau"""
21
22 import logging
23 import salome
24 from .geomsmesh import geompy
25 from .geomsmesh import smesh
26 from salome.smesh import smeshBuilder
27 import SMESH
28
29 from .putName import putName
30
31 def insereFissureLongue_b (facePeau, edgePeauFiss, groupEdgesBordPeau, bordsLibres, \
32                            groupsDemiCerclesPeau, groups_demiCercles, verticesOutCercles, \
33                            nbSegGenLong, nbSegGenBout, profondeur, \
34                            mailleur="MeshGems"):
35   """maillage face de peau"""
36   logging.info('start')
37
38   meshFacePeau = smesh.Mesh(facePeau)
39   logging.info("Maillage avec %s", mailleur)
40   if ( mailleur == "MeshGems"):
41     algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
42     hypo2d = algo2d.Parameters()
43     hypo2d.SetPhySize( 1000 )
44     hypo2d.SetMinSize( 100 )
45     hypo2d.SetMaxSize( 3000. )
46     hypo2d.SetChordalError( 250. )
47     hypo2d.SetVerbosity( 0 )
48   else:
49     algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_2D)
50     hypo2d = algo2d.Parameters()
51     hypo2d.SetMaxSize( 1000 )
52     hypo2d.SetOptimize( 1 )
53     hypo2d.SetFineness( 2 )
54     hypo2d.SetMinSize( 2 )
55     hypo2d.SetQuadAllowed( 0 )
56   putName(algo2d.GetSubMesh(), "facePeau")
57   putName(algo2d, "algo2d_facePeau")
58   putName(hypo2d, "hypo2d_facePeau")
59   #
60   lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
61   frac = profondeur/lenEdgePeauFiss
62   nbSeg = nbSegGenLong +2*nbSegGenBout
63   ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
64   logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
65
66   algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
67   hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[  ])
68   hypo1d.SetDistrType( 2 )
69   hypo1d.SetConversionMode( 1 )
70   hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
71   putName(algo1d.GetSubMesh(), "edgePeauFiss")
72   putName(algo1d, "algo1d_edgePeauFiss")
73   putName(hypo1d, "hypo1d_edgePeauFiss")
74   #
75   algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
76   hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
77   putName(algo1d.GetSubMesh(), "bordsLibres")
78   putName(algo1d, "algo1d_bordsLibres")
79   putName(hypo1d, "hypo1d_bordsLibres")
80   #
81   for i in range(2):
82     algo1d = meshFacePeau.UseExisting1DElements(geom=groupsDemiCerclesPeau[i])
83     hypo1d = algo1d.SourceEdges([ groups_demiCercles[i] ],0,0)
84     putName(algo1d.GetSubMesh(), "DemiCercles", i)
85     putName(algo1d, "algo1d_groupDemiCercles", i)
86     putName(hypo1d, "hypo1d_groupDemiCercles", i)
87
88   _ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
89   _ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
90
91   groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
92
93   is_done = meshFacePeau.Compute()
94   text = "meshFacePeau.Compute"
95   if is_done:
96     logging.info(text+" OK")
97   else:
98     text = "Erreur au calcul du maillage.\n" + text
99     logging.info(text)
100     raise Exception(text)
101
102   peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
103   _ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
104
105   return meshFacePeau, groupEdgesPeauFiss