Salome HOME
Merge branch 'master' into gni/evolution
[modules/smesh.git] / src / Tools / blocFissure / gmu / insereFissureLongue_c.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  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 """Insertion de fissure longue - maillage face de fissure"""
21
22 import logging
23 import salome
24 from .geomsmesh import smesh
25 from salome.smesh import smeshBuilder
26 import SMESH
27
28 from .putName import putName
29
30 import math
31
32 def insereFissureLongue_c (faceFiss, edgePeauFiss, groupEdgesPeauFiss, group_generFiss, groupEdgesFaceFissPipe, \
33                            profondeur, rayonPipe):
34   """maillage face de fissure"""
35   logging.info('start')
36
37   meshFaceFiss = smesh.Mesh(faceFiss)
38   algo2d = meshFaceFiss.Triangle(algo=smeshBuilder.NETGEN_2D)
39   hypo2d = algo2d.Parameters()
40   hypo2d.SetMaxSize( (profondeur - rayonPipe)/math.sqrt(3.0) ) # pour avoir deux couches de triangles equilateraux partout sur la fissure
41   hypo2d.SetOptimize( 1 )
42   hypo2d.SetFineness( 2 )
43   hypo2d.SetMinSize( 2 )
44   hypo2d.SetQuadAllowed( 0 )
45   putName(algo2d.GetSubMesh(), "faceFiss")
46   putName(algo2d, "algo2d_faceFiss")
47   putName(hypo2d, "hypo2d_faceFiss")
48   #
49   algo1d = meshFaceFiss.UseExisting1DElements(geom=edgePeauFiss)
50   hypo1d = algo1d.SourceEdges([ groupEdgesPeauFiss ],0,0)
51   putName(algo1d.GetSubMesh(), "edgeFissPeau")
52   putName(algo1d, "algo1d_edgeFissPeau")
53   putName(hypo1d, "hypo1d_edgeFissPeau")
54   #
55   algo1d = meshFaceFiss.UseExisting1DElements(geom=groupEdgesFaceFissPipe)
56   hypo1d = algo1d.SourceEdges([ group_generFiss ],0,0)
57   putName(algo1d.GetSubMesh(), "edgeFissPeau")
58   putName(algo1d, "algo1d_edgeFissPeau")
59   putName(hypo1d, "hypo1d_edgeFissPeau")
60
61   _ = meshFaceFiss.GroupOnGeom(faceFiss, "fisOutPi", SMESH.FACE)
62
63   is_done = meshFaceFiss.Compute()
64   text = "meshFaceFiss.Compute"
65   if is_done:
66     logging.info(text+" OK")
67   else:
68     text = "Erreur au calcul du maillage.\n" + text
69     logging.info(text)
70     raise Exception(text)
71
72   return meshFaceFiss