Salome HOME
Copyright update 2022
[modules/homard.git] / doc / files / tutorial_1.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2011-2022  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, 2019
24 """
25 __revision__ = "V3.03"
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 creation_dircase
37 # ==================================
38 DIRCASE = creation_dircase(1)
39 # ==================================
40 #
41 import salome
42 salome.salome_init()
43 import HOMARD
44 #
45 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
46 homard.UpdateStudy()
47 #
48 #============================= Début des commandes =============================
49 #
50 # Hypotheses
51 # ==========
52 l_hypothese = homard.CreateHypothesis('hypo_1')
53 l_hypothese.SetUnifRefinUnRef(1)
54 #
55 # Cas
56 # ===
57 le_cas = homard.CreateCase('Case_1', 'MAILL', os.path.join(DATA_TUTORIAL, "tutorial_1.00.med"))
58 le_cas.SetDirName(DIRCASE)
59 #
60 # Iterations
61 # ==========
62 # Iteration "iter_1_1"
63 iter_1_1 = le_cas.NextIteration('iter_1_1')
64 iter_1_1.SetMeshName('MESH')
65 iter_1_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
66 iter_1_1.AssociateHypo('hypo_1')
67 erreur = iter_1_1.Compute(1, 2)
68
69 # Iteration "iter_1_2"
70 iter_1_2 = iter_1_1.NextIteration('iter_1_2')
71 iter_1_2.SetMeshName('MESH')
72 iter_1_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
73 iter_1_2.AssociateHypo('hypo_1')
74 erreur = iter_1_2.Compute(1, 2)
75
76 # Iteration "iter_1_3"
77 iter_1_3 = iter_1_2.NextIteration('iter_1_3')
78 iter_1_3.SetMeshName('MESH')
79 iter_1_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
80 iter_1_3.AssociateHypo('hypo_1')
81 erreur = iter_1_3.Compute(1, 2)
82 #
83 #============================== Fin des commandes ==============================
84 #
85 if salome.sg.hasDesktop():
86   salome.sg.updateObjBrowser()