Salome HOME
Copyright update 2020
[modules/smesh.git] / src / Tools / blocFissure / CasTests / cylindre.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
21 import os
22 from blocFissure import gmu
23 from blocFissure.gmu.geomsmesh import geompy, smesh
24
25 import math
26 import GEOM
27 import SALOMEDS
28 import SMESH
29 #import StdMeshers
30 #import GHS3DPlugin
31 #import NETGENPlugin
32 import logging
33
34 from blocFissure.gmu.fissureGenerique import fissureGenerique
35
36 from blocFissure.gmu.triedreBase import triedreBase
37 from blocFissure.gmu.genereMeshCalculZoneDefaut import genereMeshCalculZoneDefaut
38 from blocFissure.gmu.creeZoneDefautDansObjetSain import creeZoneDefautDansObjetSain
39 from blocFissure.gmu.construitFissureGenerale import construitFissureGenerale
40
41 O, OX, OY, OZ = triedreBase()
42
43 class cylindre(fissureGenerique):
44   """
45   problème de fissure plane sur cylindre, grand fond de fissure en arc de cercle
46   """
47
48   nomProbleme = "cylindre"
49
50   # ---------------------------------------------------------------------------
51   def genereMaillageSain(self, geometriesSaines, meshParams):
52     """
53     génère le maillage de l'objet sain, par chargement d'un fichier med
54     ici, les paramètres de géométrie et de maillage ne sont pas utiles
55     """
56     logging.info("genereMaillageSain %s", self.nomCas)
57
58     ([objetSain], status) = smesh.CreateMeshesFromMED(os.path.join(gmu.pathBloc, "materielCasTests/CylindreSain.med"))
59     smesh.SetName(objetSain.GetMesh(), 'objetSain')
60
61     return [objetSain, True] # True : maillage hexa
62
63   # ---------------------------------------------------------------------------
64   def setParamShapeFissure(self):
65     """
66     paramètres de la fissure pour méthode construitFissureGenerale
67     lgInfluence : distance autour de la shape de fissure a remailler (A ajuster selon le maillage)
68     rayonPipe   : le rayon du pile maillé en hexa autour du fond de fissure
69     """
70     logging.info("setParamShapeFissure %s", self.nomCas)
71     self.shapeFissureParams = dict(lgInfluence = 20,
72                                    rayonPipe   = 5)
73
74   # ---------------------------------------------------------------------------
75   def genereShapeFissure( self, geometriesSaines, geomParams, shapeFissureParams):
76     logging.info("genereShapeFissure %s", self.nomCas)
77
78     lgInfluence = shapeFissureParams['lgInfluence']
79
80     shellFiss = geompy.ImportFile(os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre2.brep"), "BREP")
81     fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"])
82     geompy.UnionIDs(fondFiss, [6])
83     geompy.addToStudy( shellFiss, 'shellFiss' )
84     geompy.addToStudyInFather( shellFiss, fondFiss, 'fondFiss' )
85
86
87     coordsNoeudsFissure = genereMeshCalculZoneDefaut(shellFiss, 5 ,15)
88
89     centre = None
90     return [shellFiss, centre, lgInfluence, coordsNoeudsFissure, fondFiss]
91
92   # ---------------------------------------------------------------------------
93   def setParamMaillageFissure(self):
94     self.maillageFissureParams = dict(nomRep           = '.',
95                                       nomFicSain       = self.nomCas,
96                                       nomFicFissure    = 'fissure_' + self.nomCas,
97                                       nbsegRad         = 5,
98                                       nbsegCercle      = 8,
99                                       areteFaceFissure = 20)
100
101   # ---------------------------------------------------------------------------
102   def genereZoneDefaut(self, geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams):
103     elementsDefaut = creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, shapeFissureParams, maillageFissureParams)
104     return elementsDefaut
105
106   # ---------------------------------------------------------------------------
107   def genereMaillageFissure(self, geometriesSaines, maillagesSains,
108                             shapesFissure, shapeFissureParams,
109                             maillageFissureParams, elementsDefaut, step):
110     maillageFissure = construitFissureGenerale(maillagesSains,
111                                                shapesFissure, shapeFissureParams,
112                                                maillageFissureParams, elementsDefaut, step)
113     return maillageFissure
114
115   # ---------------------------------------------------------------------------
116   def setReferencesMaillageFissure(self):
117     self.referencesMaillageFissure = dict(Entity_Quad_Pyramid    = 1270,
118                                           Entity_Quad_Triangle   = 1260,
119                                           Entity_Quad_Edge       = 758,
120                                           Entity_Quad_Penta      = 496,
121                                           Entity_Quad_Hexa       = 18814,
122                                           Entity_Node            = 113313,
123                                           Entity_Quad_Tetra      = 20469,
124                                           Entity_Quad_Quadrangle = 7280)
125