Salome HOME
11bd321092729458fdca68eb9b3c1c2fd7233ac6
[modules/homard.git] / doc / files / tutorial_1.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2011-2016  CEA/DEN, EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21 """
22 Exemple de couplage HOMARD-Salome
23 Copyright EDF 1996, 2010, 2018
24 """
25 __revision__ = "V3.2"
26 #
27 import os
28 import sys
29 #
30 # ==================================
31 PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
32 # Repertoire des donnees du tutorial
33 DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
34 DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
35 sys.path.append(DATA_TUTORIAL)
36 from tutorial_util import gzip_gunzip
37 from tutorial_util import creation_dircase
38 # ==================================
39 DIRCASE = creation_dircase(1)
40 gzip_gunzip(DATA_TUTORIAL, 1, -1)
41 # ==================================
42 #
43 import salome
44 salome.salome_init()
45 import HOMARD
46 #
47 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
48 homard.UpdateStudy()
49 #
50 #============================= Début des commandes =============================
51 #
52 # Hypotheses
53 # ==========
54 l_hypothese = homard.CreateHypothesis('hypo_1')
55 l_hypothese.SetUnifRefinUnRef(1)
56 #
57 # Cas
58 # ===
59 le_cas = homard.CreateCase('Case_1', 'MAILL', os.path.join(DATA_TUTORIAL, "tutorial_1.00.med"))
60 le_cas.SetDirName(DIRCASE)
61 #
62 # Iterations
63 # ==========
64 # Iteration "iter_1_1"
65 iter_1_1 = le_cas.NextIteration('iter_1_1')
66 iter_1_1.SetMeshName('MESH')
67 iter_1_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
68 iter_1_1.AssociateHypo('hypo_1')
69 erreur = iter_1_1.Compute(1, 2)
70
71 # Iteration "iter_1_2"
72 iter_1_2 = iter_1_1.NextIteration('iter_1_2')
73 iter_1_2.SetMeshName('MESH')
74 iter_1_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
75 iter_1_2.AssociateHypo('hypo_1')
76 erreur = iter_1_2.Compute(1, 2)
77
78 # Iteration "iter_1_3"
79 iter_1_3 = iter_1_2.NextIteration('iter_1_3')
80 iter_1_3.SetMeshName('MESH')
81 iter_1_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
82 iter_1_3.AssociateHypo('hypo_1')
83 erreur = iter_1_3.Compute(1, 2)
84 #
85 #============================== Fin des commandes ==============================
86 #
87 # ==================================
88 gzip_gunzip(DATA_TUTORIAL, 1, 1)
89 # ==================================
90 #
91 if salome.sg.hasDesktop():
92   salome.sg.updateObjBrowser()