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