Salome HOME
Merge branch 'gni/evolution'
[modules/smesh.git] / src / Tools / blocFissure / gmu / mailleFacesFissure.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
23 from .geomsmesh import geompy
24 from .geomsmesh import smesh
25 from salome.smesh import smeshBuilder
26 import SMESH
27
28 from .putName import putName
29
30 def mailleFacesFissure(faceFissureExterne, \
31                        edgesPipeFissureExterneC, edgesPeauFissureExterneC, \
32                        meshPipeGroups, areteFaceFissure, rayonPipe, nbsegRad, \
33                        mailleur="MeshGems"):
34   """maillage faces de fissure"""
35   logging.info('start')
36
37   meshFaceFiss = smesh.Mesh(faceFissureExterne)
38   logging.info("Maillage avec %s", mailleur)
39   if ( mailleur == "MeshGems"):
40     algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.MG_CADSurf)
41     hypo2d = algo2d.Parameters()
42     hypo2d.SetPhySize( areteFaceFissure )
43     hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
44     hypo2d.SetMaxSize( areteFaceFissure*3. )
45     hypo2d.SetChordalError( areteFaceFissure*0.25 )
46     hypo2d.SetVerbosity( 0 )
47   else:
48     algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_1D2D)
49     hypo2d = algo2d.Parameters()
50     hypo2d.SetMaxSize( areteFaceFissure )
51     hypo2d.SetSecondOrder( 0 )
52     hypo2d.SetOptimize( 1 )
53     hypo2d.SetFineness( 2 )
54     hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
55     hypo2d.SetQuadAllowed( 0 )
56   putName(algo2d.GetSubMesh(), "faceFiss")
57   putName(algo2d, "algo2d_faceFiss")
58   putName(hypo2d, "hypo2d_faceFiss")
59
60   texte = "Récupération des arêtes de '{}'".format(edgesPipeFissureExterneC.GetName())
61   logging.info(texte)
62   algo1d = meshFaceFiss.UseExisting1DElements(geom=edgesPipeFissureExterneC)
63   hypo1d = algo1d.SourceEdges([ meshPipeGroups['edgeFaceFissGroup'] ],0,0)
64   putName(algo1d.GetSubMesh(), "edgeFissPeau")
65   putName(algo1d, "algo1d_edgeFissPeau")
66   putName(hypo1d, "hypo1d_edgeFissPeau")
67
68   grpFaceFissureExterne = meshFaceFiss.GroupOnGeom(faceFissureExterne, "fisOutPi", SMESH.FACE)
69   grpEdgesPeauFissureExterne = meshFaceFiss.GroupOnGeom(edgesPeauFissureExterneC,'edgesPeauFissureExterne',SMESH.EDGE)
70   grpEdgesPipeFissureExterne = meshFaceFiss.GroupOnGeom(edgesPipeFissureExterneC,'edgesPipeFissureExterne',SMESH.EDGE)
71
72   is_done = meshFaceFiss.Compute()
73   text = "meshFaceFiss.Compute"
74   if is_done:
75     logging.info(text+" OK")
76   else:
77     text = "Erreur au calcul du maillage.\n" + text
78     logging.info(text)
79     raise Exception(text)
80
81   return (meshFaceFiss, grpFaceFissureExterne, grpEdgesPeauFissureExterne, grpEdgesPipeFissureExterne)