From: Gerald NICOLAS Date: Tue, 9 Jan 2018 16:03:49 +0000 (+0100) Subject: automatisation FronTrack - fichiers à télécharger X-Git-Tag: V8_5_0a1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=244cbd13f8aea042689efd30aa16809d502d0a6e;p=modules%2Fhomard.git automatisation FronTrack - fichiers à télécharger --- diff --git a/doc/en/images/create_boundary_cao_1.png b/doc/en/images/create_boundary_cao_1.png new file mode 100755 index 00000000..96c2382e Binary files /dev/null and b/doc/en/images/create_boundary_cao_1.png differ diff --git a/doc/files/tutorial_1.py b/doc/files/tutorial_1.py index b1553c17..39770e1c 100755 --- a/doc/files/tutorial_1.py +++ b/doc/files/tutorial_1.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- - # Copyright (C) 2011-2016 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or @@ -19,18 +17,17 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # - """ Exemple de couplage HOMARD-Salome -Copyright EDF-R&D 1996, 2010, 2014 +Copyright EDF 1996, 2010, 2018 """ -__revision__ = "V2.1" +__revision__ = "V3.1" # import os import sys # # ================================== -PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +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) @@ -47,42 +44,44 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") -study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # +#============================= Début des commandes ============================= +# # Hypotheses # ========== -hypo_1 = homard.CreateHypothesis('hypo_1') -hypo_1.SetUnifRefinUnRef(1) +l_hypothese = homard.CreateHypothesis('hypo_1') +l_hypothese.SetUnifRefinUnRef(1) # # Cas # === -case_1 = homard.CreateCase('Case_1', 'MAILL', DATA_TUTORIAL+'/tutorial_1.00.med') -case_1.SetDirName(DIRCASE) -case_1.SetConfType(1) +le_cas = homard.CreateCase('Case_1', 'MAILL', os.path.join(DATA_TUTORIAL, "tutorial_1.00.med")) +le_cas.SetDirName(DIRCASE) # # Iterations # ========== # Iteration "iter_1_1" -iter_1_1 = case_1.NextIteration('iter_1_1') +iter_1_1 = le_cas.NextIteration('iter_1_1') iter_1_1.SetMeshName('MESH') -iter_1_1.SetMeshFile(DIRCASE+'/maill.01.med') +iter_1_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) iter_1_1.AssociateHypo('hypo_1') -error = iter_1_1.Compute(1, 2) +erreur = iter_1_1.Compute(1, 2) # Iteration "iter_1_2" iter_1_2 = iter_1_1.NextIteration('iter_1_2') iter_1_2.SetMeshName('MESH') -iter_1_2.SetMeshFile(DIRCASE+'/maill.02.med') +iter_1_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) iter_1_2.AssociateHypo('hypo_1') -error = iter_1_2.Compute(1, 2) +erreur = iter_1_2.Compute(1, 2) # Iteration "iter_1_3" iter_1_3 = iter_1_2.NextIteration('iter_1_3') iter_1_3.SetMeshName('MESH') -iter_1_3.SetMeshFile(DIRCASE+'/maill.03.med') +iter_1_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med")) iter_1_3.AssociateHypo('hypo_1') -error = iter_1_3.Compute(1, 2) +erreur = iter_1_3.Compute(1, 2) +# +#============================== Fin des commandes ============================== # # ================================== gzip_gunzip(DATA_TUTORIAL, 1, 1) diff --git a/doc/files/tutorial_2.py b/doc/files/tutorial_2.py index ad007671..7a8fe656 100755 --- a/doc/files/tutorial_2.py +++ b/doc/files/tutorial_2.py @@ -22,15 +22,15 @@ """ Exemple de couplage HOMARD-Salome -Copyright EDF-R&D 1996, 2010, 2014 +Copyright EDF 1996, 2010, 2018 """ -__revision__ = "V2.10" +__revision__ = "V3.01" # import os import sys # # ================================== -PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +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) @@ -47,9 +47,10 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") -study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # +#============================= Début des commandes ============================= +# # Creation des zones # ================== # Box "Zone_0" @@ -63,37 +64,39 @@ Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) # # 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" # ====================== -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_TUTORIAL+'/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" # ==================== -iter_2_1 = case_2.NextIteration('iter_2_1') +iter_2_1 = le_cas.NextIteration('iter_2_1') iter_2_1.SetMeshName('M_1') -iter_2_1.SetMeshFile(DIRCASE+'/maill.01.med') +iter_2_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) iter_2_1.AssociateHypo('hypo_2') -error = iter_2_1.Compute(1, 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(DIRCASE+'/maill.02.med') +iter_2_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) iter_2_2.AssociateHypo('hypo_2_bis') -error = iter_2_2.Compute(1, 2) - +erreur = iter_2_2.Compute(1, 2) +# +#============================== Fin des commandes ============================== +# # ================================== gzip_gunzip(DATA_TUTORIAL, 2, 1) # ================================== diff --git a/doc/files/tutorial_3.py b/doc/files/tutorial_3.py index 07957b80..00da4557 100755 --- a/doc/files/tutorial_3.py +++ b/doc/files/tutorial_3.py @@ -22,15 +22,15 @@ """ Exemple de couplage HOMARD-Salome -Copyright EDF-R&D 1996, 2010, 2014 +Copyright EDF 1996, 2010, 2018 """ -__revision__ = "V2.1" +__revision__ = "V3.1" # import os import sys # # ================================== -PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +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) @@ -47,9 +47,10 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") -study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # +#============================= Début des commandes ============================= +# # Hypothese "hypo_0vers1" # ======================= hypo_0vers1 = homard.CreateHypothesis('hypo_0vers1') @@ -90,39 +91,41 @@ hypo_1vers2_bis.SetTypeFieldInterp(0) # # Cas # === -case_3 = homard.CreateCase('Case_3', 'G_0', DATA_TUTORIAL+'/tutorial_3.00.med') -case_3.SetDirName(DIRCASE) +le_cas = homard.CreateCase('Case_3', 'G_0', os.path.join(DATA_TUTORIAL, "tutorial_3.00.med")) +le_cas.SetDirName(DIRCASE) # # Iteration "iter_3_1" # ==================== -iter_3_1 = case_3.NextIteration('iter_3_1') +iter_3_1 = le_cas.NextIteration('iter_3_1') iter_3_1.SetMeshName('H_1') -iter_3_1.SetMeshFile(DIRCASE+'/maill.01.med') -iter_3_1.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.00.med') +iter_3_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) +iter_3_1.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.00.med")) iter_3_1.SetTimeStepRank( 1, 1) iter_3_1.AssociateHypo('hypo_0vers1') -error = iter_3_1.Compute(1, 2) +erreur = iter_3_1.Compute(1, 2) # # Iteration "iter_3_2" # ==================== iter_3_2 = iter_3_1.NextIteration('iter_3_2') iter_3_2.SetMeshName('H_2') -iter_3_2.SetMeshFile(DIRCASE+'/maill.02.med') -iter_3_2.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.01.med') +iter_3_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) +iter_3_2.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med")) iter_3_2.SetTimeStepRank(1, 1) iter_3_2.AssociateHypo('hypo_1vers2') -error = iter_3_2.Compute(1, 2) +erreur = iter_3_2.Compute(1, 2) # # Iteration "iter_3_2_bis" # ======================== iter_3_2_bis = iter_3_1.NextIteration('iter_3_2_bis') iter_3_2_bis.SetMeshName('H_2_bis') -iter_3_2_bis.SetMeshFile(DIRCASE+'/maill.02.bis.med') -iter_3_2_bis.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.01.med') +iter_3_2_bis.SetMeshFile(os.path.join(DIRCASE, "maill.02.bis.med")) +iter_3_2_bis.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med")) iter_3_2_bis.SetTimeStepRank(1, 1) iter_3_2_bis.AssociateHypo('hypo_1vers2_bis') -error = iter_3_2_bis.Compute(1, 2) - +erreur = iter_3_2_bis.Compute(1, 2) +# +#============================== Fin des commandes ============================== +# # ================================== gzip_gunzip(DATA_TUTORIAL, 3, 1) # ================================== diff --git a/doc/files/tutorial_4.fr.med.gz b/doc/files/tutorial_4.fr.med.gz deleted file mode 100644 index 171bc3ad..00000000 Binary files a/doc/files/tutorial_4.fr.med.gz and /dev/null differ diff --git a/doc/files/tutorial_4.py b/doc/files/tutorial_4.py index 8b8a583d..8da2992e 100755 --- a/doc/files/tutorial_4.py +++ b/doc/files/tutorial_4.py @@ -22,15 +22,15 @@ """ Exemple de couplage HOMARD-Salome -Copyright EDF-R&D 1996, 2011, 2014 +Copyright EDF 1996, 2011, 2018 """ -__revision__ = "V3.1" +__revision__ = "V4.2" # import os import sys # # ================================== -PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +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) @@ -47,69 +47,58 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") -study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Frontieres -# ========== -boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med') -# -boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) -# -boun_4_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.) +#============================= Début des commandes ============================= # -boun_4_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")) # -boun_4_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" ) # # Hypotheses # ========== # Creation of the hypothesis hypo_4 -hypo_4 = homard.CreateHypothesis('hypo_4') -hypo_4.SetUnifRefinUnRef(1) -hypo_4.AddGroup('T1_INT_I') -hypo_4.AddGroup('T1_INT_O') -hypo_4.AddGroup('T2_INT') +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 -hypo_4_bis = homard.CreateHypothesis('hypo_4_bis') -hypo_4_bis.SetUnifRefinUnRef(1) -hypo_4_bis.AddGroup('T1_EXT_I') -hypo_4_bis.AddGroup('T1_EXT_O') -hypo_4_bis.AddGroup('T2_EXT') -# -# Cas -# === -case_4 = homard.CreateCase('Case_4', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.00.med') -case_4.SetDirName(DIRCASE) -case_4.AddBoundaryGroup( 'intersection', '' ) -case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' ) -case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' ) -case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' ) -case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' ) -case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' ) -case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' ) +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 = case_4.NextIteration('iter_4_1') +iter_4_1 = le_cas.NextIteration('iter_4_1') iter_4_1.SetMeshName('PIQUAGE_1') -iter_4_1.SetMeshFile(DIRCASE+'/maill.01.med') +iter_4_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) iter_4_1.AssociateHypo('hypo_4') -error = iter_4_1.Compute(1, 2) +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(DIRCASE+'/maill.02.med') +iter_4_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) iter_4_2.AssociateHypo('hypo_4_bis') -error = iter_4_2.Compute(1, 2) +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(DIRCASE+'/maill.03.med') +iter_4_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med")) iter_4_3.AssociateHypo('hypo_4_bis') -error = iter_4_3.Compute(1, 2) - +erreur = iter_4_3.Compute(1, 2) +# +#============================== Fin des commandes ============================== +# # ================================== gzip_gunzip(DATA_TUTORIAL, 4, 1) # ================================== diff --git a/doc/files/tutorial_4.xao.gz b/doc/files/tutorial_4.xao.gz new file mode 100644 index 00000000..ecb87d33 Binary files /dev/null and b/doc/files/tutorial_4.xao.gz differ diff --git a/doc/files/tutorial_4.xml b/doc/files/tutorial_4.xml index b793eeee..6f44548e 100644 --- a/doc/files/tutorial_4.xml +++ b/doc/files/tutorial_4.xml @@ -29,9 +29,12 @@ + + + @@ -53,6 +56,7 @@ clt = orbmodule.client() StudyManager = clt.Resolve("/myStudyManager") CurrentStudy = StudyManager.GetStudyByID(1) ]]> + @@ -61,45 +65,6 @@ CurrentStudy = StudyManager.GetStudyByID(1) SetCurrentStudy - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder - - - - - - - - - - - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder - - - - - - - - - - - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder - - - - - - - - - - Etude_Initialisation.SetCurrentStudy CreateHypothesis @@ -116,12 +81,13 @@ CurrentStudy = StudyManager.GetStudyByID(1) + @@ -129,43 +95,23 @@ Hypo.AddGroup('T2_INT') # ========= # Repertoire d'execution Case.SetDirName(DirName) -# Options de conformite -Case.SetConfType(1) # Liens avec les frontieres -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' ) +Case.AddBoundary(CAO.GetName()) # Resultats # ========= # Iteration 0 associee Iter0 = Case.GetIter0() ]]> + + - + Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder + CreateBoundaryCAO - - - - - - - - - - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryDi - - @@ -177,25 +123,23 @@ Iter0 = Case.GetIter0() + StudyCreation SetCurrentStudy - SetCurrentStudy CreateBoundarycyl_1_int - CreateBoundarycyl_1_int CreateBoundarycyl_1_ext - CreateBoundarycyl_1_ext CreateBoundarycyl_2_int - CreateBoundarycyl_2_int CreateBoundarycyl_2_ext + SetCurrentStudy CreateBoundaryCAO CreateHypothesis_1 Hypo_Options_1 CreateCase Case_Options Hypo_Options_1 CreateHypothesis_2 Case_Options CreateHypothesis_1 - CreateBoundarycyl_2_ext CreateBoundaryintersection - CreateBoundaryintersection CreateCase + CreateBoundaryCAO CreateCase + CreateBoundaryCAO Case_Options CreateHypothesis_2 Hypo_Options_2 StudyCreation CurrentStudy @@ -209,6 +153,10 @@ Hypo.AddGroup('T2_EXT') CreateCase return Case_Options Case + + CreateBoundaryCAO return + Case_Options CAO + CreateHypothesis_2 return Hypo_Options_2 Hypo @@ -269,6 +217,7 @@ else : MessInfo = "" ]]> + @@ -289,17 +238,26 @@ else : - + @@ -307,8 +265,6 @@ else : + - @@ -387,6 +341,7 @@ else : MessInfo = "" ]]> + @@ -412,25 +367,21 @@ else : DataInit FileName Etude_Initialisation.CreateCase FileName - - DataInit BMeshName - Etude_Initialisation.CreateBoundaryintersection MeshName - DataInit BFileName - Etude_Initialisation.CreateBoundaryintersection FileName + Etude_Initialisation.CreateBoundaryCAO FileName DataInit DirName - HOMARD_1 DirName + Etude_Initialisation.Case_Options DirName DataInit DirName - Etude_Initialisation.Case_Options DirName + ForLoop.HOMARD_2 DirName DataInit DirName - ForLoop.HOMARD_2 DirName + HOMARD_1 DirName HOMARD_1 MessInfo @@ -469,104 +420,16 @@ else : HOMARD_1 Hypo - ForLoopnsteps - 2 - - - Etude_Initialisation.CreateBoundarycyl_1_extBoundaryName - cyl_1_ext - - - Etude_Initialisation.CreateBoundarycyl_1_extXcentre - 0 - - - Etude_Initialisation.CreateBoundarycyl_1_extYcentre - 25 - - - Etude_Initialisation.CreateBoundarycyl_1_extZcentre - -25 - - - Etude_Initialisation.CreateBoundarycyl_1_extXaxis - 25 - - - Etude_Initialisation.CreateBoundarycyl_1_extYaxis - 50 - - - Etude_Initialisation.CreateBoundarycyl_1_extZaxis - 75 - - - Etude_Initialisation.CreateBoundarycyl_1_extRadius - 100 + Etude_Initialisation.CreateBoundaryCAOBoundaryName + CAO - Etude_Initialisation.CreateBoundarycyl_1_intBoundaryName - cyl_1_int - - - Etude_Initialisation.CreateBoundarycyl_1_intXcentre - 0 - - - Etude_Initialisation.CreateBoundarycyl_1_intYcentre - 25 - - - Etude_Initialisation.CreateBoundarycyl_1_intZcentre - -25 - - - Etude_Initialisation.CreateBoundarycyl_1_intXaxis - 25 - - - Etude_Initialisation.CreateBoundarycyl_1_intYaxis - 50 - - - Etude_Initialisation.CreateBoundarycyl_1_intZaxis - 75 - - - Etude_Initialisation.CreateBoundarycyl_1_intRadius - 75 - - - Etude_Initialisation.CreateBoundarycyl_2_intBoundaryName - cyl_2_int - - - Etude_Initialisation.CreateBoundarycyl_2_intXcentre - 17.5 - - - Etude_Initialisation.CreateBoundarycyl_2_intYcentre - -2.5 - - - Etude_Initialisation.CreateBoundarycyl_2_intZcentre - -12.5 - - - Etude_Initialisation.CreateBoundarycyl_2_intXaxis - -100 - - - Etude_Initialisation.CreateBoundarycyl_2_intYaxis - -75 - - - Etude_Initialisation.CreateBoundarycyl_2_intZaxis - -25 + Etude_Initialisation.CreateHypothesis_2HypoName + Hypo_4_bis - Etude_Initialisation.CreateBoundarycyl_2_intRadius - 25 + ForLoopnsteps + 2 Etude_Initialisation.CreateCaseCaseName @@ -574,66 +437,22 @@ else : Etude_Initialisation.CreateHypothesis_1HypoName - Hypo_1 - - - Etude_Initialisation.CreateBoundarycyl_2_extBoundaryName - cyl_2_ext - - - Etude_Initialisation.CreateBoundarycyl_2_extXcentre - 17.5 - - - Etude_Initialisation.CreateBoundarycyl_2_extYcentre - -2.5 - - - Etude_Initialisation.CreateBoundarycyl_2_extZcentre - -12.5 - - - Etude_Initialisation.CreateBoundarycyl_2_extXaxis - -100 - - - Etude_Initialisation.CreateBoundarycyl_2_extYaxis - -75 - - - Etude_Initialisation.CreateBoundarycyl_2_extZaxis - -25 - - - Etude_Initialisation.CreateBoundarycyl_2_extRadius - 50 - - - Etude_Initialisation.CreateBoundaryintersectionBoundaryName - intersection - - - Etude_Initialisation.CreateHypothesis_2HypoName - Hypo_2 - - - - - - + Hypo_4 + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + diff --git a/doc/files/tutorial_5.py b/doc/files/tutorial_5.py index cdcd96e7..c155c1d9 100755 --- a/doc/files/tutorial_5.py +++ b/doc/files/tutorial_5.py @@ -22,15 +22,15 @@ """ Exemple de couplage HOMARD-Salome -Copyright EDF-R&D 1996, 2010, 2014 +Copyright EDF 1996, 2010, 2018 """ -__revision__ = "V2.1" +__revision__ = "V3.1" # import os import sys # # ================================== -PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +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) @@ -47,13 +47,14 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") -study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Frontiere +#============================= Début des commandes ============================= +# +# Frontière # ========= # Creation of the discrete boundary boun_5_1 -boun_5_1 = homard.CreateBoundaryDi('boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med') +boun_5_1 = homard.CreateBoundaryDi('boun_5_1', 'MAIL_EXT', os.path.join(DATA_TUTORIAL, "tutorial_5.fr.med")) # # Creation des zones # ================== @@ -65,24 +66,24 @@ quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 ) # Hypotheses # ========== # Creation of the hypothesis hypo_5 -hypo_5 = homard.CreateHypothesis('hypo_5') -hypo_5.AddZone('enveloppe', 1) -# Creation of the hypothesis hypo_5_bis -hypo_5_bis = homard.CreateHypothesis('hypo_5_bis') -hypo_5_bis.AddZone('quart_sup', 1) +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 # === -case_5 = homard.CreateCase('Case_5', 'COEUR_2D', DATA_TUTORIAL+'/tutorial_5.00.med') -case_5.SetDirName(DIRCASE) -case_5.SetConfType(3) -case_5.AddBoundaryGroup('boun_5_1', '') +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 = case_5.NextIteration('iter_5_1') +iter_5_1 = le_cas.NextIteration('iter_5_1') iter_5_1.SetMeshName('COEUR_2D_01') -iter_5_1.SetMeshFile(DIRCASE+'/maill.01.med') +iter_5_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) iter_5_1.AssociateHypo('hypo_5') error = iter_5_1.Compute(1, 2) # @@ -90,10 +91,12 @@ error = iter_5_1.Compute(1, 2) # ==================== iter_5_2 = iter_5_1.NextIteration('iter_5_2') iter_5_2.SetMeshName('COEUR_2D_02') -iter_5_2.SetMeshFile(DIRCASE+'/maill.02.med') +iter_5_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) iter_5_2.AssociateHypo('hypo_5_bis') error = iter_5_2.Compute(1, 2) - +# +#============================== Fin des commandes ============================== +# # ================================== gzip_gunzip(DATA_TUTORIAL, 5, 1) # ================================== diff --git a/doc/files/tutorial_6.fr.med.gz b/doc/files/tutorial_6.fr.med.gz new file mode 100644 index 00000000..e2808105 Binary files /dev/null and b/doc/files/tutorial_6.fr.med.gz differ diff --git a/doc/files/tutorial_6.py b/doc/files/tutorial_6.py new file mode 100755 index 00000000..cc12c548 --- /dev/null +++ b/doc/files/tutorial_6.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2011-2016 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, 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 1996, 2011, 2018 +""" +__revision__ = "V4.3" +# +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 gzip_gunzip +from tutorial_util import creation_dircase +# ================================== +DIRCASE = creation_dircase(6) +gzip_gunzip(DATA_TUTORIAL, 4, -1) +gzip_gunzip(DATA_TUTORIAL, 6, -1) +# ================================== +# +import salome +salome.salome_init() +import HOMARD +# +homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") +homard.SetCurrentStudy(salome.myStudy) +# +#============================= Début des commandes ============================= +# +# Frontières +# ========== +boun_6_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', os.path.join(DATA_TUTORIAL, "tutorial_6.fr.med")) +# +boun_6_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) +# +boun_6_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.) +# +boun_6_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.) +# +boun_6_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.) +# +# Cas +# === +le_cas = homard.CreateCase('Case_6', 'PIQUAGE', os.path.join(DATA_TUTORIAL, "tutorial_4.00.med")) +le_cas.SetDirName(DIRCASE) +le_cas.AddBoundary( 'intersection' ) +le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' ) +le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' ) +le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' ) +le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' ) +le_cas.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' ) +le_cas.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' ) +# +#============================== Fin des commandes ============================== +# +# Hypotheses +# ========== +# Creation of the hypothesis hypo_6 +l_hypothese = homard.CreateHypothesis('hypo_6') +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_6_bis +l_hypothese_bis = homard.CreateHypothesis('hypo_6_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_6_1 : raffinement selon les faces internes +iter_6_1 = le_cas.NextIteration('iter_6_1') +iter_6_1.SetMeshName('PIQUAGE_6_1') +iter_6_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) +iter_6_1.AssociateHypo('hypo_6') +erreur = iter_6_1.Compute(1, 2) +# Iteration iter_6_2 : raffinement selon les faces externes +iter_6_2 = iter_6_1.NextIteration('iter_6_2') +iter_6_2.SetMeshName('PIQUAGE_6_2') +iter_6_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) +iter_6_2.AssociateHypo('hypo_6_bis') +erreur = iter_6_2.Compute(1, 2) +# Iteration iter_6_3 : second raffinement selon les faces externes +iter_6_3 = iter_6_2.NextIteration('iter_6_3') +iter_6_3.SetMeshName('PIQUAGE_6_3') +iter_6_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med")) +iter_6_3.AssociateHypo('hypo_6_bis') +erreur = iter_6_3.Compute(1, 2) +# +# ================================== +gzip_gunzip(DATA_TUTORIAL, 4, 1) +gzip_gunzip(DATA_TUTORIAL, 6, 1) +# ================================== + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) diff --git a/doc/files/tutorial_6.xml b/doc/files/tutorial_6.xml new file mode 100755 index 00000000..542251c9 --- /dev/null +++ b/doc/files/tutorial_6.xml @@ -0,0 +1,652 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HOMARD + + SetCurrentStudy + + + + Etude_Initialisation.SetCurrentStudy + CreateBoundaryCylinder + + + + + + + + + + + + Etude_Initialisation.SetCurrentStudy + CreateBoundaryCylinder + + + + + + + + + + + + Etude_Initialisation.SetCurrentStudy + CreateBoundaryCylinder + + + + + + + + + + + + Etude_Initialisation.SetCurrentStudy + CreateHypothesis + + + + + Etude_Initialisation.SetCurrentStudy + CreateCase + + + + + + + + + + + + + + + + + + + Etude_Initialisation.SetCurrentStudy + CreateBoundaryCylinder + + + + + + + + + + + + Etude_Initialisation.SetCurrentStudy + CreateBoundaryDi + + + + + + + Etude_Initialisation.SetCurrentStudy + CreateHypothesis + + + + + + + + + StudyCreation SetCurrentStudy + SetCurrentStudy CreateBoundarycyl_1_int + CreateBoundarycyl_1_int CreateBoundarycyl_1_ext + CreateBoundarycyl_1_ext CreateBoundarycyl_2_int + CreateBoundarycyl_2_int CreateBoundarycyl_2_ext + CreateHypothesis_1 Hypo_Options_1 + CreateCase Case_Options + Hypo_Options_1 CreateHypothesis_2 + Case_Options CreateHypothesis_1 + CreateBoundarycyl_2_ext CreateBoundaryintersection + CreateBoundaryintersection CreateCase + CreateHypothesis_2 Hypo_Options_2 + + StudyCreation CurrentStudy + SetCurrentStudy theStudy + + + CreateHypothesis_1 return + Hypo_Options_1 Hypo + + + CreateCase return + Case_Options Case + + + CreateHypothesis_2 return + Hypo_Options_2 Hypo + + + + + + + + + + + + + + + + + HOMARD_2 Iter + HOMARD_2 LastIter + + + HOMARD_2 Pb + HOMARD_2 LastPb + + + + + + + + + + + + + + + + + + + + + + + + + + + + Etude_Initialisation HOMARD_1 + ForLoop Bilan + DataInit HOMARD_1 + DataInit Etude_Initialisation + HOMARD_1 ForLoop + + ForLoop index + ForLoop.HOMARD_2 NumAdapt + + + DataInit MeshName + Etude_Initialisation.CreateCase MeshName + + + DataInit FileName + Etude_Initialisation.CreateCase FileName + + + DataInit BMeshName + Etude_Initialisation.CreateBoundaryintersection MeshName + + + DataInit BFileName + Etude_Initialisation.CreateBoundaryintersection FileName + + + DataInit DirName + ForLoop.HOMARD_2 DirName + + + DataInit DirName + Etude_Initialisation.Case_Options DirName + + + DataInit DirName + HOMARD_1 DirName + + + HOMARD_1 MessInfo + Bilan MessInfo + + + HOMARD_1 MeshFile + Bilan MeshFile + + + HOMARD_1 Iter + ForLoop.HOMARD_2 LastIter + + + HOMARD_1 Pb + ForLoop.HOMARD_2 LastPb + + + Etude_Initialisation.CreateHypothesis_2 return + ForLoop.HOMARD_2 Hypo + + + ForLoop.HOMARD_2 MessInfo + Bilan MessInfo + + + ForLoop.HOMARD_2 MeshFile + Bilan MeshFile + + + Etude_Initialisation.Case_Options Iter0 + HOMARD_1 LastIter + + + Etude_Initialisation.CreateHypothesis_1 return + HOMARD_1 Hypo + + + Etude_Initialisation.CreateHypothesis_2HypoName + Hypo_6_bis + + + Etude_Initialisation.CreateBoundaryintersectionBoundaryName + intersection + + + Etude_Initialisation.CreateBoundarycyl_2_extBoundaryName + cyl_2_ext + + + Etude_Initialisation.CreateBoundarycyl_2_extXcentre + 17.5 + + + Etude_Initialisation.CreateBoundarycyl_2_extYcentre + -2.5 + + + Etude_Initialisation.CreateBoundarycyl_2_extZcentre + -12.5 + + + Etude_Initialisation.CreateBoundarycyl_2_extXaxis + -100 + + + Etude_Initialisation.CreateBoundarycyl_2_extYaxis + -75 + + + Etude_Initialisation.CreateBoundarycyl_2_extZaxis + -25 + + + Etude_Initialisation.CreateBoundarycyl_2_extRadius + 50 + + + Etude_Initialisation.CreateHypothesis_1HypoName + Hypo_6 + + + Etude_Initialisation.CreateBoundarycyl_2_intBoundaryName + cyl_2_int + + + Etude_Initialisation.CreateBoundarycyl_2_intXcentre + 17.5 + + + Etude_Initialisation.CreateBoundarycyl_2_intYcentre + -2.5 + + + Etude_Initialisation.CreateBoundarycyl_2_intZcentre + -12.5 + + + Etude_Initialisation.CreateBoundarycyl_2_intXaxis + -100 + + + Etude_Initialisation.CreateBoundarycyl_2_intYaxis + -75 + + + Etude_Initialisation.CreateBoundarycyl_2_intZaxis + -25 + + + Etude_Initialisation.CreateBoundarycyl_2_intRadius + 25 + + + Etude_Initialisation.CreateBoundarycyl_1_extBoundaryName + cyl_1_ext + + + Etude_Initialisation.CreateBoundarycyl_1_extXcentre + 0 + + + Etude_Initialisation.CreateBoundarycyl_1_extYcentre + 25 + + + Etude_Initialisation.CreateBoundarycyl_1_extZcentre + -25 + + + Etude_Initialisation.CreateBoundarycyl_1_extXaxis + 25 + + + Etude_Initialisation.CreateBoundarycyl_1_extYaxis + 50 + + + Etude_Initialisation.CreateBoundarycyl_1_extZaxis + 75 + + + Etude_Initialisation.CreateBoundarycyl_1_extRadius + 100 + + + Etude_Initialisation.CreateCaseCaseName + tutorial_6 + + + Etude_Initialisation.CreateBoundarycyl_1_intBoundaryName + cyl_1_int + + + Etude_Initialisation.CreateBoundarycyl_1_intXcentre + 0 + + + Etude_Initialisation.CreateBoundarycyl_1_intYcentre + 25 + + + Etude_Initialisation.CreateBoundarycyl_1_intZcentre + -25 + + + Etude_Initialisation.CreateBoundarycyl_1_intXaxis + 25 + + + Etude_Initialisation.CreateBoundarycyl_1_intYaxis + 50 + + + Etude_Initialisation.CreateBoundarycyl_1_intZaxis + 75 + + + Etude_Initialisation.CreateBoundarycyl_1_intRadius + 75 + + + ForLoopnsteps + 2 + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/files/tutorial_util.py b/doc/files/tutorial_util.py index 8a22233f..57149f4a 100755 --- a/doc/files/tutorial_util.py +++ b/doc/files/tutorial_util.py @@ -19,9 +19,9 @@ # """ Python script for HOMARD -Copyright EDF-R&D 2014, 2017 +Copyright EDF 2014, 2018 """ -__revision__ = "V2.01" +__revision__ = "V2.02" import os import sys @@ -33,11 +33,12 @@ REP_PYTHON = os.path.normpath(REP_PYTHON) sys.path.append(REP_PYTHON) from test_util import remove_dir -#======================================================================== -#======================================================================== +# +#========================= Debut de la fonction ================================== +# def gzip_gunzip(data_dir, num_tuto, option) : """ -Compression/Uncompression of the med files of a directory such as tutorial_x.nn.med +Compression/Uncompression of the med(or xao) files of a directory such as tutorial_x.nn.med (or tutorial_x.nn.xao) data_dir: directory num_tuto: number of the tutorial option : 1: compression, -1: uncompression @@ -66,13 +67,14 @@ Copyright EDF-R&D 2014 erreur = 1 break # - ficloc = ficloc_basis + ".fr.med" - nomfic = os.path.join(data_dir, ficloc) - if not os.path.isfile(nomfic) : - ficloc += ".gz" + for suffixe in ( "xao", "fr.med" ) : + ficloc = ficloc_basis + "." + suffixe nomfic = os.path.join(data_dir, ficloc) - if os.path.isfile(nomfic) : - os.system("gunzip "+nomfic) + if not os.path.isfile(nomfic) : + ficloc += ".gz" + nomfic = os.path.join(data_dir, ficloc) + if os.path.isfile(nomfic) : + os.system("gunzip "+nomfic) # # Compression # @@ -91,18 +93,21 @@ Copyright EDF-R&D 2014 erreur = 2 break # - ficloc = ficloc_basis + ".fr.med.gz" - nomfic = os.path.join(data_dir, ficloc) - if not os.path.isfile(nomfic) : - ficloc = ficloc_basis + ".fr.med" + for suffixe in ( "xao", "fr.med" ) : + ficloc = ficloc_basis + "." + suffixe + ".gz" nomfic = os.path.join(data_dir, ficloc) - if os.path.isfile(nomfic) : - os.system("gzip "+nomfic) + if not os.path.isfile(nomfic) : + ficloc = ficloc_basis + ".fr.med" + nomfic = os.path.join(data_dir, ficloc) + if os.path.isfile(nomfic) : + os.system("gzip "+nomfic) # return # -#======================================================================== -#======================================================================== +#========================== Fin de la fonction ================================== +# +#========================= Debut de la fonction ================================== +# def creation_dircase(num_tuto) : """ Creation of a directory for the results of tutorial_x @@ -124,6 +129,6 @@ Copyright EDF-R&D 2014 os.mkdir (dircase) # return dircase -#======================================================================== -#======================================================================== +# +#========================== Fin de la fonction ================================== # diff --git a/src/tests/Test/test_6.py b/src/tests/Test/test_6.py new file mode 100755 index 00000000..7a1226e0 --- /dev/null +++ b/src/tests/Test/test_6.py @@ -0,0 +1,347 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2011-2016 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, 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 +# +""" +Python script for HOMARD +Test test_6 +""" +__revision__ = "V1.02" + +#======================================================================== +TEST_NAME = "test_6" +DEBUG = False +N_ITER_TEST_FILE = 3 +# +TAILLE = 10. +LG_ARETE = TAILLE*2.5 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD") +REP_PYTHON = os.path.normpath(REP_PYTHON) +sys.path.append(REP_PYTHON) +from test_util import remove_dir +from test_util import test_results +from test_util import saveGeometry +# Repertoire des donnees du test +REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples") +REP_DATA = os.path.normpath(REP_DATA) +# Repertoire des resultats +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) +else : + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) + +salome.salome_init() +import iparameters +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") +# +#========================= Debut de la fonction ================================== +# +def create_geom(nom_obj, taille, verbose=False) : + """ +Création de la géométrie + """ +# + erreur = 0 +# + if verbose : + texte = "Geometrie '%s'\n" % nom_obj + texte += "Taille de base = %f" % taille + print (texte) +# + import GEOM + from salome.geom import geomBuilder + geompy = geomBuilder.New(salome.myStudy) +# +# 1. Les sommets et la première ligne +# + vertex_1 = geompy.MakeVertex( 0.*taille, 0.*taille, 0.*taille, theName = "V1") + vertex_2 = geompy.MakeVertex( 5.*taille, 2.*taille, 0.*taille, theName = "V2") + vertex_3 = geompy.MakeVertex(10.*taille, 1.*taille, 0.*taille, theName = "V3") + vertex_4 = geompy.MakeVertex(16.*taille, 4.*taille, 0.*taille, theName = "V4") + vertex_5 = geompy.MakeVertex(16.*taille, 10.*taille, 0.*taille, theName = "V5") +# + courbe_0 = geompy.MakeInterpol([vertex_1, vertex_2, vertex_3, vertex_4, vertex_5], False, False, theName="courbe_0") +# +# 2. Les sommets et la seconde ligne +# + sommet_1 = geompy.MakeVertex( 0.*taille, 0.*taille, 20.*taille, theName = "S1") + sommet_2 = geompy.MakeVertex( 6.*taille, -5.*taille, 20.*taille, theName = "S2") + sommet_3 = geompy.MakeVertex(11.*taille, -2.*taille, 20.*taille, theName = "S3") + sommet_4 = geompy.MakeVertex(12.*taille, 3.*taille, 20.*taille, theName = "S4") + sommet_5 = geompy.MakeVertex(16.*taille, 10.*taille, 20.*taille, theName = "S5") +# + courbe_1 = geompy.MakeInterpol([sommet_1, sommet_2, sommet_3, sommet_4, sommet_5], False, False, theName="courbe_1") +# +# 3. La face de base +# + structure_g = geompy.MakeFilling([courbe_0, courbe_1], theName=nom_obj) +# +# 4. Groupes : on cherche les entites par des proximités avec des shapes bien choisies +# + l_groupes_g = list() +# + shape = geompy.GetFaceNearPoint (structure_g, vertex_2) + nom = "Voile" + groupe_g = geompy.CreateGroup(structure_g, geompy.ShapeType["FACE"], nom) + geompy.UnionList ( groupe_g, [shape] ) + l_groupes_g.append( (nom, groupe_g, 2) ) +# + shape = geompy.GetEdgeNearPoint (structure_g, vertex_2) + nom = "C_0" + groupe_g = geompy.CreateGroup(structure_g, geompy.ShapeType["EDGE"], nom) + geompy.UnionList ( groupe_g, [shape] ) + l_groupes_g.append( (nom, groupe_g, 1) ) +# + shape = geompy.GetEdgeNearPoint (structure_g, sommet_2) + nom = "C_1" + groupe_g = geompy.CreateGroup(structure_g, geompy.ShapeType["EDGE"], nom) + geompy.UnionList ( groupe_g, [shape] ) + l_groupes_g.append( (nom, groupe_g, 1) ) +# + shape = geompy.GetEdge (structure_g, vertex_1, sommet_1) + nom = "D_0" + groupe_g = geompy.CreateGroup(structure_g, geompy.ShapeType["EDGE"], nom) + geompy.UnionList ( groupe_g, [shape] ) + l_groupes_g.append( (nom, groupe_g, 1) ) +# + shape = geompy.GetEdge (structure_g, vertex_5, sommet_5) + nom = "D_1" + groupe_g = geompy.CreateGroup(structure_g, geompy.ShapeType["EDGE"], nom) + geompy.UnionList ( groupe_g, [shape] ) + l_groupes_g.append( (nom, groupe_g, 1) ) +# + return erreur, structure_g, l_groupes_g +# +#========================== Fin de la fonction ================================== +# +#========================= Debut de la fonction ================================== +# +def create_mail(lg_arete, structure_g, l_groupes_g, rep_mail, verbose=False) : + """ +Création du maillage + """ +# + erreur = 0 + message = "" + ficmed = "" +# + while not erreur : +# + nom = structure_g.GetName() + if verbose : + texte = "Maillage de '%s'\n" % nom + texte += "lg_arete = %f\n" % lg_arete + texte += "rep_mail = '%s'" % rep_mail + print (texte) +# + import SMESH + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) +# +# 2. Maillage de calcul +# + maill_00 = smesh.Mesh(structure_g) + smesh.SetName(maill_00.GetMesh(), nom) +# + MG_CADSurf = maill_00.Triangle(algo=smeshBuilder.MG_CADSurf) + smesh.SetName(MG_CADSurf.GetAlgorithm(), 'MG_CADSurf') +# + MG_CADSurf_Parameters = MG_CADSurf.Parameters() + smesh.SetName(MG_CADSurf_Parameters, 'MG_CADSurf Triangles') + MG_CADSurf_Parameters.SetPhySize( lg_arete ) + MG_CADSurf_Parameters.SetMinSize( lg_arete/20. ) + MG_CADSurf_Parameters.SetMaxSize( lg_arete*5. ) + MG_CADSurf_Parameters.SetChordalError( lg_arete ) + MG_CADSurf_Parameters.SetAngleMesh( 12. ) +# +# 3. Les groupes issus de la géométrie +# + for taux in l_groupes_g : + groupe_m = maill_00.Group(taux[1]) + smesh.SetName(groupe_m, taux[0]) +# +# 4. Calcul +# + isDone = maill_00.Compute() + if not isDone : + message += "Probleme dans le maillage de la surface." + erreur = 13 + break +# +# 5. Export MED +# + ficmed = os.path.join(rep_mail,'maill.00.med') + texte = "Ecriture du fichier '%s'" % ficmed + if verbose : + print (texte) + maill_00.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1 ) +# + break +# + return erreur, message, ficmed +# +#========================== Fin de la fonction ================================== +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, xao_file, verbose=False): + """ +Python script for HOMARD + """ + erreur = 0 + message = "" +# + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Frontière + # ========= + if verbose : + print(". Frontière") + cao_name = "CAO_" + nom + la_frontiere = HOMARD.CreateBoundaryCAO(cao_name, xao_file) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + hyponame = "hypo_" + nom + l_hypothese = HOMARD.CreateHypothesis(hyponame) + l_hypothese.SetUnifRefinUnRef(1) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_'+nom, nom, ficmed) + le_cas.SetDirName(DIRCASE) + le_cas.AddBoundary(cao_name) + # + # Creation of the iterations + # ========================== + if verbose : + option = 2 + else : + option = 1 + # + for niter in range(1, N_ITER_TEST_FILE+1): + if verbose : + print(". Itération numéro %d" % niter) + iter_name = "I_" + nom + "_%02d" % niter + if ( niter == 1 ) : + l_iteration = le_cas.NextIteration(iter_name) + else : + l_iteration = l_iteration.NextIteration(iter_name) + l_iteration.SetMeshName(nom) + mesh_file = os.path.join(DIRCASE, "maill.%02d.med" % niter) + l_iteration.SetMeshFile(mesh_file) + l_iteration.AssociateHypo(hyponame) + erreur = l_iteration.Compute(1, option) + if erreur : + erreur = niter + break + # + break + # + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur + # + return erreur, message +# +#========================== Fin de la fonction ================================== +# +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : + # + VERBOSE = DEBUG + # + # A. Geometry + # + ERREUR, STRUCTURE_G, L_GROUPES_G = create_geom(TEST_NAME, TAILLE, VERBOSE) + if ERREUR : + MESSAGE = "The construction of the geometry failed." + break + # + # B. Save the geometry + # + XAO_FILE = os.path.join(DIRCASE, TEST_NAME+".xao") + try : + ERREUR = saveGeometry(XAO_FILE, TEST_NAME, "test_salome_"+TEST_NAME) + except Exception, eee: + ERREUR = 2000 + MESSAGE = eee.message + # + if ERREUR : + MESSAGE += "Pb in saveGeometry" + break + # + # C. Mesh + # + ERREUR, MESSAGE, FICMED = create_mail(LG_ARETE, STRUCTURE_G, L_GROUPES_G, DIRCASE, VERBOSE) + if ERREUR : + break + # + # D. Exec of HOMARD-SALOME + # + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") +# + try: + ERREUR, MESSAGE = homard_exec(TEST_NAME, FICMED, XAO_FILE, VERBOSE) + except Exception, eee: + ERREUR = 4000 + MESSAGE = eee.message + # + if ERREUR : + MESSAGE += "Pb in homard_exec" + break + # + # E. Test of the results + # + N_REP_TEST_FILE = N_ITER_TEST_FILE + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) + # + break +# +if ERREUR: + MESSAGE = "\nErreur numéro %d\n" % ERREUR + MESSAGE + raise Exception(MESSAGE) +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) + iparameters.getSession().restoreVisualState(1) + diff --git a/src/tests/Test/tutorial_6.py b/src/tests/Test/tutorial_6.py new file mode 100755 index 00000000..849998df --- /dev/null +++ b/src/tests/Test/tutorial_6.py @@ -0,0 +1,223 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2011-2016 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, 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 +# +""" +Python script for HOMARD +Test tutorial_6 associe au tutorial 6 +""" +__revision__ = "V4.02" + +#======================================================================== +TEST_NAME = "tutorial_6" +DEBUG = False +N_ITER_TEST_FILE = 3 +#======================================================================== +import os +import tempfile +import sys +import HOMARD +import salome +# +# ================================== +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD") +REP_PYTHON = os.path.normpath(REP_PYTHON) +sys.path.append(REP_PYTHON) +from test_util import remove_dir +from test_util import test_results +# Repertoire des donnees du test +REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples") +REP_DATA = os.path.normpath(REP_DATA) +# Repertoire des resultats +if DEBUG : + DIRCASE = os.path.join("/tmp", TEST_NAME) + if ( os.path.isdir(DIRCASE) ) : + remove_dir(DIRCASE) + os.mkdir(DIRCASE) +else : + DIRCASE = tempfile.mkdtemp(prefix=TEST_NAME) +# 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 +# ================================== +gzip_gunzip(DATA_TUTORIAL, 4, -1) +gzip_gunzip(DATA_TUTORIAL, 6, -1) +# ================================== + +salome.salome_init() +import iparameters +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) +IPAR.append("AP_MODULES_LIST", "Homard") +# +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, nomfr, ficfrmed, verbose=False): + """ +Python script for HOMARD + """ + erreur = 0 + message = "" +# + while not erreur : + # + HOMARD.SetCurrentStudy(salome.myStudy) + # + # Frontières + # ========== + if verbose : + print(". Frontières") + boun_6_1 = HOMARD.CreateBoundaryDi('intersection', nomfr, ficfrmed) + # + boun_6_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) + # + boun_6_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.) + # + boun_6_6 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.) + # + boun_6_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # Creation of the hypothesis hypo_0_1 + l_hypothese_0_1 = HOMARD.CreateHypothesis('hypo_6_0_1') + l_hypothese_0_1.SetUnifRefinUnRef(1) + l_hypothese_0_1.AddGroup('IN1') + l_hypothese_0_1.AddGroup('IN2') + l_hypothese_0_1.AddGroup('T1_INT_I') + l_hypothese_0_1.AddGroup('T1_INT_O') + l_hypothese_0_1.AddGroup('T2_INT') + # Creation of the hypothesis hypo_1_2 + l_hypothese_1_2 = HOMARD.CreateHypothesis('hypo_6_1_2') + l_hypothese_1_2.SetUnifRefinUnRef(1) + l_hypothese_1_2.AddGroup('T1_EXT_I') + l_hypothese_1_2.AddGroup('T1_EXT_O') + l_hypothese_1_2.AddGroup('T2_EXT') + # Creation of the hypothesis hypo_2_3 + l_hypothese_2_3 = HOMARD.CreateHypothesis('hypo_6_2_3') + l_hypothese_2_3.SetUnifRefinUnRef(1) + l_hypothese_2_3.AddGroup('INT_I') + l_hypothese_2_3.AddGroup('INT_E') + l_hypothese_2_3.AddGroup('IN1') + l_hypothese_2_3.AddGroup('IN2') + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_'+nom, nom, ficmed) + le_cas.SetDirName(DIRCASE) + le_cas.AddBoundary( 'intersection' ) + le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' ) + le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' ) + le_cas.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' ) + le_cas.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' ) + le_cas.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' ) + le_cas.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' ) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # Iteration iter_6_1 : raffinement selon les faces internes + iter_6_1 = le_cas.NextIteration('iter_6_1') + iter_6_1.SetMeshName('PIQUAGE_1') + iter_6_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_6_1.AssociateHypo('hypo_6_0_1') + erreur = iter_6_1.Compute(1, option) + print ("erreur = %d" % erreur) + if erreur : + break + # Iteration iter_6_2 : raffinement selon les faces externes + iter_6_2 = iter_6_1.NextIteration('iter_6_2') + iter_6_2.SetMeshName('PIQUAGE_2') + iter_6_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med")) + iter_6_2.AssociateHypo('hypo_6_1_2') + erreur = iter_6_2.Compute(1, option) + if erreur : + break + # Iteration iter_6_3 : second raffinement selon les faces externes + iter_6_3 = iter_6_2.NextIteration('iter_6_3') + iter_6_3.SetMeshName('PIQUAGE_3') + iter_6_3.SetMeshFile(os.path.join(DIRCASE, "maill.03.med")) + iter_6_3.AssociateHypo('hypo_6_2_3') + erreur = iter_6_3.Compute(1, option) + if erreur : + break + # + break + # + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur + # + return erreur, message +# +#========================== Fin de la fonction ================================== +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : + # + # A. Exec of HOMARD-SALOME + # + HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') + assert HOMARD is not None, "Impossible to load homard engine" + HOMARD.SetLanguageShort("fr") +# + FICMED = os.path.join(DATA_TUTORIAL, "tutorial_4.00.med") + FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med") + try: + ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, "COURBES", FICFRMED, DEBUG) + except Exception, eee: + ERREUR = 2 + MESSAGE = eee.message + # + if ERREUR : + MESSAGE += "Pb in homard_exec" + break + # + # B. Test of the results + # + N_REP_TEST_FILE = N_ITER_TEST_FILE + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) + # + break +# +if ERREUR: + raise Exception(MESSAGE) +# +# ================================== +gzip_gunzip(DATA_TUTORIAL, 4, 1) +gzip_gunzip(DATA_TUTORIAL, 6, 1) +# ================================== +# +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) + iparameters.getSession().restoreVisualState(1) +