1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023 EDF
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 """construction de la fissure générale - maillage"""
26 from salome.smesh import smeshBuilder
29 from .geomsmesh import geompy
31 from .putName import putName
32 from .enleveDefaut import enleveDefaut
33 from .shapeSurFissure import shapeSurFissure
34 from .regroupeSainEtDefaut import RegroupeSainEtDefaut
35 from .triedreBase import triedreBase
37 # -----------------------------------------------------------------------------
39 def construitFissureGenerale_c(maillageSain, meshBoiteDefaut, \
40 zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges, \
42 maillageFissureParams, \
43 mailleur="MeshGems", nro_cas=None):
44 """construction de la fissure générale - maillage"""
46 logging.info("Usage du mailleur %s pour le cas n°%s", mailleur, nro_cas)
48 nomRep = maillageFissureParams['nomRep']
49 nomFicSain = maillageFissureParams['nomFicSain']
50 nomFicFissure = maillageFissureParams['nomFicFissure']
52 O, _, _, _ = triedreBase()
54 # pour aider l'algo hexa-tetra à ne pas mettre de pyramides à l'exterieur des volumes repliés sur eux-mêmes
55 # on désigne les faces de peau en quadrangles par le groupe "skinFaces"
56 group_faceFissOutPipe = None
57 group_faceFissInPipe = None
58 groups = meshBoiteDefaut.GetGroups()
60 if grp.GetType() == SMESH.FACE:
61 if grp.GetName() == "fisOutPi":
62 group_faceFissOutPipe = grp
63 elif grp.GetName() == "fisInPi":
64 group_faceFissInPipe = grp
66 # le maillage NETGEN ne passe pas toujours ==> on force l'usage de MG_Tetra
68 logging.info("Maillage avec %s", mailleur)
69 if ( mailleur == "MeshGems"):
70 algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.MG_Tetra)
72 algo3d = meshBoiteDefaut.Tetrahedron(algo=smeshBuilder.NETGEN)
73 hypo3d = algo3d.MaxElementVolume(1000.0)
74 hypo3d.SetVerboseLevel( 0 )
75 hypo3d.SetStandardOutputLog( 0 )
76 hypo3d.SetRemoveLogOnSuccess( 1 )
77 putName(algo3d.GetSubMesh(), "boiteDefaut", i_pref=nro_cas)
79 is_done = meshBoiteDefaut.Compute()
80 text = "meshBoiteDefaut.Compute"
82 logging.info(text+" OK")
84 text = "Erreur au calcul du maillage.\n" + text
88 _ = meshBoiteDefaut.GetMesh().UnionListOfGroups( [ group_faceFissOutPipe, group_faceFissInPipe ], \
90 maillageSain = enleveDefaut(maillageSain, zoneDefaut, zoneDefaut_skin,
91 zoneDefaut_internalFaces, zoneDefaut_internalEdges)
92 putName(maillageSain, nomFicSain+"_coupe", i_pref=nro_cas)
93 _, normfiss = shapeSurFissure(facesPortFissure)
94 maillageComplet = RegroupeSainEtDefaut(maillageSain, meshBoiteDefaut, \
95 None, None, 'COMPLET', normfiss)
96 putName(maillageComplet, nomFicFissure)
98 logging.info("conversion quadratique")
99 maillageComplet.ConvertToQuadratic( 1 )
101 logging.info("groupes")
102 groups = maillageComplet.GetGroups()
103 grps = [ grp for grp in groups if grp.GetName() == 'FONDFISS']
104 _ = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FONDFISS' )
106 logging.info("réorientation face de fissure FACE1")
107 grps = [ grp for grp in groups if grp.GetName() == 'FACE1']
108 _ = maillageComplet.Reorient2D( grps[0], normfiss, grps[0].GetID(1))
110 logging.info("réorientation face de fissure FACE2")
111 plansim = geompy.MakePlane(O, normfiss, 10000)
112 fissnorm = geompy.MakeMirrorByPlane(normfiss, plansim)
113 grps = [ grp for grp in groups if grp.GetName() == 'FACE2']
114 _ = maillageComplet.Reorient2D( grps[0], fissnorm, grps[0].GetID(1))
115 _ = maillageComplet.GetMesh().CreateDimGroup( grps, SMESH.NODE, 'FACE2' )
117 logging.info("export maillage fini")
118 fichierMaillageFissure = os.path.join (nomRep , '{}.med'.format(nomFicFissure))
119 maillageComplet.ExportMED(fichierMaillageFissure)
120 logging.info("fichier maillage fissure %s", fichierMaillageFissure)
122 return maillageComplet