Salome HOME
Mise à niveau python
[modules/smesh.git] / src / Tools / blocFissure / gmu / insereFissureLongue_e.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 fissure"""
21
22 import logging
23 import math
24
25 import SMESH
26 from salome.smesh import smeshBuilder
27 import salome
28
29 from .geomsmesh import smesh
30
31 from .putName import putName
32
33 def insereFissureLongue_e (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
34                            profondeur, rayonPipe, \
35                            mailleur="MeshGems"):
36   """maillage face de fissure"""
37   logging.info('start')
38
39   meshFaceFiss = smesh.Mesh(faceFiss)
40   mesh_size = (profondeur - rayonPipe)/math.sqrt(3.0) # pour avoir deux couches de triangles equilateraux partout sur la fissure
41   logging.info("Maillage avec %s", mailleur)
42   if ( mailleur == "MeshGems"):
43     algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.MG_CADSurf)
44     hypo2d = algo2d.Parameters()
45     hypo2d.SetPhySize( mesh_size )
46     hypo2d.SetMinSize( mesh_size/10. )
47     hypo2d.SetMaxSize( mesh_size*3. )
48     hypo2d.SetChordalError( mesh_size*0.25 )
49     hypo2d.SetVerbosity( 0 )
50   else:
51     algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_2D)
52     hypo2d = algo2d.Parameters()
53     hypo2d.SetMaxSize( mesh_size )
54     hypo2d.SetOptimize( 1 )
55     hypo2d.SetFineness( 2 )
56     hypo2d.SetMinSize( 2 )
57     hypo2d.SetQuadAllowed( 0 )
58   putName(algo2d.GetSubMesh(), "faceFiss")
59   putName(algo2d, "algo2d_faceFiss")
60   putName(hypo2d, "hypo2d_faceFiss")
61   #
62   algo1d = meshFaceFiss.UseExisting1DElements(geom=edgePeauFiss)
63   hypo1d = algo1d.SourceEdges([ groupEdgesPeauFiss ],0,0)
64   putName(algo1d.GetSubMesh(), "edgeFissPeau")
65   putName(algo1d, "algo1d_edgeFissPeau")
66   putName(hypo1d, "hypo1d_edgeFissPeau")
67   #
68   algo1d = meshFaceFiss.UseExisting1DElements(geom=groupEdgesFaceFissPipe)
69   hypo1d = algo1d.SourceEdges([ group_generFiss ],0,0)
70   putName(algo1d.GetSubMesh(), "edgeFissPeau")
71   putName(algo1d, "algo1d_edgeFissPeau")
72   putName(hypo1d, "hypo1d_edgeFissPeau")
73
74   _ = meshFaceFiss.GroupOnGeom(faceFiss, "fisOutPi", SMESH.FACE)
75
76   is_done = meshFaceFiss.Compute()
77   text = "meshFaceFiss.Compute"
78   if is_done:
79     logging.info(text+" OK")
80   else:
81     text = "Erreur au calcul du maillage.\n" + text
82     logging.info(text)
83     raise Exception(text)
84
85   return meshFaceFiss