Salome HOME
Copyright update 2021
[modules/homard.git] / doc / files / tutorial_5.py
old mode 100644 (file)
new mode 100755 (executable)
index 58908a3..cde5084
@@ -1,12 +1,12 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
 
-# Copyright (C) 2011-2013  CEA/DEN, EDF R&D
+# Copyright (C) 2011-2021  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 """
 Exemple de couplage HOMARD-Salome
-Copyright EDF-R&D 1996, 2010, 2013
+Copyright EDF 1996, 2010, 2019
 """
-__revision__ = "V1.5"
+__revision__ = "V3.04"
 #
 import os
+import sys
 #
 # ==================================
-# Repertoire a personnaliser
-# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med
-if os.environ.has_key("LOGNAME") :
-  user = os.environ ["LOGNAME"]
-else :
-  user = "anonymous"
-dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user)
-if not os.path.isdir(dircase) :
-  os.mkdir (dircase)
+PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
+# Repertoire des donnees du tutorial
+DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
+DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
+sys.path.append(DATA_TUTORIAL)
+from tutorial_util import creation_dircase
+# ==================================
+DIRCASE = creation_dircase(5)
 # ==================================
-# Ce repertoire contient les fichiers de donnees : tutorial_5.00.med, tutorial_5.fr.med
-pathHomard = os.getenv('HOMARD_ROOT_DIR')
-data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/fr/_downloads")
 #
 import salome
 salome.salome_init()
 import HOMARD
 #
 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
-study_main = salome.myStudyManager.NewStudy("HOMARD")
-homard.SetCurrentStudy(salome.myStudy)
+homard.UpdateStudy()
+#
+#============================= Début des commandes =============================
 #
-# Creation of the boundaries
-# ==========================
-# Creation of the discrete boundary Boun_1
-Boun_1 = homard.CreateBoundaryDi('Boun_1', 'MAIL_EXT', data_dir+'/tutorial_5.fr.med')
+# Frontière
+# =========
+# Creation of the discrete boundary boun_5_1
+boun_5_1 = homard.CreateBoundaryDi('boun_5_1', 'MAIL_EXT', os.path.join(DATA_TUTORIAL, "tutorial_5.fr.med"))
 #
-# Creation of the zones
-# =====================
+# Creation des zones
+# ==================
 # Creation of the disk with hole enveloppe
 enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
 # Creation of the rectangle quart_sup
 quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
 #
-# Hypothesis
+# Hypotheses
 # ==========
-# Creation of the hypothesis Hypo_1
-Hypo_1 = homard.CreateHypothesis('Hypo_1')
-Hypo_1.SetAdapRefinUnRef(0, 1, 0)
-Hypo_1.AddZone('enveloppe', 1)
-# Creation of the hypothesis Hypo_2
-Hypo_2 = homard.CreateHypothesis('Hypo_2')
-Hypo_2.SetAdapRefinUnRef(0, 1, 0)
-Hypo_2.AddZone('quart_sup', 1)
-#
-# Case "Case_1"
-# =============
-Case_1 = homard.CreateCase('Case_1', 'COEUR_2D', data_dir+'/tutorial_5.00.med')
-Case_1.SetDirName(dircase)
-Case_1.SetConfType(3)
-Case_1.AddBoundaryGroup('Boun_1', '')
-#
-# Iteration "Iter_1"
-# ==================
-Iter_1 = Case_1.NextIteration('Iter_1')
-Iter_1.SetMeshName('COEUR_2D_01')
-Iter_1.SetMeshFile(dircase+'/maill.01.med')
-Iter_1.AssociateHypo('Hypo_1')
-codret = Iter_1.Compute(1, 2)
+# Creation of the hypothesis hypo_5
+l_hypothese = homard.CreateHypothesis('hypo_5')
+l_hypothese.AddZone('enveloppe', 1)
+# Creation of the hypothesis l_hypothese_bis
+l_hypothese_bis = homard.CreateHypothesis('hypo_5_bis')
+l_hypothese_bis.AddZone('quart_sup', 1)
+#
+# Cas
+# ===
+le_cas = homard.CreateCase('Case_5', 'COEUR_2D', os.path.join(DATA_TUTORIAL, "tutorial_5.00.med"))
+le_cas.SetDirName(DIRCASE)
+le_cas.SetConfType(1)
+le_cas.AddBoundary('boun_5_1')
+#
+# Iteration "iter_5_1"
+# ====================
+iter_5_1 = le_cas.NextIteration('iter_5_1')
+iter_5_1.SetMeshName('COEUR_2D_01')
+iter_5_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
+iter_5_1.AssociateHypo('hypo_5')
+erreur = iter_5_1.Compute(1, 2)
+#
+# Iteration "iter_5_2"
+# ====================
+iter_5_2 = iter_5_1.NextIteration('iter_5_2')
+iter_5_2.SetMeshName('COEUR_2D_02')
+iter_5_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
+iter_5_2.AssociateHypo('hypo_5_bis')
+erreur = iter_5_2.Compute(1, 2)
+#
+#============================== Fin des commandes ==============================
 #
-# Iteration "Iter_2"
-# ==================
-Iter_2 = Iter_1.NextIteration('Iter_2')
-Iter_2.SetMeshName('COEUR_2D_02')
-Iter_2.SetMeshFile(dircase+'/maill.02.med')
-Iter_2.AssociateHypo('Hypo_2')
-codret = Iter_2.Compute(1, 2)
-
-
 if salome.sg.hasDesktop():
-  salome.sg.updateObjBrowser(1)
+  salome.sg.updateObjBrowser()