1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 """Maillage sain sans la zone de defaut"""
25 from .geomsmesh import geompy
26 from .geomsmesh import smesh
29 def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGeomFissure, nomVolume, normal = None):
30 """Maillage sain sans la zone de defaut
34 logging.info('Concatenation')
36 maillageComplet = smesh.Concatenate([maillageSain.GetMesh(), blocComplet.GetMesh()], 1, 1, 1e-05,False)
38 groups = maillageComplet.GetGroups()
40 grp_nom = grp.GetName()
41 if ( grp_nom == "FACE1" ):
43 elif ( grp_nom == "nfondfis" ):
44 noeudsFondFissure = grp
45 elif ( grp_nom == "fisInPi" ):
47 elif ( grp_nom == "fisOutPi" ):
50 # --- TODO: fiabiliser l'orientation dans le cas general
52 normal = smesh.MakeDirStruct( 0, 0, 1 )
53 logging.debug('après normal = {}'.format(normal))
54 maillageComplet.Reorient2D( fisInPi, normal, [0,0,0])
55 logging.debug('après Reorient2D In')
56 maillageComplet.Reorient2D( fisOutPi, normal, [0,0,0])
59 if extrusionFaceFissure is not None:
60 subIds = geompy.SubShapeAllIDs(extrusionFaceFissure, geompy.ShapeType["SOLID"])
62 shapes = geompy.ExtractShapes(extrusionFaceFissure, geompy.ShapeType["SOLID"], False)
64 shapes = [extrusionFaceFissure]
66 # subIds = geompy.SubShapeAllIDs(faceGeomFissure, geompy.ShapeType["FACE"])
68 # shapes = geompy.ExtractShapes(faceGeomFissure, geompy.ShapeType["FACE"], False)
70 # shapes = [faceGeomFissure]
76 shapes = [None] # calcul uniquement avec les normales des faces mailles de la fissure
77 for i, aShape in enumerate(shapes):
78 texte = "Detection elements affectes par le dedoublement de la face n° {}".format(i)
80 affectedGroups = maillageComplet.AffectedElemGroupsInRegion([faceFissure], [noeudsFondFissure], aShape)
81 for grp in affectedGroups:
82 grp_nom = grp.GetName()
83 if ( grp_nom == "affectedEdges" ):
85 elif ( grp_nom == "affectedFaces" ):
87 elif ( grp_nom == "affectedVolumes" ):
89 #grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedEdges']
90 #affectedEdges = grps[0]
91 affectedEdges.SetName('affEd%d'%i)
92 grpEdges.append(affectedEdges)
93 #grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedFaces']
94 #affectedFaces = grps[0]
95 affectedFaces.SetName('affFa%d'%i)
96 grpFaces.append(affectedFaces)
97 #grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedVolumes']
98 #affectedVolumes = grps[0]
99 affectedVolumes.SetName('affVo%d'%i)
100 grpVolumes.append(affectedVolumes)
101 affectedEdges = maillageComplet.UnionListOfGroups(grpEdges, 'affEdges')
102 affectedFaces = maillageComplet.UnionListOfGroups(grpFaces, 'affFaces')
103 affectedVolumes = maillageComplet.UnionListOfGroups(grpVolumes, 'affVols')
104 for grp in affectedGroups:
105 texte = "Traitement du groupe '{}'".format(grp.GetName())
107 [ FACE2, _ ] = maillageComplet.DoubleNodeElemGroups([faceFissure], [noeudsFondFissure], affectedGroups, True, True)
108 FACE2.SetName( 'FACE2' )
110 # Groupe de toutes les mailles volumiques
111 GroupVol = maillageComplet.CreateEmptyGroup( SMESH.VOLUME, nomVolume )
112 _ = GroupVol.AddFrom( maillageComplet.GetMesh() )
114 return maillageComplet