]> SALOME platform Git repositories - modules/homard.git/blob - doc/files/tutorial_1.py
Salome HOME
tests et tutorial
[modules/homard.git] / doc / files / tutorial_1.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, 2010, 2018
26 """
27 __revision__ = "V3.1"
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(1)
42 gzip_gunzip(DATA_TUTORIAL, 1, -1)
43 # ==================================
44 #
45 import salome
46 salome.salome_init()
47 import HOMARD
48 #
49 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
50 homard.UpdateStudy()
51 #
52 #============================= Début des commandes =============================
53 #
54 # Hypotheses
55 # ==========
56 l_hypothese = homard.CreateHypothesis('hypo_1')
57 l_hypothese.SetUnifRefinUnRef(1)
58 #
59 # Cas
60 # ===
61 le_cas = homard.CreateCase('Case_1', 'MAILL', os.path.join(DATA_TUTORIAL, "tutorial_1.00.med"))
62 le_cas.SetDirName(DIRCASE)
63 #
64 # Iterations
65 # ==========
66 # Iteration "iter_1_1"
67 iter_1_1 = le_cas.NextIteration('iter_1_1')
68 iter_1_1.SetMeshName('MESH')
69 iter_1_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
70 iter_1_1.AssociateHypo('hypo_1')
71 erreur = iter_1_1.Compute(1, 2)
72
73 # Iteration "iter_1_2"
74 iter_1_2 = iter_1_1.NextIteration('iter_1_2')
75 iter_1_2.SetMeshName('MESH')
76 iter_1_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
77 iter_1_2.AssociateHypo('hypo_1')
78 erreur = iter_1_2.Compute(1, 2)
79
80 # Iteration "iter_1_3"
81 iter_1_3 = iter_1_2.NextIteration('iter_1_3')
82 iter_1_3.SetMeshName('MESH')
83 iter_1_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
84 iter_1_3.AssociateHypo('hypo_1')
85 erreur = iter_1_3.Compute(1, 2)
86 #
87 #============================== Fin des commandes ==============================
88 #
89 # ==================================
90 gzip_gunzip(DATA_TUTORIAL, 1, 1)
91 # ==================================
92 #
93 if salome.sg.hasDesktop():
94   salome.sg.updateObjBrowser()