Salome HOME
Merge branch 'V9_2_2_BR'
[modules/homard.git] / doc / files / tutorial_6.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2011-2019  CEA/DEN, EDF R&D
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 """
24 Exemple de couplage HOMARD-Salome
25 Copyright EDF 1996, 2011, 2018
26 """
27 __revision__ = "V4.5"
28 #
29 import os
30 import sys
31 #
32 # ==================================
33 PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
34 # Repertoire des donnees du tutorial
35 DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
36 DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
37 sys.path.append(DATA_TUTORIAL)
38 from tutorial_util import gzip_gunzip
39 from tutorial_util import creation_dircase
40 # ==================================
41 DIRCASE = creation_dircase(6)
42 gzip_gunzip(DATA_TUTORIAL, 4, -1)
43 gzip_gunzip(DATA_TUTORIAL, 6, -1)
44 # ==================================
45 #
46 import salome
47 salome.salome_init()
48 import HOMARD
49 #
50 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
51 homard.UpdateStudy()
52 #
53 #============================= Début des commandes =============================
54 #
55 # Frontières
56 # ==========
57 boun_6_1 = homard.CreateBoundaryDi('intersection', 'COURBES', os.path.join(DATA_TUTORIAL, "tutorial_6.fr.med"))
58 #
59 boun_6_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
60 #
61 boun_6_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
62 #
63 boun_6_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
64 #
65 boun_6_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
66 #
67 # Cas
68 # ===
69 le_cas = homard.CreateCase('Case_6', 'PIQUAGE', os.path.join(DATA_TUTORIAL, "tutorial_4.00.med"))
70 le_cas.SetDirName(DIRCASE)
71 le_cas.AddBoundary( 'intersection' )
72 le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
73 le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
74 le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
75 le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
76 le_cas.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
77 le_cas.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
78 #
79 #============================== Fin des commandes ==============================
80 #
81 # Hypotheses
82 # ==========
83 # Creation of the hypothesis hypo_6
84 l_hypothese = homard.CreateHypothesis('hypo_6')
85 l_hypothese.SetUnifRefinUnRef(1)
86 l_hypothese.AddGroup('IN1')
87 l_hypothese.AddGroup('IN2')
88 l_hypothese.AddGroup('T1_INT_I')
89 l_hypothese.AddGroup('T1_INT_O')
90 l_hypothese.AddGroup('T2_INT')
91 # Creation of the hypothesis hypo_6_bis
92 l_hypothese_bis = homard.CreateHypothesis('hypo_6_bis')
93 l_hypothese_bis.SetUnifRefinUnRef(1)
94 l_hypothese_bis.AddGroup('T1_EXT_I')
95 l_hypothese_bis.AddGroup('T1_EXT_O')
96 l_hypothese_bis.AddGroup('T2_EXT')
97 #
98 # Iterations
99 # ==========
100 # Iteration iter_6_1 : raffinement selon les faces internes
101 iter_6_1 = le_cas.NextIteration('iter_6_1')
102 iter_6_1.SetMeshName('PIQUAGE_6_1')
103 iter_6_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
104 iter_6_1.AssociateHypo('hypo_6')
105 erreur = iter_6_1.Compute(1, 2)
106 # Iteration iter_6_2 : raffinement selon les faces externes
107 iter_6_2 = iter_6_1.NextIteration('iter_6_2')
108 iter_6_2.SetMeshName('PIQUAGE_6_2')
109 iter_6_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
110 iter_6_2.AssociateHypo('hypo_6_bis')
111 erreur = iter_6_2.Compute(1, 2)
112 # Iteration iter_6_3 : second raffinement selon les faces externes
113 iter_6_3 = iter_6_2.NextIteration('iter_6_3')
114 iter_6_3.SetMeshName('PIQUAGE_6_3')
115 iter_6_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
116 iter_6_3.AssociateHypo('hypo_6_bis')
117 erreur = iter_6_3.Compute(1, 2)
118 #
119 # ==================================
120 gzip_gunzip(DATA_TUTORIAL, 4, 1)
121 gzip_gunzip(DATA_TUTORIAL, 6, 1)
122 # ==================================
123
124 if salome.sg.hasDesktop():
125   salome.sg.updateObjBrowser()