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 from .putName import putName
30 def genereMeshCalculZoneDefaut(facefiss, minSize, maxSize, \
31 mailleur="MeshGems", nro_cas=None):
32 """Maillage de l'objet géométrique 'facefiss'
34 . Avec l'algorithme MG_CADSurf :
35 -SetMaxSize = dimension max d'un élément (maxSize)
36 -SetSecondOrder = élément quadratique (Y=1, N=0)
37 -SetOptimize = élément régulier (Y=1, N=0)
38 -SetFineness = finesse du maillage
40 . Avec l'algorithme NETGEN_1D2D :
41 -SetMaxSize = dimension max d'un élément (maxSize)
42 -SetSecondOrder = élément quadratique (Y=1, N=0)
43 -SetOptimize = élément régulier (Y=1, N=0)
44 -SetFineness = finesse du maillage
45 [very_coarse, coarse, moderate, fine, very_fine, custom]
47 -SetMinSize = dimension min d'un élément (minSize)
48 -SetQuadAllowed = permission quadrangle dans maillage triangle
50 -On récupère les coordonnées de chaque noeud de la fissure qu'on stocke
51 dans une liste sous la forme : [X0, Y0, Z0, ..., Xn, Yn, Zn]
55 logging.info("Maillage avec %s pour le cas n°%s", mailleur, nro_cas)
57 meshFissure = smesh.Mesh(facefiss)
58 putName(meshFissure, "facefiss", i_pref=nro_cas)
60 text = "Maillage de '{}'".format(facefiss.GetName())
62 if ( mailleur == "MeshGems"):
63 algo2d = meshFissure.Triangle(algo=smeshBuilder.MG_CADSurf)
64 hypo2d = algo2d.Parameters()
65 hypo2d.SetPhySize( maxSize )
66 hypo2d.SetMinSize( maxSize/4. )
67 hypo2d.SetMaxSize( maxSize*2. )
68 hypo2d.SetChordalError( maxSize*0.25 )
69 hypo2d.SetVerbosity( 0 )
71 algo2d = meshFissure.Triangle(algo=smeshBuilder.NETGEN_1D2D)
72 hypo2d = algo2d.Parameters()
73 hypo2d.SetMaxSize( maxSize )
74 hypo2d.SetSecondOrder( 0 )
75 hypo2d.SetOptimize( 1 )
76 hypo2d.SetFineness( 2 )
77 hypo2d.SetMinSize( minSize )
78 hypo2d.SetQuadAllowed( 0 )
79 putName(algo2d, "{}_2d_zoneFiss".format(mailleur), i_pref=nro_cas)
80 putName(hypo2d, "hypo1d_zoneFiss", i_pref=nro_cas)
82 is_done = meshFissure.Compute()
83 text = "meshFissure.Compute"
85 logging.info(text+" OK")
87 text = "Erreur au calcul du maillage.\n" + text
91 coordsNoeudsFissure = list()
92 nodeIds = meshFissure.GetNodesId()
93 for indice in nodeIds:
94 coords = meshFissure.GetNodeXYZ(indice)
95 coordsNoeudsFissure.append(coords[0])
96 coordsNoeudsFissure.append(coords[1])
97 coordsNoeudsFissure.append(coords[2])
101 return coordsNoeudsFissure