Salome HOME
simplification
[modules/smesh.git] / src / Tools / blocFissure / gmu / calculePointsAxiauxPipe_a.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 selon le rayon de courbure du fond de fissure"""
21
22 import logging
23 import math
24
25 from .geomsmesh import geompy
26 from .geomsmesh import smesh
27
28 from .putName import putName
29
30 def calculePointsAxiauxPipe_a(facesDefaut, centreFondFiss, wireFondFiss, \
31                               lenSegPipe, \
32                               nro_cas=None):
33   """Maillage selon le rayon de courbure du fond de fissure"""
34
35   logging.info('start')
36
37   # Rayon de courbure maximal
38   disfond = list()
39   for filling in facesDefaut:
40     disfond.append(geompy.MinDistance(centreFondFiss, filling))
41   disfond.sort()
42
43   texte = "rcourb: {}, lenSegPipe: {}".format(disfond[0], lenSegPipe)
44   logging.info(texte)
45
46   # Maillage 1D
47   lgmin = lenSegPipe*0.25
48   lgmax = lenSegPipe*1.5
49   # la dĂ©flexion ets la distance maximale entre une arĂȘte du maillage et la courbe support
50   nbSegQuart = 5 # on veut 5 segments min sur un quart de cercle
51   alpha = math.pi/(4*nbSegQuart)
52   deflexion = disfond[0]*(1.0 -math.cos(alpha))
53   texte = "==> lgmin: {}, lgmax: {}, deflexion: {}".format(deflexion, lgmin, lgmax)
54   logging.info(texte)
55
56   meshFondFiss = smesh.Mesh(wireFondFiss)
57   putName(meshFondFiss, "wireFondFiss", i_pref=nro_cas)
58   algo1d = meshFondFiss.Segment()
59   hypo1d = algo1d.Adaptive(lgmin, lgmax, deflexion) # a ajuster selon la profondeur de la fissure
60   putName(algo1d.GetSubMesh(), "wireFondFiss", i_pref=nro_cas)
61   putName(algo1d, "algo1d_wireFondFiss", i_pref=nro_cas)
62   putName(hypo1d, "hypo1d_wireFondFiss", i_pref=nro_cas)
63
64   is_done = meshFondFiss.Compute()
65   text = "calculePointsAxiauxPipe meshFondFiss.Compute"
66   if is_done:
67     logging.info(text)
68   else:
69     text = "Erreur au calcul du maillage.\n" + text
70     logging.info(text)
71     raise Exception(text)
72
73   return meshFondFiss