1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 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
20 """Maillage face de fissure pour identification zone de défaut"""
24 from salome.smesh import smeshBuilder
26 from .geomsmesh import smesh
28 def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \
30 """Maillage de l'objet géométrique 'facefiss'
32 . Avec l'algorithme MG_CADSurf :
33 -SetMaxSize = dimension max d'un élément (maxSize)
34 -SetSecondOrder = élément quadratique (Y=1, N=0)
35 -SetOptimize = élément régulier (Y=1, N=0)
36 -SetFineness = finesse du maillage
38 . Avec l'algorithme NETGEN_1D2D :
39 -SetMaxSize = dimension max d'un élément (maxSize)
40 -SetSecondOrder = élément quadratique (Y=1, N=0)
41 -SetOptimize = élément régulier (Y=1, N=0)
42 -SetFineness = finesse du maillage
43 [very_coarse, coarse, moderate, fine, very_fine, custom]
45 -SetMinSize = dimension min d'un élément (minSize)
46 -SetQuadAllowed = permission quadrangle dans maillage triangle
48 -On récupère les coordonnées de chaque noeud de la fissure qu'on stocke
49 dans une liste sous la forme : [X0, Y0, Z0, ..., Xn, Yn, Zn]
54 meshFissure = smesh.Mesh(facefiss)
55 text = "Maillage de '{}' avec {}".format(facefiss.GetName(),mailleur)
57 if ( mailleur == "MeshGems"):
58 algo2d = meshFissure.Triangle(algo=smeshBuilder.MG_CADSurf)
59 hypo2d = algo2d.Parameters()
60 hypo2d.SetPhySize( maxSize )
61 hypo2d.SetMinSize( maxSize/4. )
62 hypo2d.SetMaxSize( maxSize*2. )
63 hypo2d.SetChordalError( maxSize*0.25 )
64 hypo2d.SetVerbosity( 0 )
66 algo2d = meshFissure.Triangle(algo=smeshBuilder.NETGEN_1D2D)
67 hypo2d = algo2d.Parameters()
68 hypo2d.SetMaxSize( maxSize )
69 hypo2d.SetSecondOrder( 0 )
70 hypo2d.SetOptimize( 1 )
71 hypo2d.SetFineness( 2 )
72 hypo2d.SetMinSize( minSize )
73 hypo2d.SetQuadAllowed( 0 )
74 smesh.SetName(algo2d, "algo2d_zoneFiss")
75 smesh.SetName(hypo2d, "hypo1d_zoneFiss")
77 is_done = meshFissure.Compute()
78 text = "meshFissure.Compute"
80 logging.info(text+" OK")
82 text = "Erreur au calcul du maillage.\n" + text
86 coordsNoeudsFissure = list()
87 nodeIds = meshFissure.GetNodesId()
88 for indice in nodeIds:
89 coords = meshFissure.GetNodeXYZ(indice)
90 coordsNoeudsFissure.append(coords[0])
91 coordsNoeudsFissure.append(coords[1])
92 coordsNoeudsFissure.append(coords[2])
96 return coordsNoeudsFissure