From: Gerald NICOLAS Date: Mon, 15 Jan 2018 10:41:55 +0000 (+0100) Subject: tests et tutorial X-Git-Tag: V9_0_0^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d7d01c43ae1939e2d7834e4b1a3104239466b82;p=modules%2Fhomard.git tests et tutorial --- diff --git a/doc/files/tutorial_1.py b/doc/files/tutorial_1.py index 51b46e37..b02c56ec 100755 --- a/doc/files/tutorial_1.py +++ b/doc/files/tutorial_1.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,40 +47,44 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") +homard.UpdateStudy() +# +#============================= 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 8fe7b6a9..9a351357 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,6 +47,9 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") +homard.UpdateStudy() +# +#============================= Début des commandes ============================= # # Creation des zones # ================== @@ -61,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 61ffaae6..22eba2b1 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,6 +47,9 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") +homard.UpdateStudy() +# +#============================= Début des commandes ============================= # # Hypothese "hypo_0vers1" # ======================= @@ -88,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.00.med.gz b/doc/files/tutorial_4.00.med.gz index b0bc4273..d023424b 100644 Binary files a/doc/files/tutorial_4.00.med.gz and b/doc/files/tutorial_4.00.med.gz differ 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 9b4751f1..02b05e2a 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,67 +47,58 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") +homard.UpdateStudy() # -# 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 100755 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 0fadf72f..2ccdb22c 100644 --- a/doc/files/tutorial_4.xml +++ b/doc/files/tutorial_4.xml @@ -1,5 +1,6 @@ + @@ -28,9 +29,12 @@ + + + @@ -51,6 +55,7 @@ import HOMARD_Boundary_idl clt = orbmodule.client() CurrentStudy = clt.Resolve("/Study") ]]> + @@ -59,45 +64,6 @@ CurrentStudy = clt.Resolve("/Study") SetCurrentStudy - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder - - - - - - - - - - - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder - - - - - - - - - - - - Etude_Initialisation.SetCurrentStudy - CreateBoundaryCylinder - - - - - - - - - - Etude_Initialisation.SetCurrentStudy CreateHypothesis @@ -114,12 +80,13 @@ CurrentStudy = clt.Resolve("/Study") + @@ -127,43 +94,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 - - @@ -175,25 +122,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 @@ -207,6 +152,10 @@ Hypo.AddGroup('T2_EXT') CreateCase return Case_Options Case + + CreateBoundaryCAO return + Case_Options CAO + CreateHypothesis_2 return Hypo_Options_2 Hypo @@ -267,6 +216,7 @@ else : MessInfo = "" ]]> + @@ -287,17 +237,26 @@ else : - + @@ -305,8 +264,6 @@ else : + - @@ -385,6 +340,7 @@ else : MessInfo = "" ]]> + @@ -410,25 +366,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 @@ -467,104 +419,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 @@ -572,66 +436,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 12bb4943..fdb7ea5d 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.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,11 +47,14 @@ salome.salome_init() import HOMARD # homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") +homard.UpdateStudy() # -# 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 # ================== @@ -63,35 +66,37 @@ 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) +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(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) - +erreur = 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 100755 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..c4644020 --- /dev/null +++ b/doc/files/tutorial_6.py @@ -0,0 +1,125 @@ +#!/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.4" +# +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', 'COURBES', 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('IN1') +l_hypothese.AddGroup('IN2') +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/doc/files/yacs_script.py b/doc/files/yacs_script.py index 587ec7e2..20367f96 100755 --- a/doc/files/yacs_script.py +++ b/doc/files/yacs_script.py @@ -22,7 +22,7 @@ """ Lancement d'un calcul ASTER """ -__revision__ = "V5.9" +__revision__ = "V5.11" # import sys import os diff --git a/doc/files/yacs_script_test.py b/doc/files/yacs_script_test.py index 12f4f581..056b87f2 100755 --- a/doc/files/yacs_script_test.py +++ b/doc/files/yacs_script_test.py @@ -22,7 +22,7 @@ """ Pseudo-lancement d'un calcul pour valider les tests """ -__revision__ = "V2.1" +__revision__ = "V2.2" # import sys import os diff --git a/src/tests/Test/CMakeLists.txt b/src/tests/Test/CMakeLists.txt index 93266444..d27d7859 100755 --- a/src/tests/Test/CMakeLists.txt +++ b/src/tests/Test/CMakeLists.txt @@ -24,11 +24,13 @@ SET(HOMARD_TEST_FILES test_3.py test_4.py test_5.py + test_6.py tutorial_1.py tutorial_2.py tutorial_3.py tutorial_4.py tutorial_5.py + tutorial_6.py test_util.py ) diff --git a/src/tests/Test/CTestTestfileInstall.cmake b/src/tests/Test/CTestTestfileInstall.cmake index f9df746f..a95627c3 100644 --- a/src/tests/Test/CTestTestfileInstall.cmake +++ b/src/tests/Test/CTestTestfileInstall.cmake @@ -28,11 +28,13 @@ test_2 test_3 test_4 test_5 +test_6 tutorial_1 tutorial_2 tutorial_3 tutorial_4 tutorial_5 +tutorial_6 ) FOREACH(tfile ${HOMARD_TEST_FILES}) diff --git a/src/tests/Test/test_1.py b/src/tests/Test/test_1.py index 9690918f..ca1a4c93 100755 --- a/src/tests/Test/test_1.py +++ b/src/tests/Test/test_1.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_1 """ -__revision__ = "V4.01" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "test_1" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,19 +39,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_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() +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -108,10 +99,10 @@ Python script for HOMARD zones_1_et_2.AddZone('Zone_1_2', 1) laux = zones_1_et_2.GetZones() nbzone = len(laux) // 2 - jaux = 0 - for iaux in range(nbzone) : - print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]) - jaux += 2 + iaux = 0 + for _ in range(nbzone) : + print(hyponame_2, " : ", dico[laux[iaux+1]], "sur la zone", laux[iaux]) + iaux += 2 print(hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName()) if ( len (zones_1_et_2.GetFieldName()) > 0 ) : print(".. caractéristiques de l'adaptation :", zones_1_et_2.GetField()) @@ -205,7 +196,7 @@ try : ERROR = homard_exec() if ERROR : raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: +except RuntimeError as eee: raise Exception('Pb in homard_exec: '+str(eee.message)) # # Test of the results diff --git a/src/tests/Test/test_2.py b/src/tests/Test/test_2.py index f4f58a21..ad6cff7f 100755 --- a/src/tests/Test/test_2.py +++ b/src/tests/Test/test_2.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_2 """ -__revision__ = "V4.01" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "test_2" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,19 +39,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_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() +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -177,8 +168,8 @@ try : ERROR = homard_exec() if ERROR : raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) +except RuntimeError as eee: + raise Exception('Pb in homard_exec: '+str(eee.message)) # # Test of the results # diff --git a/src/tests/Test/test_3.py b/src/tests/Test/test_3.py index cb324205..87175a93 100755 --- a/src/tests/Test/test_3.py +++ b/src/tests/Test/test_3.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_3 """ -__revision__ = "V4.01" +__revision__ = "V4.04" #======================================================================== TEST_NAME = "test_3" @@ -30,7 +30,6 @@ N_BOUCLE = 2 N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -41,19 +40,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_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() +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -112,7 +103,7 @@ Python script for HOMARD mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med') case_test_3 = HOMARD.CreateCase(TEST_NAME, 'MOYEU', mesh_file) case_test_3.SetDirName(DIRCASE) - case_test_3.AddBoundaryGroup('courbes', '') + case_test_3.AddBoundary('courbes') case_test_3.AddBoundaryGroup('cyl_ext', 'EXT') case_test_3.AddBoundaryGroup('cyl_int', 'INT') case_test_3.AddBoundaryGroup('sphere_1', 'END_1') @@ -211,8 +202,8 @@ try : ERROR = homard_exec() if ERROR : raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) +except RuntimeError as eee: + raise Exception('Pb in homard_exec: '+str(eee.message)) # # Test of the results # diff --git a/src/tests/Test/test_4.py b/src/tests/Test/test_4.py index 6a83c6f8..ddb7d7d1 100755 --- a/src/tests/Test/test_4.py +++ b/src/tests/Test/test_4.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_4 """ -__revision__ = "V3.01" +__revision__ = "V3.03" #======================================================================== TEST_NAME = "test_4" @@ -32,7 +32,6 @@ DY = 400. DZ = 200. #======================================================================== import os -import tempfile import sys import numpy as np import salome @@ -48,19 +47,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_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() +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -128,7 +119,7 @@ Python script for GEOM and SMESH try: ficmed = os.path.join(DIRCASE, 'maill.00.med') box_m.ExportMED(ficmed) - except Exception as eee: + except IOError as eee: error = 2 raise Exception('ExportMED() failed. ' + str(eee)) # @@ -220,7 +211,7 @@ Python script for HOMARD laux = hypo_4_1.GetZones() nbzone = len(laux) // 2 jaux = 0 - for iaux in range(nbzone) : + for _ in range(nbzone) : print(hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]) jaux += 2 # Creation of the hypothesis hypo_4_2 @@ -232,7 +223,7 @@ Python script for HOMARD laux = hypo_4_2.GetZones() nbzone = len(laux) // 2 jaux = 0 - for iaux in range(nbzone) : + for _ in range(nbzone) : print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]) jaux += 2 # Creation of the hypothesis DISTANCE INVERSE @@ -320,7 +311,7 @@ try : ERROR = geom_smesh_exec() if ERROR : raise Exception('Pb in geom_smesh_exec') -except Exception as eee: +except RuntimeError as eee: raise Exception('Pb in geom_smesh_exec: '+str(eee.message)) HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') @@ -333,7 +324,7 @@ try : ERROR = homard_exec() if ERROR : raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: +except RuntimeError as eee: raise Exception('Pb in homard_exec: '+str(eee.message)) # # Test of the results diff --git a/src/tests/Test/test_5.py b/src/tests/Test/test_5.py index 439426c0..125a9626 100755 --- a/src/tests/Test/test_5.py +++ b/src/tests/Test/test_5.py @@ -22,7 +22,7 @@ Python script for HOMARD Specific conditions for Code_Saturne Test test_5 """ -__revision__ = "V2.01" +__revision__ = "V2.03" #======================================================================== TEST_NAME = "test_5" @@ -38,7 +38,6 @@ LG_Z = 160. MESH_NAME = "MESH" #======================================================================== import os -import tempfile import sys import numpy as np import salome @@ -52,19 +51,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_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() +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -103,11 +94,11 @@ Python script for MED # coordinates = list() coo_z = -0.5*LG_Z - for kaux in range(nbno_z) : + for _ in range(nbno_z) : coo_y = -0.5*LG_Y - for jaux in range(nbno_y) : + for _ in range(nbno_y) : coo_x = -0.5*LG_X - for iaux in range(nbno_x) : + for _ in range(nbno_x) : coordinates.append(coo_x) coordinates.append(coo_y) coordinates.append(coo_z) @@ -167,7 +158,7 @@ Python script for MED ficmed = os.path.join(DIRCASE, 'maill.00.med') #print "Ecriture du maillage dans le fichier", ficmed meshMEDFile3D.write(ficmed, 2) - except Exception as eee: + except IOError as eee: error = 2 raise Exception('MEDFileUMesh.write() failed. ' + str(eee)) # @@ -308,7 +299,7 @@ try : ERROR = mesh_exec() if ERROR : raise Exception('Pb in mesh_exec') -except Exception as eee: +except RuntimeError as eee: raise Exception('Pb in mesh_exec: '+str(eee.message)) HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') @@ -321,7 +312,7 @@ try : ERROR = homard_exec() if ERROR : raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: +except RuntimeError as eee: raise Exception('Pb in homard_exec: '+str(eee.message)) # # Test of the results diff --git a/src/tests/Test/test_6.py b/src/tests/Test/test_6.py new file mode 100755 index 00000000..c329efdc --- /dev/null +++ b/src/tests/Test/test_6.py @@ -0,0 +1,341 @@ +# -*- 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.04" + +#======================================================================== +TEST_NAME = "test_6" +DEBUG = False +N_ITER_TEST_FILE = 3 +# +TAILLE = 10. +LG_ARETE = TAILLE*2.5 +#======================================================================== +import os +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 saveGeometry +from test_util import get_dir +from test_util import test_results +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== + +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) +# + from salome.geom import geomBuilder + geompy = geomBuilder.New() +# +# 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) +# + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New() +# +# 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) + try: + maill_00.ExportMED(ficmed) + except IOError as eee: + error = 2 + raise Exception('ExportMED() failed. ' + str(eee)) +# + 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.UpdateStudy() + # + # 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 IOError as eee: + ERREUR = os.error + MESSAGE = str(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 RuntimeError as eee: + ERREUR = os.error + MESSAGE = str(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() + iparameters.getSession().restoreVisualState(1) + diff --git a/src/tests/Test/test_util.py b/src/tests/Test/test_util.py index 6fb8c33f..960c0e8d 100755 --- a/src/tests/Test/test_util.py +++ b/src/tests/Test/test_util.py @@ -21,13 +21,50 @@ Python script for HOMARD Utilitaires pour les tests """ -__revision__ = "V3.01" +__revision__ = "V4.02" import os +import tempfile import MEDLoader as ml import shutil #======================================================================== #======================================================================== +def get_dir(path_homard, test_name, debug=False) : + """ +Get directories for the test. +Copyright EDF 2018 + """ +# +# Répertoire des données du test + rep_data = os.path.join(path_homard, "share", "salome", "homardsamples") + rep_data = os.path.normpath(rep_data) +# +# Répertoire des résultats + 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) +# + return rep_data, dircase +# +#======================================================================== +#======================================================================== +def get_dir_tutorial(path_homard) : + """ +Get directory for the tutorial. +Copyright EDF 2018 + """ +# +# Répertoire des données du tutorial + data_tutorial = os.path.join(path_homard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") + data_tutorial = os.path.normpath(data_tutorial) +# + return data_tutorial +#======================================================================== +#======================================================================== def remove_dir(directory) : """ Empties, then removes a directory. @@ -61,16 +98,15 @@ Copyright EDF-R&D 2014 # test_file_suff = "apad.%02d.bilan" % n_iter_test_file rep_test_file = "I%02d" % n_rep_test_file +# +# Existence du fichier de référence # test_file = os.path.join(rep_test, test_name + "." + test_file_suff) mess_error_ref = "\nReference file: " + test_file -# -# Existence du fichier de référence -# + #print ("test_file = %s" % test_file) try : - file = open (test_file, "r") - les_lignes_ref = file.readlines() - file.close() + with open (test_file, "r") as fichier : + les_lignes_ref = fichier.readlines() except : mess_error = mess_error_ref + "\nThis file does not exist.\n" destroy_dir = False @@ -80,9 +116,8 @@ Copyright EDF-R&D 2014 # test_file = os.path.join(dircase, rep_test_file, test_file_suff) if os.path.isfile (test_file) : - file = open (test_file, "r") - les_lignes = file.readlines() - file.close() + with open (test_file, "r") as fichier : + les_lignes = fichier.readlines() else : mess_error = "\nResult file: " + test_file mess_error += "\nThis file does not exist.\n" @@ -164,7 +199,7 @@ def saveGeometry( xao_file, name, author="" ): #======================================================================== #======================================================================== # -def repositionnement (rep_calc, fic_med_brut, fic_med_new, xao_file, verbose=False) : +def repositionnement (rep_calc, fic_med_brut, fic_med_new, xao_file, menage=True, verbose=False) : # """ Pilote le repositionnement des noeuds qui ont bougé @@ -173,12 +208,14 @@ Entrées : fic_med_brut : fichier MED du calcul avec les coordonnées avant projection fic_med_new : fichier MED du calcul avec les coordonnées après projection xao_file : fichier XAO de la géométrie + menage : Suppression du fichier fic_med_brut """ if verbose : ligne = "rep_calc = %s" % rep_calc ligne += "\nfic_med_brut = %s" % fic_med_brut ligne += "\nfic_med_new = %s" % fic_med_new ligne += "\nxao_file = %s" % xao_file + ligne += "\nmenage = %d" % menage print(ligne) message = "" @@ -186,8 +223,6 @@ Entrées : while not erreur : # # 1. l_fr = liste des fichiers des lignes/surfaces a suivre -# Les fichiers des numéros de groupes par frontière sont renommés selon le support -# à condition de ne pas être vide. # fic_hom_med = None laux = os.listdir(rep_calc) @@ -197,33 +232,8 @@ Entrées : icpt_2D = 0 for fic in laux : #print "\t" + fic - if ( fic[:5] == 'fort.' ) : - fic_fort = os.path.join(rep_calc, fic) - fichier = open (fic_fort, "r") - les_lignes = fichier.readlines() - fichier.close() - os.remove(fic_fort) - a_faire = False - for ligne in les_lignes[1:] : - laux1 = ligne.split() - if ( len(laux1) >= 3 ) : - a_faire = True - break - if a_faire : - if ( "1D" in les_lignes[0] ) : - nomfic_bis = "fr1D.%02d" % icpt_1D - icpt_1D += 1 - else : - nomfic_bis = "fr2D.%02d" % icpt_2D - icpt_2D += 1 - fic_1 = os.path.join(rep_calc, nomfic_bis) - fichier = open (fic_1, "w") - for ligne in les_lignes[1:] : - if ( ( "1D" not in ligne ) and ( "2D" not in ligne ) ) : - fichier.write(ligne) - fichier.close() - #print "\t\tajout de %s" % fic_1 - l_fr.append(fic_1) + if ( fic[:2] == 'fr' ) : + l_fr.append(os.path.join(rep_calc, fic)) elif ( fic[-4:] == '.med' ) : fic_hom_med = os.path.join(rep_calc, fic) #print "\t\treperage de fic_hom_med =", fic_hom_med @@ -259,11 +269,14 @@ Entrées : #if erreur : #break # -# 2.3. Ménage de l'ancien fichier MED +# 2.3. Ménage éventuel de l'ancien fichier MED # - if ( fic_med_brut != fic_med_new ) : - print("Suppression du fichier %s" % fic_med_new) - os.remove(fic_med_brut) + if menage : +# + if ( fic_med_brut != fic_med_new ) : + if verbose : + print("Suppression du fichier %s" % fic_med_brut) + os.remove(fic_med_brut) # # 3. Renommage du fichier si aucun noeud n'est concerné # @@ -306,9 +319,8 @@ Entrées : # 1. Recherche des inforamtions permanentes dans le fichier de configuration # fic_conf = os.path.join(rep_calc, "HOMARD.Configuration") - fichier = open (fic_conf, "r") - les_lignes = fichier.readlines() - fichier.close() + with open (fic_conf, "r") as fichier : + les_lignes = fichier.readlines() # ligne0 = "" icpt = 0 @@ -336,22 +348,22 @@ Entrées : # 2. Création du fichier de configuration # fic_conf_sv = os.path.join(rep_calc, "HOMARD.Configuration.majc") - fichier = open (fic_conf_sv, "w") -# - ligne = ligne0 - ligne += "ModeHOMA 5\n" - fic = os.path.join(rep_calc, "Liste.%s.maj_coords.log" % s_iter) - ligne += "ListeStd %s\n" % fic - ligne += "CCMaiN__ %s\n" % fic_med_calc - ligne += "RepeTrav %s\n" % rep_calc - ligne += "RepeInfo %s\n" % rep_calc - ligne += "Action homa\n" - ligne += "CCAssoci med\n" - ligne += "EcriFiHO N_SANS_FRONTIERE\n" - ligne += "MessInfo 10\n" -# - fichier.write(ligne) - fichier.close() +# + with open (fic_conf_sv, "w") as fichier : +# + ligne = ligne0 + ligne += "ModeHOMA 5\n" + fic = os.path.join(rep_calc, "Liste.%s.maj_coords.log" % s_iter) + ligne += "ListeStd %s\n" % fic + ligne += "CCMaiN__ %s\n" % fic_med_calc + ligne += "RepeTrav %s\n" % rep_calc + ligne += "RepeInfo %s\n" % rep_calc + ligne += "Action homa\n" + ligne += "CCAssoci med\n" + ligne += "EcriFiHO N_SANS_FRONTIERE\n" + ligne += "MessInfo 10\n" +# + fichier.write(ligne) # # 3. Mise à jour # 3.1. Détermination de l'exécutable diff --git a/src/tests/Test/tutorial_1.py b/src/tests/Test/tutorial_1.py index 96a3868a..e8105bce 100755 --- a/src/tests/Test/tutorial_1.py +++ b/src/tests/Test/tutorial_1.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_1 associe au tutorial 1 """ -__revision__ = "V4.01" +__revision__ = "V4.04" #======================================================================== TEST_NAME = "tutorial_1" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,14 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_dir +from test_util import get_dir_tutorial 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() -# 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) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -67,70 +58,109 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" # - homard.UpdateStudy() - # - # Hypotheses - # ========== - hypo_1 = homard.CreateHypothesis('hypo_1') - hypo_1.SetUnifRefinUnRef(1) - # - # Cas - # === - case_1 = homard.CreateCase('case_1', 'MAILL', DATA_TUTORIAL+'/tutorial_1.00.med') - case_1.SetDirName(DIRCASE) + while not erreur : # - # Iterations - # ========== - # Iteration "iter_1_1" - iter_1_1 = case_1.NextIteration('iter_1_1') - iter_1_1.SetMeshName('MESH') - iter_1_1.SetMeshFile(DIRCASE+'/maill.01.med') - iter_1_1.AssociateHypo('hypo_1') - error = iter_1_1.Compute(1, 2) + HOMARD.UpdateStudy() + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + hypo_1 = HOMARD.CreateHypothesis('hypo_1') + hypo_1.SetUnifRefinUnRef(1) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_1', nom, ficmed) + le_cas.SetDirName(DIRCASE) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # Iteration "iter_1_1" + iter_1_1 = le_cas.NextIteration('iter_1_1') + iter_1_1.SetMeshName('MESH') + iter_1_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med")) + iter_1_1.AssociateHypo('hypo_1') + erreur = iter_1_1.Compute(1, option) + if erreur : + break - # 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.AssociateHypo('hypo_1') - error = iter_1_2.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(os.path.join(DIRCASE, "maill.01.med")) + iter_1_2.AssociateHypo('hypo_1') + erreur = iter_1_2.Compute(1, option) + if erreur : + break - # 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.AssociateHypo('hypo_1') - error = iter_1_3.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(os.path.join(DIRCASE, "maill.03.med")) + iter_1_3.AssociateHypo('hypo_1') + erreur = iter_1_3.Compute(1, option) + if erreur : + break # - return error - -#======================================================================== - -homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert homard is not None, "Impossible to load homard engine" -homard.SetLanguageShort("fr") + break + # + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur + # + return erreur, message # -# Exec of HOMARD-SALOME +#========================== Fin de la fonction ================================== # -try : - ERROR = homard_exec() - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) +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") # -# Test of the results + FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") + try: + ERREUR, MESSAGE = homard_exec("MAILL", FICMED, DEBUG) + except RuntimeError as eee: + ERREUR = 2 + MESSAGE = str(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 # -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) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 1, 1) diff --git a/src/tests/Test/tutorial_2.py b/src/tests/Test/tutorial_2.py index 585523c1..7f89207c 100755 --- a/src/tests/Test/tutorial_2.py +++ b/src/tests/Test/tutorial_2.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_2 associe au tutorial 2 """ -__revision__ = "V4.01" +__revision__ = "V4.04" #======================================================================== TEST_NAME = "tutorial_2" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,14 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_dir +from test_util import get_dir_tutorial 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() -# 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) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -67,81 +58,125 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" # - HOMARD.UpdateStudy() + while not erreur : + # + HOMARD.UpdateStudy() + # + # Creation des zones + # ================== + if verbose : + print(". Zones") + # Box "Zone_12_0" + zone_12_0 = HOMARD.CreateZoneBox ('Zone_12_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) + # + # Sphere "Zone_12_1" + zone_12_1 = HOMARD.CreateZoneSphere ('Zone_12_1', 0., 0., 0., 1.05) + # + # Box "Zone_12_2" + zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # Hypothese "hypo_2" + # ================== + hypo_2 = HOMARD.CreateHypothesis('hypo_2') + hypo_2.AddZone('Zone_12_1', 1) + hypo_2.AddZone('Zone_12_0', 1) + # + # Hypothese "hypo_2_bis" + # ====================== + hypo_2_bis = HOMARD.CreateHypothesis('hypo_2_bis') + hypo_2_bis.AddZone('Zone_12_0', -1) + hypo_2_bis.AddZone('Zone_12_2', 1) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_2', nom, ficmed) + le_cas.SetDirName(DIRCASE) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # + # 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, option) + if erreur : + break + # + # 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.01.med")) + iter_2_2.AssociateHypo('hypo_2_bis') + erreur = iter_2_2.Compute(1, option) + if erreur : + break # - # Creation des zones - # ================== - # Box "Zone_12_0" - zone_12_0 = HOMARD.CreateZoneBox ('Zone_12_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) + break # - # Sphere "Zone_12_1" - zone_12_1 = HOMARD.CreateZoneSphere ('Zone_12_1', 0., 0., 0., 1.05) + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur # - # Box "Zone_12_2" - zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) + return erreur, message +# +#========================== Fin de la fonction ================================== +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - # Hypothese "hypo_2" - # ================== - hypo_2 = HOMARD.CreateHypothesis('hypo_2') - hypo_2.AddZone('Zone_12_1', 1) - hypo_2.AddZone('Zone_12_0', 1) + # A. Exec of HOMARD-SALOME # - # Hypothese "hypo_2_bis" - # ====================== - hypo_2_bis = HOMARD.CreateHypothesis('hypo_2_bis') - hypo_2_bis.AddZone('Zone_12_0', -1) - hypo_2_bis.AddZone('Zone_12_2', 1) + 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, TEST_NAME+".00.med") + try: + ERREUR, MESSAGE = homard_exec("MZERO", FICMED, DEBUG) + except RuntimeError as eee: + ERREUR = 2 + MESSAGE = str(eee.message) # - # Cas - # === - case_2 = HOMARD.CreateCase('case_2', 'MZERO', DATA_TUTORIAL+'/tutorial_2.00.med') - case_2.SetDirName(DIRCASE) + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # 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) + # B. Test of the results # - # 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) + 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) # - return error - -#======================================================================== - -HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert HOMARD is not None, "Impossible to load HOMARD engine" -HOMARD.SetLanguageShort("fr") -# -# Exec of HOMARD-SALOME -# -try : - ERROR = homard_exec() - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + break # -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) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 2, 1) diff --git a/src/tests/Test/tutorial_3.py b/src/tests/Test/tutorial_3.py index d9b84371..ae8e1535 100755 --- a/src/tests/Test/tutorial_3.py +++ b/src/tests/Test/tutorial_3.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_3 associe au tutorial 3 """ -__revision__ = "V4.01" +__revision__ = "V4.04" #======================================================================== TEST_NAME = "tutorial_3" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,14 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_dir +from test_util import get_dir_tutorial 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() -# 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) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -67,110 +58,153 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" # - HOMARD.UpdateStudy() + while not erreur : + # + HOMARD.UpdateStudy() + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # Hypothese "hypo_0vers1" + # ======================= + hypo_0vers1 = HOMARD.CreateHypothesis('hypo_0vers1') + # Characterization of the field + hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________') + hypo_0vers1.SetUseComp(0) + hypo_0vers1.AddComp('ERREST ') + hypo_0vers1.SetRefinThr(3, 1.0) + hypo_0vers1.SetTypeFieldInterp(2) + hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________') + hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________') + # + # Hypothese "hypo_1vers2" + # ======================= + hypo_1vers2 = HOMARD.CreateHypothesis('hypo_1vers2') + # Characterization of the field + hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________') + hypo_1vers2.SetUseComp(0) + hypo_1vers2.AddComp('ERREST ') + hypo_1vers2.SetRefinThr(3, 1.5) + hypo_1vers2.SetUnRefThr(3, 6.) + hypo_1vers2.SetTypeFieldInterp(2) + hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________') + hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________') + # + # Hypothese "hypo_1vers2_bis" + # =========================== + hypo_1vers2_bis = HOMARD.CreateHypothesis('hypo_1vers2_bis') + # Characterization of the field + hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________') + hypo_1vers2_bis.SetUseComp(1) + hypo_1vers2_bis.AddComp('DX') + hypo_1vers2_bis.AddComp('DY') + hypo_1vers2_bis.AddComp('DZ') + hypo_1vers2_bis.SetRefinThr(1, 0.0001) + hypo_1vers2_bis.SetUnRefThr(1, 0.000001) + hypo_1vers2_bis.SetTypeFieldInterp(0) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_3', nom, ficmed) + le_cas.SetDirName(DIRCASE) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # Iteration "iter_3_1" + # ==================== + iter_3_1 = le_cas.NextIteration('iter_3_1') + iter_3_1.SetMeshName('H_1') + 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') + erreur = iter_3_1.Compute(1, option) + if erreur : + break + # + # Iteration "iter_3_2" + # ==================== + iter_3_2 = iter_3_1.NextIteration('iter_3_2') + iter_3_2.SetMeshName('H_2') + 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') + erreur = iter_3_2.Compute(1, option) + if erreur : + break + # + # 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(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') + erreur = iter_3_2_bis.Compute(1, option) + if erreur : + break # - # Hypothese "hypo_0vers1" - # ======================= - hypo_0vers1 = HOMARD.CreateHypothesis('hypo_0vers1') - # Characterization of the field - hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________') - hypo_0vers1.SetUseComp(0) - hypo_0vers1.AddComp('ERREST ') - hypo_0vers1.SetRefinThr(3, 1.0) - hypo_0vers1.SetTypeFieldInterp(2) - hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________') - hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________') + break # - # Hypothese "hypo_1vers2" - # ======================= - hypo_1vers2 = HOMARD.CreateHypothesis('hypo_1vers2') - # Characterization of the field - hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________') - hypo_1vers2.SetUseComp(0) - hypo_1vers2.AddComp('ERREST ') - hypo_1vers2.SetRefinThr(3, 1.5) - hypo_1vers2.SetUnRefThr(3, 6.) - hypo_1vers2.SetTypeFieldInterp(2) - hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________') - hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________') + 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 : # - # Hypothese "hypo_1vers2_bis" - # =========================== - hypo_1vers2_bis = HOMARD.CreateHypothesis('hypo_1vers2_bis') - # Characterization of the field - hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________') - hypo_1vers2_bis.SetUseComp(1) - hypo_1vers2_bis.AddComp('DX') - hypo_1vers2_bis.AddComp('DY') - hypo_1vers2_bis.AddComp('DZ') - hypo_1vers2_bis.SetRefinThr(1, 0.0001) - hypo_1vers2_bis.SetUnRefThr(1, 0.000001) - hypo_1vers2_bis.SetTypeFieldInterp(0) + # A. Exec of HOMARD-SALOME # - # Cas - # === - case_3 = HOMARD.CreateCase('case_3', 'G_0', DATA_TUTORIAL+'/tutorial_3.00.med') - case_3.SetDirName(DIRCASE) + 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, TEST_NAME+".00.med") + try: + ERREUR, MESSAGE = homard_exec("G_0", FICMED, DEBUG) + except RuntimeError as eee: + ERREUR = 2 + MESSAGE = str(eee.message) # - # Iteration "iter_3_1" - # ==================== - iter_3_1 = case_3.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.SetTimeStepRank( 1, 1) - iter_3_1.AssociateHypo('hypo_0vers1') - error = iter_3_1.Compute(1, 2) + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # 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.SetTimeStepRank(1, 1) - iter_3_2.AssociateHypo('hypo_1vers2') - error = iter_3_2.Compute(1, 2) + # B. Test of the results # - # 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.SetTimeStepRank(1, 1) - iter_3_2_bis.AssociateHypo('hypo_1vers2_bis') - error = iter_3_2_bis.Compute(1, 2) + N_REP_TEST_FILE = 3 + DESTROY_DIR = not DEBUG + test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) # - return error - -#======================================================================== - -HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert HOMARD is not None, "Impossible to load HOMARD engine" -HOMARD.SetLanguageShort("fr") -# -# Exec of HOMARD-SALOME -# -try : - ERROR = homard_exec() - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + break # -N_REP_TEST_FILE = 3 -DESTROY_DIR = not DEBUG -test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 3, 1) diff --git a/src/tests/Test/tutorial_4.py b/src/tests/Test/tutorial_4.py index 1853abe3..61ee052c 100755 --- a/src/tests/Test/tutorial_4.py +++ b/src/tests/Test/tutorial_4.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_4 associe au tutorial 4 """ -__revision__ = "V4.01" +__revision__ = "V5.03" #======================================================================== TEST_NAME = "tutorial_4" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,14 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_dir +from test_util import get_dir_tutorial 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() -# 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) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -67,97 +58,136 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, xao_file, verbose=True): """ Python script for HOMARD """ - # - HOMARD.UpdateStudy() + erreur = 0 + message = "" # - # Frontieres - # ========== - boun_4_1 = HOMARD.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med') + while not erreur : + # + HOMARD.UpdateStudy() + # + # Frontières + # ========== + if verbose : + print(". Frontières") + cao_name = "CAO_" + nom + la_frontiere = HOMARD.CreateBoundaryCAO(cao_name, xao_file) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # Creation of the hypothesis hypo_0_1 + l_hypothese_0_1 = HOMARD.CreateHypothesis('hypo_4_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_4_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_4_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(cao_name) + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # 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_0_1') + erreur = iter_4_1.Compute(1, option) + print ("erreur = %d" % erreur) + if erreur : + break + # 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_1_2') + erreur = iter_4_2.Compute(1, option) + if erreur : + break + # 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_2_3') + erreur = iter_4_3.Compute(1, option) + if erreur : + break # - boun_4_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) + break # - boun_4_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.) + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur # - boun_4_4 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.) + return erreur, message +# +#========================== Fin de la fonction ================================== +# +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - boun_4_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.) + # A. Exec of HOMARD-SALOME # - # 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') - # 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') + 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") + XAO_FILE = os.path.join(DATA_TUTORIAL, TEST_NAME+".xao") + try: + ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, XAO_FILE, DEBUG) + except RuntimeError as eee: + ERREUR = 2 + MESSAGE = str(eee.message) # - # 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' ) + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # Iterations - # ========== - # Iteration iter_4_1 : raffinement selon les faces internes - iter_4_1 = case_4.NextIteration('iter_4_1') - iter_4_1.SetMeshName('PIQUAGE_1') - iter_4_1.SetMeshFile(DIRCASE+'/maill.01.med') - iter_4_1.AssociateHypo('hypo_4') - error = 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.AssociateHypo('hypo_4_bis') - error = 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.AssociateHypo('hypo_4_bis') - error = iter_4_3.Compute(1, 2) + # B. Test of the results # - return error - -#======================================================================== - -HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert HOMARD is not None, "Impossible to load HOMARD engine" -HOMARD.SetLanguageShort("fr") -# -# Exec of HOMARD-SALOME -# -try : - ERROR = homard_exec() - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# 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 # -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) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 4, 1) diff --git a/src/tests/Test/tutorial_5.py b/src/tests/Test/tutorial_5.py index 00234d92..499a195f 100755 --- a/src/tests/Test/tutorial_5.py +++ b/src/tests/Test/tutorial_5.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_5 associe au tutorial 5 """ -__revision__ = "V4.01" +__revision__ = "V4.04" #======================================================================== TEST_NAME = "tutorial_5" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,14 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 get_dir +from test_util import get_dir_tutorial 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() -# 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) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -67,81 +58,126 @@ import iparameters IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) IPAR.append("AP_MODULES_LIST", "Homard") # -#======================================================================== -#======================================================================== -def homard_exec(): +# +#========================= Debut de la fonction ================================== +# +def homard_exec(nom, ficmed, nomfr, ficfrmed, verbose=False): """ Python script for HOMARD """ + erreur = 0 + message = "" +# + while not erreur : + # + HOMARD.UpdateStudy() + # + # Frontiere + # ========= + if verbose : + print(". Frontière") + # Creation of the discrete boundary Boun_5_1 + boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', nomfr, ficfrmed) + # + # Creation des zones + # ================== + if verbose : + print(". 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 ) + # + # Hypotheses + # ========== + if verbose : + print(". Hypothèses") + # 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) + # + # Cas + # === + if verbose : + print(". Cas") + le_cas = HOMARD.CreateCase('case_5', nom, ficmed) + le_cas.SetDirName(DIRCASE) + le_cas.SetConfType(1) + le_cas.AddBoundary('Boun_5_1') + # + # Itérations + # ========== + if verbose : + option = 2 + else : + option = 1 + if verbose : + print(". Itérations") + # + # 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, option) + if erreur : + break + # + # 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, option) + if erreur : + break + # + break + # + if erreur : + message += "Erreur au calcul de l'itération %d" % erreur # - HOMARD.UpdateStudy() + return erreur, message + +#========================== Fin de la fonction ================================== # - # Frontiere - # ========= - # Creation of the discrete boundary Boun_5_1 - boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med') +ERREUR = 0 +MESSAGE = "" +while not ERREUR : # - # 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 ) + # A. Exec of HOMARD-SALOME # - # 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) + 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, TEST_NAME+".00.med") + FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med") + try: + ERREUR, MESSAGE = homard_exec("COEUR_2D", FICMED, "MAIL_EXT", FICFRMED, DEBUG) + except RuntimeError as eee: + ERREUR = 2 + MESSAGE = str(eee.message) # - # Cas - # === - case_5 = HOMARD.CreateCase('case_5', 'COEUR_2D', DATA_TUTORIAL+'/tutorial_5.00.med') - case_5.SetDirName(DIRCASE) - case_5.SetConfType(1) - case_5.AddBoundaryGroup('Boun_5_1', '') + if ERREUR : + MESSAGE += "Pb in homard_exec" + break # - # Iteration "iter_5_1" - # ==================== - iter_5_1 = case_5.NextIteration('iter_5_1') - iter_5_1.SetMeshName('COEUR_2D_01') - iter_5_1.SetMeshFile(DIRCASE+'/maill.01.med') - iter_5_1.AssociateHypo('hypo_5') - error = iter_5_1.Compute(1, 2) + # B. Test of the results # - # 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(DIRCASE+'/maill.02.med') - iter_5_2.AssociateHypo('hypo_5_bis') - error = iter_5_2.Compute(1, 2) + 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) # - return error - -#======================================================================== - -HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') -assert HOMARD is not None, "Impossible to load HOMARD engine" -HOMARD.SetLanguageShort("fr") -# -# Exec of HOMARD-SALOME -# -try : - ERROR = homard_exec() - if ERROR : - raise Exception('Pb in homard_exec at iteration %d' %ERROR ) -except Exception as eee: - raise Exception('Pb in homard_exec: '+eee.message) -# -# Test of the results + break # -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) +if ERREUR: + raise Exception(MESSAGE) # # ================================== gzip_gunzip(DATA_TUTORIAL, 5, 1) diff --git a/src/tests/Test/tutorial_6.py b/src/tests/Test/tutorial_6.py new file mode 100755 index 00000000..433a7c84 --- /dev/null +++ b/src/tests/Test/tutorial_6.py @@ -0,0 +1,214 @@ +# -*- 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.04" + +#======================================================================== +TEST_NAME = "tutorial_6" +DEBUG = False +N_ITER_TEST_FILE = 3 +#======================================================================== +import os +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 get_dir +from test_util import get_dir_tutorial +from test_util import test_results +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD) +# ================================== +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.UpdateStudy() + # + # 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 RuntimeError as eee: + ERREUR = 2 + MESSAGE = str(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() + iparameters.getSession().restoreVisualState(1) + diff --git a/src/tests/samples/test_6.apad.03.bilan b/src/tests/samples/test_6.apad.03.bilan new file mode 100755 index 00000000..bfa20c29 --- /dev/null +++ b/src/tests/samples/test_6.apad.03.bilan @@ -0,0 +1,53 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + test_6 + Date de creation : jeudi 4 janvier 2018 a 14 h 20 mn 19 s + Dimension : 3 + Degre : 1 + C'est un maillage obtenu apres 3 adaptations. + Le niveau minimum actif est : 3 + Le niveau maximum atteint est : 3 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + | | 0.0000 | 169.52 + | | -50.434 | 100.00 + | | 0.0000 | 200.00 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 6441 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 336 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 336 * + * . dont aretes internes aux faces/volumes * 0 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 12544 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 0.5 * 0 * + * . du niveau 1 * 0 * + * . du niveau 1.5 * 0 * + * . du niveau 2 * 0 * + * . du niveau 2.5 * 0 * + * . du niveau 3 * 12544 * + ************************************************************ diff --git a/src/tests/samples/tutorial_4.apad.03.bilan b/src/tests/samples/tutorial_4.apad.03.bilan index 45a987dc..4325d63e 100644 --- a/src/tests/samples/tutorial_4.apad.03.bilan +++ b/src/tests/samples/tutorial_4.apad.03.bilan @@ -5,7 +5,7 @@ ANALYSE DU MAILLAGE Maillage apres adaptation PIQUAGE - Date de creation : lundi 2 novembre 2015 a 9 h 13 mn 13 s + Date de creation : jeudi 4 janvier 2018 a 14 h 7 mn 55 s Dimension : 3 Degre : 1 C'est un maillage obtenu apres 3 adaptations. @@ -14,9 +14,9 @@ ANALYSE DU MAILLAGE Direction | Unite | Minimum | Maximum --------------------------------------------------------------- - | | -230.00 | 136.45 - | | -250.62 | 189.69 - | | -285.21 | 155.03 + | | -230.00 | 136.04 + | | -250.19 | 188.38 + | | -285.20 | 154.14 NOMBRE D'ENTITES DU CALCUL @@ -26,40 +26,40 @@ ANALYSE DU MAILLAGE ************************************************************ * Noeuds * ************************************************************ - * Nombre total * 12825 * + * Nombre total * 3040 * ************************************************************ ************************************************************ * Segments * ************************************************************ - * Nombre total * 758 * + * Nombre total * 452 * * . dont aretes isolees * 0 * * . dont aretes de bord de regions 2D * 0 * - * . dont aretes internes aux faces/volumes * 758 * + * . dont aretes internes aux faces/volumes * 452 * ************************************************************ ************************************************************ * Triangles * ************************************************************ - * Nombre total * 20838 * + * Nombre total * 4562 * * . dont triangles de regions 2D * 0 * - * . dont triangles de bord * 20560 * - * . dont triangles internes aux volumes * 278 * + * . dont triangles de bord * 4418 * + * . dont triangles internes aux volumes * 144 * ************************************************************ * . du niveau 0 * 0 * * . du niveau 0.5 * 0 * - * . du niveau 1 * 3530 * - * . du niveau 1.5 * 380 * - * . du niveau 2 * 16928 * + * . du niveau 1 * 3526 * + * . du niveau 1.5 * 316 * + * . du niveau 2 * 720 * ************************************************************ ************************************************************ * Tetraedres * ************************************************************ - * Nombre total * 43490 * + * Nombre total * 11214 * ************************************************************ * . du niveau 0 * 0 * * . du niveau 0.5 * 0 * - * . du niveau 1 * 18174 * - * . du niveau 1.5 * 25316 * + * . du niveau 1 * 9930 * + * . du niveau 1.5 * 1284 * ************************************************************ diff --git a/src/tests/samples/tutorial_6.apad.03.bilan b/src/tests/samples/tutorial_6.apad.03.bilan new file mode 100755 index 00000000..452d42aa --- /dev/null +++ b/src/tests/samples/tutorial_6.apad.03.bilan @@ -0,0 +1,65 @@ + + +ANALYSE DU MAILLAGE +=================== + + Maillage apres adaptation + PIQUAGE + Date de creation : lundi 25 septembre 2017 a 13 h 52 mn 40 s + Dimension : 3 + Degre : 1 + C'est un maillage obtenu apres 3 adaptations. + Le niveau minimum actif est : 1 + Le niveau maximum atteint est : 2 + + Direction | Unite | Minimum | Maximum + --------------------------------------------------------------- + | | -230.00 | 136.04 + | | -250.52 | 189.69 + | | -285.20 | 155.02 + + + NOMBRE D'ENTITES DU CALCUL + ========================== + + + ************************************************************ + * Noeuds * + ************************************************************ + * Nombre total * 3040 * + ************************************************************ + + ************************************************************ + * Segments * + ************************************************************ + * Nombre total * 452 * + * . dont aretes isolees * 0 * + * . dont aretes de bord de regions 2D * 0 * + * . dont aretes internes aux faces/volumes * 452 * + ************************************************************ + + ************************************************************ + * Triangles * + ************************************************************ + * Nombre total * 4562 * + * . dont triangles de regions 2D * 0 * + * . dont triangles de bord * 4418 * + * . dont triangles internes aux volumes * 144 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 0.5 * 0 * + * . du niveau 1 * 3526 * + * . du niveau 1.5 * 316 * + * . du niveau 2 * 720 * + ************************************************************ + + ************************************************************ + * Tetraedres * + ************************************************************ + * Nombre total * 11214 * + ************************************************************ + * . du niveau 0 * 0 * + * . du niveau 0.5 * 0 * + * . du niveau 1 * 9930 * + * . du niveau 1.5 * 1284 * + ************************************************************