Salome HOME
automatisation FronTrack - fichiers à télécharger
[modules/homard.git] / doc / files / tutorial_4.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2011-2016  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.2"
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(4)
42 gzip_gunzip(DATA_TUTORIAL, 4, -1)
43 # ==================================
44 #
45 import salome
46 salome.salome_init()
47 import HOMARD
48 #
49 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
50 homard.SetCurrentStudy(salome.myStudy)
51 #
52 #============================= Début des commandes =============================
53 #
54 # Frontières
55 # ==========
56 boun_4 = homard.CreateBoundaryCAO("PIQUAGE", os.path.join(DATA_TUTORIAL, "tutorial_4.xao"))
57 #
58 # Cas
59 # ===
60 le_cas = homard.CreateCase('Case_4', "PIQUAGE", os.path.join(DATA_TUTORIAL, "tutorial_4.00.med"))
61 le_cas.SetDirName(DIRCASE)
62 le_cas.AddBoundary( "PIQUAGE" )
63 #
64 # Hypotheses
65 # ==========
66 # Creation of the hypothesis hypo_4
67 l_hypothese = homard.CreateHypothesis('hypo_4')
68 l_hypothese.SetUnifRefinUnRef(1)
69 l_hypothese.AddGroup('T1_INT_I')
70 l_hypothese.AddGroup('T1_INT_O')
71 l_hypothese.AddGroup('T2_INT')
72 # Creation of the hypothesis hypo_4_bis
73 l_hypothese_bis = homard.CreateHypothesis('hypo_4_bis')
74 l_hypothese_bis.SetUnifRefinUnRef(1)
75 l_hypothese_bis.AddGroup('T1_EXT_I')
76 l_hypothese_bis.AddGroup('T1_EXT_O')
77 l_hypothese_bis.AddGroup('T2_EXT')
78 #
79 # Iterations
80 # ==========
81 # Iteration iter_4_1 : raffinement selon les faces internes
82 iter_4_1 = le_cas.NextIteration('iter_4_1')
83 iter_4_1.SetMeshName('PIQUAGE_1')
84 iter_4_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
85 iter_4_1.AssociateHypo('hypo_4')
86 erreur = iter_4_1.Compute(1, 2)
87 # Iteration iter_4_2 : raffinement selon les faces externes
88 iter_4_2 = iter_4_1.NextIteration('iter_4_2')
89 iter_4_2.SetMeshName('PIQUAGE_2')
90 iter_4_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
91 iter_4_2.AssociateHypo('hypo_4_bis')
92 erreur = iter_4_2.Compute(1, 2)
93 # Iteration iter_4_3 : second raffinement selon les faces externes
94 iter_4_3 = iter_4_2.NextIteration('iter_4_3')
95 iter_4_3.SetMeshName('PIQUAGE_3')
96 iter_4_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
97 iter_4_3.AssociateHypo('hypo_4_bis')
98 erreur = iter_4_3.Compute(1, 2)
99 #
100 #============================== Fin des commandes ==============================
101 #
102 # ==================================
103 gzip_gunzip(DATA_TUTORIAL, 4, 1)
104 # ==================================
105
106 if salome.sg.hasDesktop():
107   salome.sg.updateObjBrowser(True)