Salome HOME
Merge branch 'gni/evolution'
[modules/smesh.git] / src / Tools / blocFissure / gmu / insereFissureLongue_f.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 meshBoiteDefaut"""
21
22 import logging
23
24 import salome
25 from salome.smesh import smeshBuilder
26 import SMESH
27
28 from .geomsmesh import smesh
29
30 from .putName import putName
31
32 def insereFissureLongue_f (internalBoundary, meshFondFiss, meshFacePeau, meshFaceFiss, \
33                            mailleur="MeshGems", nro_cas=None):
34   """maillage meshBoiteDefaut"""
35   logging.info('start')
36   logging.info("Usage du mailleur %s pour le cas n°%s", mailleur, nro_cas)
37
38   meshBoiteDefaut = smesh.Concatenate( [internalBoundary.GetMesh(), \
39                                         meshFondFiss.GetMesh(), \
40                                         meshFacePeau.GetMesh(), \
41                                         meshFaceFiss.GetMesh()], \
42                                         1, 1, 1e-05,False )
43   # pour aider l'algo hexa-tetra a ne pas mettre de pyramides a l'exterieur des volumes replies sur eux-memes
44   # on designe les faces de peau en quadrangles par le groupe "skinFaces"
45   group_faceFissOutPipe = None
46   group_faceFissInPipe = None
47   groups = meshBoiteDefaut.GetGroups()
48   for grp in groups:
49     if grp.GetType() == SMESH.FACE:
50       #if "internalBoundary" in grp.GetName():
51       #  grp.SetName("skinFaces")
52       if grp.GetName() == "fisOutPi":
53         group_faceFissOutPipe = grp
54       elif grp.GetName() == "fisInPi":
55         group_faceFissInPipe = grp
56
57   # le maillage NETGEN ne passe pas toujours ==> on force l'usage de MG_Tetra
58   mailleur = "MeshGems"
59   logging.info("Maillage avec %s", mailleur)
60   if ( mailleur == "MeshGems"):
61     algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.MG_Tetra)
62   else:
63     algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN)
64     hypo3d = algo3d.MaxElementVolume(1000.0)
65     hypo3d.SetVerboseLevel( 0 )
66     hypo3d.SetStandardOutputLog( 0 )
67     hypo3d.SetRemoveLogOnSuccess( 1 )
68   putName(algo3d.GetSubMesh(), "boiteDefaut", i_pref=nro_cas)
69   putName(algo3d, "algo3d_boiteDefaut", i_pref=nro_cas)
70   putName(meshBoiteDefaut, "boiteDefaut", i_pref=nro_cas)
71
72   is_done = meshBoiteDefaut.Compute()
73   text = "meshBoiteDefaut.Compute"
74   if is_done:
75     logging.info(text+" OK")
76   else:
77     text = "Erreur au calcul du maillage.\n" + text
78     logging.info(text)
79     raise Exception(text)
80
81   return meshBoiteDefaut, group_faceFissInPipe, group_faceFissOutPipe