-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2014 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
"""
Exemple de couplage HOMARD-Salome
-Copyright EDF-R&D 1996, 2010, 2014
+Copyright EDF 1996, 2010, 2019
"""
-__revision__ = "V1.10"
+__revision__ = "V3.03"
#
import os
import sys
#
# ==================================
-pathHomard = os.getenv('HOMARD_ROOT_DIR')
+PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
# Repertoire des donnees du tutorial
-data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-data_dir = os.path.normpath(data_dir)
-sys.path.append(data_dir)
-from tutorial_util import gzip_gunzip
+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(2)
-gzip_gunzip(data_dir, 2, -1)
+DIRCASE = creation_dircase(2)
# ==================================
#
import salome
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 des zones
# ==================
# Box "Zone_2"
Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
#
-# Hypothese "Hypo_2"
+# Hypothese "hypo_2"
# ==================
-Hypo_2 = homard.CreateHypothesis('Hypo_2')
-Hypo_2.AddZone('Zone_1', 1)
-Hypo_2.AddZone('Zone_0', 1)
+l_hypothese = homard.CreateHypothesis('hypo_2')
+l_hypothese.AddZone('Zone_1', 1)
+l_hypothese.AddZone('Zone_0', 1)
#
-# Hypothese "Hypo_2_bis"
+# Hypothese "hypo_2_bis"
# ======================
-Hypo_2_bis = homard.CreateHypothesis('Hypo_2_bis')
-Hypo_2_bis.AddZone('Zone_0', -1)
-Hypo_2_bis.AddZone('Zone_2', 1)
+l_hypothese_bis = homard.CreateHypothesis('hypo_2_bis')
+l_hypothese_bis.AddZone('Zone_0', -1)
+l_hypothese_bis.AddZone('Zone_2', 1)
#
# Cas
# ===
-Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med')
-Case_2.SetDirName(dircase)
+le_cas = homard.CreateCase('Case_2', 'MZERO', os.path.join(DATA_TUTORIAL, "tutorial_2.00.med"))
+le_cas.SetDirName(DIRCASE)
#
-# Iteration "Iter_2_1"
+# Iteration "iter_2_1"
# ====================
-Iter_2_1 = Case_2.NextIteration('Iter_2_1')
-Iter_2_1.SetMeshName('M_1')
-Iter_2_1.SetMeshFile(dircase+'/maill.01.med')
-Iter_2_1.AssociateHypo('Hypo_2')
-error = Iter_2_1.Compute(1, 2)
+iter_2_1 = le_cas.NextIteration('iter_2_1')
+iter_2_1.SetMeshName('M_1')
+iter_2_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
+iter_2_1.AssociateHypo('hypo_2')
+erreur = iter_2_1.Compute(1, 2)
#
-# Iteration "Iter_2_2"
+# Iteration "iter_2_2"
# ====================
-Iter_2_2 = Iter_2_1.NextIteration('Iter_2_2')
-Iter_2_2.SetMeshName('M_2')
-Iter_2_2.SetMeshFile(dircase+'/maill.02.med')
-Iter_2_2.AssociateHypo('Hypo_2_bis')
-error = Iter_2_2.Compute(1, 2)
-
-# ==================================
-gzip_gunzip(data_dir, 2, 1)
-# ==================================
+iter_2_2 = iter_2_1.NextIteration('iter_2_2')
+iter_2_2.SetMeshName('M_2')
+iter_2_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
+iter_2_2.AssociateHypo('hypo_2_bis')
+erreur = iter_2_2.Compute(1, 2)
+#
+#============================== Fin des commandes ==============================
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
+ salome.sg.updateObjBrowser()