Salome HOME
simplification
[modules/smesh.git] / src / Tools / blocFissure / gmu / insereFissureLongue_d.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
24 from salome.smesh import smeshBuilder
25 import SMESH
26
27 from .geomsmesh import geompy
28 from .geomsmesh import smesh
29
30 from .putName import putName
31
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"""
37   logging.info('start')
38   logging.info("Maillage avec %s pour le cas n°%s", mailleur, nro_cas)
39
40   meshFacePeau = smesh.Mesh(facePeau)
41   putName(meshFacePeau, "facePeau", i_pref=nro_cas)
42
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 )
51   else:
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.SetQuadAllowed( 0 )
59   putName(algo2d.GetSubMesh(), "facePeau", i_pref=nro_cas)
60   putName(algo2d, "{}_2d_facePeau".format(mailleur), i_pref=nro_cas)
61   putName(hypo2d, "hypo2d_facePeau", i_pref=nro_cas)
62   #
63   lenEdgePeauFiss = geompy.BasicProperties(edgePeauFiss)[0]
64   frac = profondeur/lenEdgePeauFiss
65   nbSeg = nbSegGenLong +2*nbSegGenBout
66   ratio = (nbSegGenBout/float(profondeur)) / (nbSegGenLong/lenEdgePeauFiss)
67   logging.info("lenEdgePeauFiss %s, profondeur %s, nbSegGenLong %s, nbSegGenBout %s, frac %s, ratio %s", lenEdgePeauFiss, profondeur, nbSegGenLong, nbSegGenBout, frac, ratio)
68
69   algo1d = meshFacePeau.Segment(geom=edgePeauFiss)
70   hypo1d = algo1d.NumberOfSegments(nbSeg,list(),[  ])
71   hypo1d.SetDistrType( 2 )
72   hypo1d.SetConversionMode( 1 )
73   hypo1d.SetTableFunction( [ 0, ratio, frac, 1, (1.-frac), 1, 1, ratio ] )
74   putName(algo1d.GetSubMesh(), "edgePeauFiss", i_pref=nro_cas)
75   putName(algo1d, "algo1d_edgePeauFiss", i_pref=nro_cas)
76   putName(hypo1d, "hypo1d_edgePeauFiss", i_pref=nro_cas)
77   #
78   algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
79   hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
80   putName(algo1d.GetSubMesh(), "bordsLibres", i_pref=nro_cas)
81   putName(algo1d, "algo1d_bordsLibres", i_pref=nro_cas)
82   putName(hypo1d, "hypo1d_bordsLibres", i_pref=nro_cas)
83   #
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(algo1d, "algo1d_groupDemiCercles", i_aux, nro_cas)
89     putName(hypo1d, "hypo1d_groupDemiCercles", i_aux, nro_cas)
90
91   _ = meshFacePeau.GroupOnGeom(verticesOutCercles[0], "THOR", SMESH.NODE)
92   _ = meshFacePeau.GroupOnGeom(verticesOutCercles[1], "THEX", SMESH.NODE)
93
94   groupEdgesPeauFiss = meshFacePeau.GroupOnGeom(edgePeauFiss, "PeauFis", SMESH.EDGE)
95
96   is_done = meshFacePeau.Compute()
97   text = "meshFacePeau.Compute"
98   if is_done:
99     logging.info(text+" OK")
100   else:
101     text = "Erreur au calcul du maillage.\n" + text
102     logging.info(text)
103     raise Exception(text)
104
105   peauext_face = meshFacePeau.CreateEmptyGroup( SMESH.FACE, 'PEAUEXT' )
106   _ = peauext_face.AddFrom( meshFacePeau.GetMesh() )
107
108   return meshFacePeau, groupEdgesPeauFiss