X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Ffiles%2Ftutorial_2.py;h=89dbd869871cb6478ad3f596d09778f76afcab88;hb=refs%2Ftags%2FV9_13_0b1;hp=d6e7ca8de90518d8bba6f53db0c18793a00fba2c;hpb=bdbb00479184579ff9ec2e33886894326d4d6a0f;p=modules%2Fhomard.git diff --git a/doc/files/tutorial_2.py b/doc/files/tutorial_2.py old mode 100644 new mode 100755 index d6e7ca8d..89dbd869 --- a/doc/files/tutorial_2.py +++ b/doc/files/tutorial_2.py @@ -1,69 +1,99 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright (C) 2011-2024 CEA, EDF +# +# 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, 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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + """ Exemple de couplage HOMARD-Salome -Copyright EDF-R&D 1996, 2010 +Copyright EDF 1996, 2010, 2019 """ -__revision__ = "V1.0" +__revision__ = "V3.03" +# +import os +import sys +# +# ================================== +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(2) +# ================================== # 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() # -dircase = "/tmp" +#============================= Début des commandes ============================= # -# Creation of the zones -# ===================== +# Creation des zones +# ================== # Box "Zone_0" -Zone_0 = homard.CreateZone('Zone_0', 2) -Zone_0.SetBox(-0.1, 1.1, -0.1, 1.1, 0.9, 1.1) +Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) # # Sphere "Zone_1" -Zone_1 = homard.CreateZone('Zone_1', 4) -Zone_1.SetSphere(0., 0., 0., 1.05) +Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05) # # Box "Zone_2" -Zone_2 = homard.CreateZone('Zone_2', 2) -Zone_2.SetBox(-0.1, 0.51, -0.1, 0.51, -0.1, 0.51) -# -# Hypothesis "Hypo_0" -# =================== -Hypo_0 = homard.CreateHypothesis('Hypo_0') -Hypo_0.SetAdapRefinUnRef(0, 1, 0) -homard.AssociateHypoZone('Zone_1', 'Hypo_0') -homard.AssociateHypoZone('Zone_0', 'Hypo_0') -# -# Hypothesis "Hypo_1" -# =================== -Hypo_1 = homard.CreateHypothesis('Hypo_1') -Hypo_1.SetAdapRefinUnRef(0, 1, 0) -homard.AssociateHypoZone('Zone_0', 'Hypo_1') -homard.AssociateHypoZone('Zone_2', 'Hypo_1') -# -# Case "Case_0" -# ============= -Case_0 = homard.CreateCase('Case_0', 'MZERO', dircase+'/tutorial_2.00.med') -Case_0.SetDirName(dircase) -# -# Iteration "Iter_0" -# ================== -Iter_0 = homard.CreateIteration('Iter_0', Case_0.GetIter0Name()) -Iter_0.SetMeshName('M_1') -Iter_0.SetMeshFile(dircase+'/maill.01.med') -homard.AssociateIterHypo('Iter_0', 'Hypo_0') -codret = homard.Compute('Iter_0', 1) +Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) # -# Iteration "Iter_1" +# Hypothese "hypo_2" # ================== -Iter_1 = homard.CreateIteration('Iter_1', 'Iter_0') -Iter_1.SetMeshName('M_2') -Iter_1.SetMeshFile(dircase+'/maill.02.med') -homard.AssociateIterHypo('Iter_1', 'Hypo_1') -codret = homard.Compute('Iter_1', 1) +l_hypothese = homard.CreateHypothesis('hypo_2') +l_hypothese.AddZone('Zone_1', 1) +l_hypothese.AddZone('Zone_0', 1) +# +# Hypothese "hypo_2_bis" +# ====================== +l_hypothese_bis = homard.CreateHypothesis('hypo_2_bis') +l_hypothese_bis.AddZone('Zone_0', -1) +l_hypothese_bis.AddZone('Zone_2', 1) +# +# Cas +# === +le_cas = homard.CreateCase('Case_2', 'MZERO', os.path.join(DATA_TUTORIAL, "tutorial_2.00.med")) +le_cas.SetDirName(DIRCASE) +# +# Iteration "iter_2_1" +# ==================== +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" +# ==================== +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()