Salome HOME
Update copyrights
[modules/homard.git] / doc / files / tutorial_4.py
old mode 100644 (file)
new mode 100755 (executable)
index 3dbaeb9..4e23bca
@@ -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-2019  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, 2011, 2013
+Copyright EDF 1996, 2011, 2018
 """
-__revision__ = "V2.2"
+__revision__ = "V4.3"
 #
 import os
+import sys
 #
 # ==================================
-# Repertoire a personnaliser
-# Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med, maill.03.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 gzip_gunzip
+from tutorial_util import creation_dircase
+# ==================================
+DIRCASE = creation_dircase(4)
+gzip_gunzip(DATA_TUTORIAL, 4, -1)
 # ==================================
-# Ce repertoire contient les fichiers de donnees : tutorial_4.00.med, tutorial_4.fr.med
-pathHomard = os.getenv('HOMARD_ROOT_DIR')
-data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/_downloads")
 #
 import salome
 salome.salome_init()
 import HOMARD
 #
 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
-study_main = salome.myStudyManager.NewStudy("HOMARD")
-homard.SetCurrentStudy(salome.myStudy)
-#
-# Creation of the boundaries
-# ==========================
-Boundary_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med')
+homard.UpdateStudy()
 #
-Boundary_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
+#============================= Début des commandes =============================
 #
-Boundary_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
-#
-Boundary_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
+# Frontières
+# ==========
+boun_4 = homard.CreateBoundaryCAO("PIQUAGE", os.path.join(DATA_TUTORIAL, "tutorial_4.xao"))
 #
-Boundary_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
+# Cas
+# ===
+le_cas = homard.CreateCase('Case_4', "PIQUAGE", os.path.join(DATA_TUTORIAL, "tutorial_4.00.med"))
+le_cas.SetDirName(DIRCASE)
+le_cas.AddBoundary( "PIQUAGE" )
 #
-# Hypothesis
+# Hypotheses
 # ==========
-# Creation of the hypothesis Hypo_1
-Hypo_1 = homard.CreateHypothesis('Hypo_1')
-Hypo_1.SetAdapRefinUnRef(-1, 1, 0)
-Hypo_1.AddGroup('T1_INT_I')
-Hypo_1.AddGroup('T1_INT_O')
-Hypo_1.AddGroup('T2_INT')
-# Creation of the hypothesis Hypo_2
-Hypo_2 = homard.CreateHypothesis('Hypo_2')
-Hypo_2.SetAdapRefinUnRef(-1, 1, 0)
-Hypo_2.AddGroup('T1_EXT_I')
-Hypo_2.AddGroup('T1_EXT_O')
-Hypo_2.AddGroup('T2_EXT')
-#
-# Case "Case"
-# =============
-Case = homard.CreateCase('Case', 'PIQUAGE', data_dir+'/tutorial_4.00.med')
-Case.SetDirName(dircase)
-Case.AddBoundaryGroup( 'intersection', '' )
-Case.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
-Case.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
-Case.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
-Case.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
-Case.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
-Case.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
-#
-# Creation of the iterations
-# ==========================
-# Creation of the iteration Iter_1 : raffinement selon les faces internes
-Iter_1 = Case.NextIteration('Iter_1')
-Iter_1.SetMeshName('PIQUAGE_1')
-Iter_1.SetMeshFile(dircase+'/maill.01.med')
-Iter_1.AssociateHypo('Hypo_1')
-codret = Iter_1.Compute(1, 2)
-# Creation of the iteration Iter_2 : raffinement selon les faces externes
-Iter_2 = Iter_1.NextIteration('Iter_2')
-Iter_2.SetMeshName('PIQUAGE_2')
-Iter_2.SetMeshFile(dircase+'/maill.02.med')
-Iter_2.AssociateHypo('Hypo_2')
-codret = Iter_2.Compute(1, 2)
-# Creation of the iteration Iter_3 : second raffinement selon les faces externes
-Iter_3 = Iter_2.NextIteration('Iter_3')
-Iter_3.SetMeshName('PIQUAGE_3')
-Iter_3.SetMeshFile(dircase+'/maill.03.med')
-Iter_3.AssociateHypo('Hypo_2')
-codret = Iter_3.Compute(1, 2)
+# Creation of the hypothesis hypo_4
+l_hypothese = homard.CreateHypothesis('hypo_4')
+l_hypothese.SetUnifRefinUnRef(1)
+l_hypothese.AddGroup('T1_INT_I')
+l_hypothese.AddGroup('T1_INT_O')
+l_hypothese.AddGroup('T2_INT')
+# Creation of the hypothesis hypo_4_bis
+l_hypothese_bis = homard.CreateHypothesis('hypo_4_bis')
+l_hypothese_bis.SetUnifRefinUnRef(1)
+l_hypothese_bis.AddGroup('T1_EXT_I')
+l_hypothese_bis.AddGroup('T1_EXT_O')
+l_hypothese_bis.AddGroup('T2_EXT')
+#
+# Iterations
+# ==========
+# Iteration iter_4_1 : raffinement selon les faces internes
+iter_4_1 = le_cas.NextIteration('iter_4_1')
+iter_4_1.SetMeshName('PIQUAGE_1')
+iter_4_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
+iter_4_1.AssociateHypo('hypo_4')
+erreur = iter_4_1.Compute(1, 2)
+# Iteration iter_4_2 : raffinement selon les faces externes
+iter_4_2 = iter_4_1.NextIteration('iter_4_2')
+iter_4_2.SetMeshName('PIQUAGE_2')
+iter_4_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
+iter_4_2.AssociateHypo('hypo_4_bis')
+erreur = iter_4_2.Compute(1, 2)
+# Iteration iter_4_3 : second raffinement selon les faces externes
+iter_4_3 = iter_4_2.NextIteration('iter_4_3')
+iter_4_3.SetMeshName('PIQUAGE_3')
+iter_4_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med"))
+iter_4_3.AssociateHypo('hypo_4_bis')
+erreur = iter_4_3.Compute(1, 2)
+#
+#============================== Fin des commandes ==============================
+#
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 4, 1)
+# ==================================
 
 if salome.sg.hasDesktop():
-  salome.sg.updateObjBrowser(1)
+  salome.sg.updateObjBrowser()