Salome HOME
Copyright update 2021
[modules/smesh.git] / src / Tools / blocFissure / gmu / regroupeSainEtDefaut.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  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
21 import logging
22 from .geomsmesh import smesh
23 import SMESH
24 from .geomsmesh import geompy
25
26 # -----------------------------------------------------------------------------
27 # --- maillage complet et fissure
28
29 def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGeomFissure, nomVolume, normal = None):
30   """
31   Maillage sain sans la zone de defaut
32   TODO: a completer
33   """
34   logging.info('Concatenation')
35
36   maillageComplet = smesh.Concatenate([maillageSain.GetMesh(), blocComplet.GetMesh()], 1, 1, 1e-05,False)
37
38   groups = maillageComplet.GetGroups()
39   grps = [ grp for grp in groups if grp.GetName() == 'FACE1']
40   faceFissure = grps[0]
41   grps = [ grp for grp in groups if grp.GetName() == 'nfondfis']
42   noeudsFondFissure = grps[0]
43   grps = [ grp for grp in groups if grp.GetName() == 'fisInPi']
44   fisInPi = grps[0]
45   grps = [ grp for grp in groups if grp.GetName() == 'fisOutPi']
46   fisOutPi = grps[0]
47
48   # --- TODO: fiabiliser l'orientation dans le cas general
49   if normal is None:
50     normal  = smesh.MakeDirStruct( 0, 0, 1 )
51   maillageComplet.Reorient2D( fisInPi,  normal, [0,0,0])
52   maillageComplet.Reorient2D( fisOutPi, normal, [0,0,0])
53     
54   shapes = []
55   if extrusionFaceFissure is not None:
56     subIds = geompy.SubShapeAllIDs(extrusionFaceFissure, geompy.ShapeType["SOLID"])
57     if len(subIds) > 1:
58       shapes = geompy.ExtractShapes(extrusionFaceFissure, geompy.ShapeType["SOLID"], False)
59     else:
60       shapes = [extrusionFaceFissure]
61 #  else:
62 #    subIds = geompy.SubShapeAllIDs(faceGeomFissure, geompy.ShapeType["FACE"])
63 #    if len(subIds) > 1:
64 #      shapes = geompy.ExtractShapes(faceGeomFissure, geompy.ShapeType["FACE"], False)
65 #    else:
66 #      shapes = [faceGeomFissure]
67     
68   grpEdges = []
69   grpFaces = []
70   grpVolumes = []
71   if len(shapes) == 0:
72     shapes = [None] # calcul uniquement avec les normales des faces mailles de la fissure
73   for i, aShape in enumerate(shapes):
74     logging.info('Detection elements affectes par le dedoublement de la face %d'%i)
75     affectedGroups = maillageComplet.AffectedElemGroupsInRegion([faceFissure], [noeudsFondFissure], aShape)
76     grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedEdges']
77     affectedEdges = grps[0]
78     affectedEdges.SetName('affEd%d'%i)
79     grpEdges.append(affectedEdges)
80     grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedFaces']
81     affectedFaces = grps[0]
82     affectedFaces.SetName('affFa%d'%i)
83     grpFaces.append(affectedFaces)
84     grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedVolumes']
85     affectedVolumes = grps[0]
86     affectedVolumes.SetName('affVo%d'%i)
87     grpVolumes.append(affectedVolumes)
88   logging.info("union des groupes d'edges") 
89   affectedEdges = maillageComplet.UnionListOfGroups(grpEdges, 'affEdges')
90   logging.info("union des groupes de faces") 
91   affectedFaces = maillageComplet.UnionListOfGroups(grpFaces, 'affFaces')
92   logging.info("union des groupes de volumes") 
93   affectedVolumes = maillageComplet.UnionListOfGroups(grpVolumes, 'affVols')
94   for grp in affectedGroups:
95     logging.debug("nom groupe %s",grp.GetName())
96   [ FACE2, FACE2_nodes ] = maillageComplet.DoubleNodeElemGroups([faceFissure], [noeudsFondFissure], affectedGroups, True, True)
97   FACE2.SetName( 'FACE2' )
98
99   GroupVol = maillageComplet.CreateEmptyGroup( SMESH.VOLUME, nomVolume )
100   nbAdd = GroupVol.AddFrom( maillageComplet.GetMesh() )
101
102   return maillageComplet
103