Salome HOME
Mise à jour SHAPER et medcoupling
authorGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Tue, 5 Jan 2021 16:07:55 +0000 (17:07 +0100)
committerGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Tue, 5 Jan 2021 16:07:55 +0000 (17:07 +0100)
src/tests/Test/test_4.py
src/tests/Test/test_5.py
src/tests/Test/test_6.py
src/tests/samples/test_4.apad.02.bilan
src/tests/samples/test_4.apad.03.bilan
src/tests/samples/test_6.apad.03.bilan

index 24e4d77ff458c7036aa3394386a6decc255f7111..7fd02fa27bef6e043474f7615b5b7f8b3e430b2a 100755 (executable)
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-"""
-Python script for HOMARD
-Test test_4
-"""
-__revision__ = "V3.04"
+"""Python script for HOMARD - Test test_4"""
+__revision__ = "V4.01"
 
-#========================================================================
-TEST_NAME = "test_4"
-DEBUG = False
-N_ITER_TEST_FILE = 3
-DX = 600.
-DY = 400.
-DZ = 200.
-#========================================================================
 import os
 import sys
 import numpy as np
+
 import salome
-import GEOM
+import SHAPERSTUDY
 import SMESH
 import HOMARD
-import MEDCoupling as mc
+import medcoupling as mc
 import MEDLoader as ml
-#
+
+from salome.shaper import model
+from salome.smesh import smeshBuilder
+from MEDCouplingRemapper import MEDCouplingRemapper
+
 # ==================================
 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
 # Repertoire des scripts utilitaires
@@ -50,101 +44,112 @@ sys.path.append(REP_PYTHON)
 from test_util import get_dir
 from test_util import test_results
 # ==================================
+
+#========================================================================
+TEST_NAME = "test_4"
+DEBUG = False
+N_ITER_TEST_FILE = 3
+DX = 600.
+DY = 400.
+DZ = 200.
 # Répertoires pour ce test
 REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
-# ==================================
+#========================================================================
 
 salome.salome_init()
 
-import SALOMEDS
-from salome.geom import geomBuilder
-from salome.smesh import smeshBuilder
-from salome.StdMeshers import StdMeshersBuilder
-#
-from MEDCouplingRemapper import MEDCouplingRemapper
+#========================================================================
+def create_cao_smesh ():
+  """CAO and mesh"""
 
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
+  structure_sh = create_cao ()
+
+  error, mesh_file = create_mesh (structure_sh)
+
+  return error, mesh_file
 #========================================================================
+
 #========================================================================
-def geom_smesh_exec():
-  """
-Python script for GEOM and SMESH
-  """
+def create_cao ():
+  """CAO"""
+
+  model.begin()
+  partset = model.moduleDocument()
+
+  part_1 = model.addPart(partset)
+  part_1_doc = part_1.document()
+
+  structure_sh = model.addBox(part_1_doc, DX, DY, DZ,)
+  structure_sh.setName(TEST_NAME)
+  structure_sh.result().setName(TEST_NAME)
+
+  model.end()
+
+  return structure_sh
+#========================================================================
+
+#========================================================================
+def create_mesh (structure_sh):
+  """Mesh"""
   error = 0
-#
+  mesh_file = os.path.join(DIRCASE, 'maill.00.med')
   while not error :
-  #
-    geompy = geomBuilder.New()
-  #
-  # Creation of the box
-  # ===================
-    box_g = geompy.MakeBoxDXDYDZ(DX, DY, DZ, "BOX")
-
-  # Creation of the mesh
-  # ====================
+
+# 1. Importation to the study
+# ===========================
+    model.publishToShaperStudy()
+    l_aux = SHAPERSTUDY.shape(model.featureStringId(structure_sh))
+
+# 2. Creation of the mesh
+# =======================
     smesh = smeshBuilder.New()
-    box_m = smesh.Mesh(box_g)
-    smesh.SetName(box_m.GetMesh(), 'MESH')
-  #
-  # Creation of the hypotheses
-  # ==========================
-    regular_1d = box_m.Segment()
+    structure_m = smesh.Mesh(l_aux[0])
+
+# Creation of the hypotheses
+    regular_1d = structure_m.Segment()
     smesh.SetName(regular_1d.GetAlgorithm(), 'Regular_1D')
     length = min(DX, DY, DZ) / 5.
     local_length = regular_1d.LocalLength(length, None, 1e-07)
     smesh.SetName(local_length, 'Local Length')
-  #
-    quadrangle_2d = box_m.Quadrangle(algo=smeshBuilder.QUADRANGLE)
+
+    quadrangle_2d = structure_m.Quadrangle(algo=smeshBuilder.QUADRANGLE)
     smesh.SetName(quadrangle_2d.GetAlgorithm(), 'Quadrangle_2D')
-    quadrangle_parameters = quadrangle_2d.QuadrangleParameters(StdMeshersBuilder.QUAD_STANDARD, -1, [], [])
-    smesh.SetName(quadrangle_parameters, 'Quadrangle Parameters')
-  #
-    hexa_3d = box_m.Hexahedron(algo=smeshBuilder.Hexa)
+
+    hexa_3d = structure_m.Hexahedron(algo=smeshBuilder.Hexa)
     smesh.SetName(hexa_3d.GetAlgorithm(), 'Hexa_3D')
-  #
-  # Computation
-  # ===========
-  #
-    isDone = box_m.Compute()
+
+# Computation
+    isDone = structure_m.Compute()
     if not isDone :
       error = 1
       break
-  #
-  # MED exportation
-  # ===============
-  #
+
+# MED exportation
     try:
-      ficmed = os.path.join(DIRCASE, 'maill.00.med')
-      box_m.ExportMED(ficmed)
+      structure_m.ExportMED(mesh_file)
     except IOError as eee:
       error = 2
       raise Exception('ExportMED() failed. ' + str(eee))
-  #
+
     break
-  #
-  return error
 
+  return error, mesh_file
 #========================================================================
-#
+
 #========================================================================
 def field_exec(niter):
-  """
-Python script for MEDCoupling
-  """
+  """Python script for MEDCoupling"""
   error = 0
-#
+
   while not error :
-  #
-  # The mesh
-  # ========
+
+# 1. The mesh
+# ===========
     ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter)
     meshMEDFileRead = ml.MEDFileMesh.New(ficmed)
     meshRead0 = meshMEDFileRead.getMeshAtLevel(0)
-  # Valeurs of the field
-  # ====================
+# 2. Values of the field
+# ======================
     nbNodes = meshRead0.getNumberOfNodes()
     valeur = mc.DataArrayDouble(nbNodes)
     for iaux, taux in enumerate(meshRead0.getCoords()) :
@@ -157,108 +162,140 @@ Python script for MEDCoupling
       valeur[iaux] = 1.e0 / max ( 1.e-5, np.sqrt(distance) )
     #print ". valeur", valeur
     nparr = valeur.toNumPyArray()
-    print(". mini/maxi", nparr.min(), nparr.max())
-  #
-  # Creation of the field
-  # =====================
+    print(". mini/maxi {}/{}".format(nparr.min(),nparr.max()))
+
+# 3. Creation of the field
+# ========================
     field = ml.MEDCouplingFieldDouble(ml.ON_NODES, ml.ONE_TIME)
     field.setArray(valeur)
     field.setMesh(meshRead0)
     field.setName("DISTANCE")
-  #
+
     fMEDFile_ch = ml.MEDFileField1TS()
     fMEDFile_ch.setFieldNoProfileSBT(field)     # No profile desired on the field, Sort By Type
     fMEDFile_ch.write(ficmed, 0) # 0 to indicate that we *append* (and no overwrite) to the MED file
-  #
+
     break
-  #
+
   return error
 
 #========================================================================
+
 #========================================================================
-def homard_exec():
-  """
-Python script for HOMARD
-  """
+def homard_exec(mesh_file):
+  """Python script for HOMARD"""
   error = 0
-#
+
   while not error :
-  #
-  #  HOMARD.UpdateStudy()
-  #
-  # Creation of the zones
-  # =====================
-  #
+
+# 1. Creation of the zones
+# ========================
+# Creation of the box zone_4_1
     epsilon = min(DX, DY, DZ) / 100.
-  # Creation of the box zone_4_1
-    zone_4_1 = HOMARD.CreateZoneBox('Zone_4_1', -epsilon, DX/3.+epsilon, DY/4.-epsilon, 3.*DY/4.+epsilon, 4.*DZ/5.-epsilon, DZ+epsilon)
+    _ = HOMARD.CreateZoneBox('Zone_4_1', -epsilon, DX/3.+epsilon, DY/4.-epsilon, 3.*DY/4.+epsilon, 4.*DZ/5.-epsilon, DZ+epsilon)
 
-  # Creation of the sphere zone_4_2
+# Creation of the sphere zone_4_2
     rayon = min(DX, DY, DZ) / 4.
-    zone_4_2 = HOMARD.CreateZoneSphere('Zone_4_2', DX/3., DY*0.3, DZ*0.6, rayon)
-  #
-  # Creation of the hypotheses
-  # ==========================
-    dico = {}
+    _ = HOMARD.CreateZoneSphere('Zone_4_2', DX/3., DY*0.3, DZ*0.6, rayon)
+
+# 2. Creation of the hypotheses
+# =============================
+    error, hyponame = homard_exec_hypo ()
+    if error :
+      break
+
+# 3. Creation of the cases
+# ========================
+    # Creation of the case
+    print("-------- Creation of the case {}".format(TEST_NAME))
+    case_test_4 = HOMARD.CreateCase(TEST_NAME, TEST_NAME, mesh_file)
+    case_test_4.SetDirName(DIRCASE)
+
+# 4. Creation of the iterations
+# =============================
+    error = homard_exec_iter(case_test_4, hyponame)
+
+    break
+
+  return error
+
+#========================================================================
+
+#========================================================================
+def homard_exec_hypo():
+  """Python script for HOMARD - Creation of the hypotheses"""
+
+  error = 0
+  while not error :
+
+    dico = dict()
     dico["1"] = "raffinement"
     dico["-1"] = "deraffinement"
-  # Creation of the hypothesis hypo_4_1
-    hyponame_1 = "Zone_1"
-    print("-------- Creation of the hypothesis", hyponame_1)
-    hypo_4_1 = HOMARD.CreateHypothesis(hyponame_1)
+    hyponame = list()
+
+# 1. Creation of the hypothesis hypo_4_1
+# ======================================
+    hyponame.append("Zone_1")
+    print("-------- Creation of the hypothesis {}".format(hyponame[0]))
+    hypo_4_1 = HOMARD.CreateHypothesis(hyponame[0])
     hypo_4_1.AddZone('Zone_4_1', 1)
     hypo_4_1.SetExtraOutput(2)
     laux = hypo_4_1.GetZones()
     nbzone = len(laux) // 2
     jaux = 0
     for _ in range(nbzone) :
-      print(hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
+      print(hyponame[0], " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
       jaux += 2
-  # Creation of the hypothesis hypo_4_2
-    hyponame_2 = "Zone_2"
-    print("-------- Creation of the hypothesis", hyponame_2)
-    hypo_4_2 = HOMARD.CreateHypothesis(hyponame_2)
+# 2. Creation of the hypothesis hypo_4_2
+# ======================================
+    hyponame.append("Zone_2")
+    print("-------- Creation of the hypothesis {}".format(hyponame[1]))
+    hypo_4_2 = HOMARD.CreateHypothesis(hyponame[1])
     hypo_4_2.AddZone('Zone_4_2', 1)
     hypo_4_2.SetExtraOutput(2)
     laux = hypo_4_2.GetZones()
     nbzone = len(laux) // 2
     jaux = 0
     for _ in range(nbzone) :
-      print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
+      print(hyponame[1], " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
       jaux += 2
-  # Creation of the hypothesis DISTANCE INVERSE
-    hyponame_3 = "DISTANCE INVERSE"
-    print("-------- Creation of the hypothesis", hyponame_3)
-    hypo_4_3 = HOMARD.CreateHypothesis(hyponame_3)
+# 3. Creation of the hypothesis DISTANCE INVERSE
+# ==============================================
+    hyponame.append("DISTANCE INVERSE")
+    print("-------- Creation of the hypothesis {}".format(hyponame[2]))
+    hypo_4_3 = HOMARD.CreateHypothesis(hyponame[2])
     hypo_4_3.SetField('DISTANCE')
     hypo_4_3.SetUseComp(0)
     hypo_4_3.SetRefinThr(1, 0.3)
     hypo_4_3.SetUnRefThr(1, 0.2)
     hypo_4_3.AddFieldInterp('DISTANCE')
     hypo_4_3.SetExtraOutput(2)
-    print(hyponame_3, " : zones utilisées :", hypo_4_3.GetZones())
-    print(hyponame_3, " : champ utilisé :", hypo_4_3.GetFieldName())
-    print(hyponame_3, " : composantes utilisées :", hypo_4_3.GetComps())
-    if ( len (hypo_4_3.GetFieldName()) > 0 ) :
-      print(".. caractéristiques de l'adaptation :", hypo_4_3.GetField())
-    print(hyponame_3, " : champs interpolés :", hypo_4_3.GetFieldInterps())
-  #
-  # Creation of the cases
-  # =====================
-    # Creation of the case
-    print("-------- Creation of the case", TEST_NAME)
-    mesh_file = os.path.join(DIRCASE, 'maill.00.med')
-    case_test_4 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
-    case_test_4.SetDirName(DIRCASE)
-  #
-  # Creation of the iterations
-  # ==========================
-  # Creation of the iteration 1
+    print(hyponame[2], " : zones utilisées : {}".format(hypo_4_3.GetZones()))
+    print(hyponame[2], " : champ utilisé : {}".format(hypo_4_3.GetFieldName()))
+    print(hyponame[2], " : composantes utilisées : {}".format(hypo_4_3.GetComps()))
+    if len (hypo_4_3.GetFieldName()):
+      print(".. caractéristiques de l'adaptation : {}".format(hypo_4_3.GetField()))
+    print(hyponame[2], " : champs interpolés : {}".format(hypo_4_3.GetFieldInterps()))
+
+    break
+
+  return error, hyponame
+
+#========================================================================
+
+#========================================================================
+def homard_exec_iter(case_test_4, hyponame):
+  """Python script for HOMARD - Creation of the iterations"""
+
+  error = 0
+  while not error :
+
+# 1. Creation of the iteration 1
     iter_name = "I_" + TEST_NAME + "_1"
     print("-------- Creation of the iteration", iter_name)
     iter_test_4_1 = case_test_4.NextIteration(iter_name)
-    iter_test_4_1.AssociateHypo(hyponame_1)
-    print(". Hypothese :", hyponame_1)
+    iter_test_4_1.AssociateHypo(hyponame[0])
+    print(". Hypothese :", hyponame[0])
     iter_test_4_1.SetMeshName('M1')
     iter_test_4_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
     error = iter_test_4_1.Compute(1, 2)
@@ -266,12 +303,12 @@ Python script for HOMARD
       error = 1
       break
 
-  # Creation of the iteration 2
+# 2. Creation of the iteration 2
     iter_name = "I_" + TEST_NAME + "_2"
     print("-------- Creation of the iteration", iter_name)
     iter_test_4_2 = iter_test_4_1.NextIteration(iter_name)
-    iter_test_4_2.AssociateHypo(hyponame_2)
-    print(". Hypothese :", hyponame_2)
+    iter_test_4_2.AssociateHypo(hyponame[1])
+    print(". Hypothese :", hyponame[1])
     iter_test_4_2.SetMeshName('M2')
     iter_test_4_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
     error = iter_test_4_2.Compute(1, 2)
@@ -279,18 +316,18 @@ Python script for HOMARD
       error = 2
       break
 
-  # Creation of the iteration 3
-  #
+# 3. Creation of the iteration 3
+
     error = field_exec(2)
     if error :
       error = 30
       break
-  #
+
     iter_name = "I_" + TEST_NAME + "_3"
     print("-------- Creation of the iteration", iter_name)
     iter_test_4_3 = iter_test_4_2.NextIteration(iter_name)
-    iter_test_4_3.AssociateHypo(hyponame_3)
-    print(". Hypothese :", hyponame_3)
+    iter_test_4_3.AssociateHypo(hyponame[2])
+    print(". Hypothese :", hyponame[2])
     iter_test_4_3.SetMeshName('M3')
     iter_test_4_3.SetFieldFile(os.path.join(DIRCASE, 'maill.02.med'))
     iter_test_4_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
@@ -298,42 +335,40 @@ Python script for HOMARD
     if error :
       error = 3
       break
-  #
+
     break
-  #
+
   return error
 
 #========================================================================
-#
-# Geometry and Mesh
-#
+
+# CAO and Mesh
+
 try :
-  ERROR = geom_smesh_exec()
+  ERROR, MESH_FILE = create_cao_smesh()
   if ERROR :
-    raise Exception('Pb in geom_smesh_exec')
+    raise Exception('Pb in create_cao_smesh')
 except RuntimeError as eee:
-  raise Exception('Pb in geom_smesh_exec: '+str(eee.message))
+  raise Exception('Pb in create_cao_smesh: '+str(eee.message))
 
 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()
+  ERROR = homard_exec(MESH_FILE)
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
 except RuntimeError as eee:
   raise Exception('Pb in homard_exec: '+str(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)
-#
+
 if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser()
-  iparameters.getSession().restoreVisualState(1)
-
index 04c21a5e7167ce95ac18a482a1dd7d43db0f57d6..9d6bd79c1ddcc95b5608f2d97e956621034af2fc 100755 (executable)
@@ -22,29 +22,17 @@ Python script for HOMARD
 Specific conditions for Code_Saturne
 Test test_5
 """
-__revision__ = "V2.04"
+__revision__ = "V2.05"
 
-#========================================================================
-TEST_NAME = "test_5"
-DEBUG = False
-VERBOSE = True
-N_ITER_TEST_FILE = 3
-NBCELL_X = 10
-NBCELL_Y = 10
-NBCELL_Z = 10
-LG_X = 360.
-LG_Y = 240.
-LG_Z = 160.
-MESH_NAME = "MESH"
-#========================================================================
 import os
 import sys
 import numpy as np
+
 import salome
 import HOMARD
-import MEDCoupling as mc
+import medcoupling as mc
 import MEDLoader as ml
-#
+
 # ==================================
 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
 # Repertoire des scripts utilitaires
@@ -54,44 +42,48 @@ sys.path.append(REP_PYTHON)
 from test_util import get_dir
 from test_util import test_results
 # ==================================
+
+#========================================================================
+TEST_NAME = "test_5"
+DEBUG = False
+VERBOSE = False
+N_ITER_TEST_FILE = 3
+NBCELL_X = 10
+NBCELL_Y = 10
+NBCELL_Z = 10
+LG_X = 360.
+LG_Y = 240.
+LG_Z = 160.
+MESH_NAME = "MESH"
 # Répertoires pour ce test
 REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
-# ==================================
+#========================================================================
 
 salome.salome_init()
-#
-from MEDCouplingRemapper import MEDCouplingRemapper
 
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
 #========================================================================
 def mesh_exec():
-  """
-Python script for MED
-  """
+  """Python script for MED"""
   error = 0
-#
+
   while not error :
-  #
-  # Creation of the mesh
-  # ====================
+
+# Creation of the mesh
+# ====================
     maillage_3d = ml.MEDCouplingUMesh(MESH_NAME, 2)
     maillage_3d.setMeshDimension(3)
-  #
-  # Creation of the nodes
-  # ====================
-  #
+
+# Creation of the nodes
+# ====================
+
     nbno_x = NBCELL_X + 1
     nbno_y = NBCELL_Y + 1
     nbno_z = NBCELL_Z + 1
-#
+
     delta_x = LG_X / float(NBCELL_X)
     delta_y = LG_Y / float(NBCELL_Y)
     delta_z = LG_Z / float(NBCELL_Z)
-#
+
     coordinates = list()
     coo_z = -0.5*LG_Z
     for _ in range(nbno_z) :
@@ -105,55 +97,54 @@ Python script for MED
           coo_x += delta_x
         coo_y += delta_y
       coo_z += delta_z
-#
-    nbr_nodes = nbno_x*nbno_y*nbno_z
-    les_coords = ml.DataArrayDouble(coordinates, nbr_nodes, 3)
+
+    nbno = nbno_x*nbno_y*nbno_z
+    les_coords = ml.DataArrayDouble(coordinates, nbno, 3)
     maillage_3d.setCoords(les_coords)
-  #
-  # Creation of the cells
-  # =====================
-  #
+
+# Creation of the cells
+# =====================
+
     nbr_cell_3d = NBCELL_X*NBCELL_Y*NBCELL_Z
     maillage_3d.allocateCells(nbr_cell_3d)
-#
+
     decala_z = nbno_x*nbno_y
 #   kaux = numero de la tranche en z
     for kaux in range(1, nbno_z) :
-#
+
       #print ". Tranche en z numero %d" % kaux
       decala = decala_z*(kaux-1)
 #     jaux = numero de la tranche en y
       for jaux in range(1, nbno_y) :
-#
+
         #print ". Tranche en y numero %d" % jaux
 #       iaux = numero de la tranche en x
         for iaux in range(1, nbno_x) :
-#
+
           #print ". Tranche en x numero %d" % iaux
           nref = decala+iaux-1
           laux = [nref, nref+nbno_x, nref+1+nbno_x, nref+1, nref+decala_z, nref+nbno_x+decala_z, nref+1+nbno_x+decala_z, nref+1+decala_z]
-          #if self.verbose_max :
-            #if ( ( iaux==1 and jaux==1 and kaux==1 ) or ( iaux==(nbr_nodes_x-1) and jaux==(nbr_nodes_y-1) and kaux==(nbr_nodes_z-1) ) ) :
-              #print ". Maille %d : " % (iaux*jaux*kaux), laux
+          if VERBOSE:
+            if ( ( iaux==1 and jaux==1 and kaux==1 ) or ( iaux==(nbno_x-1) and jaux==(nbno_y-1) and kaux==(nbno_z-1) ) ) :
+              print (". Maille {} : {}".format((iaux*jaux*kaux),laux))
           maillage_3d.insertNextCell(ml.NORM_HEXA8, 8, laux)
-#
+
         decala += nbno_x
-#
+
     maillage_3d.finishInsertingCells()
-  #
-  # Agregation into a structure of MEDLoader
-  # ========================================
-  #
+
+# Agregation into a structure of MEDLoader
+# ========================================
+
     meshMEDFile3D = ml.MEDFileUMesh()
     meshMEDFile3D.setName(MESH_NAME)
-#
+
     meshMEDFile3D.setMeshAtLevel(0, maillage_3d)
-#
+
     meshMEDFile3D.rearrangeFamilies()
-  #
-  # MED exportation
-  # ===============
-  #
+
+# MED exportation
+# ===============
     try:
       ficmed = os.path.join(DIRCASE, 'maill.00.med')
       #print "Ecriture du maillage dans le fichier", ficmed
@@ -161,39 +152,39 @@ Python script for MED
     except IOError as eee:
       error = 2
       raise Exception('MEDFileUMesh.write() failed. ' + str(eee))
-  #
+
     break
-  #
+
   return error
 
 #========================================================================
-#
+
 #========================================================================
 def field_exec(niter):
   """
 Python script for MEDCoupling
   """
   error = 0
-#
+
   while not error :
-  #
-  # The mesh
-  # ========
+
+# The mesh
+# ========
     ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter)
     meshMEDFileRead = ml.MEDFileMesh.New(ficmed)
     mesh_read0 = meshMEDFileRead.getMeshAtLevel(0)
-  # Barycenter of the cells
-  # =======================
+# Barycenter of the cells
+# =======================
     cg_hexa_ml = mesh_read0.computeIsoBarycenterOfNodesPerCell()
     cg_hexa = cg_hexa_ml.toNumPyArray()
-  # Target
-  # ======
+# Target
+# ======
     xyz_p = np.zeros(3, dtype=np.float)
     xyz_p[0] = -0.20*float(1-niter) * LG_X
     xyz_p[1] = -0.15*float(1-niter) * LG_Y
     xyz_p[2] = -0.10*float(1-niter) * LG_Z
-  # Values of the field
-  # ===================
+# Values of the field
+# ===================
     nbr_cell_3d = mesh_read0.getNumberOfCells()
     valeur = mc.DataArrayDouble(nbr_cell_3d)
     for num_mail in range(nbr_cell_3d) :
@@ -205,37 +196,34 @@ Python script for MEDCoupling
       valeur[num_mail] = 1.e0 / max ( 1.e-5, distance)
     #print ". valeur", valeur
     nparr = valeur.toNumPyArray()
-    print(". mini/maxi", nparr.min(), nparr.max())
-  #
-  # Creation of the field
-  # =====================
+    print(". mini/maxi {}/{}".format(nparr.min(),nparr.max()))
+
+# Creation of the field
+# =====================
     field = ml.MEDCouplingFieldDouble(ml.ON_CELLS, ml.ONE_TIME)
     field.setArray(valeur)
     field.setMesh(mesh_read0)
     field.setName("DISTANCE")
-  #
+
     fMEDFile_ch = ml.MEDFileField1TS()
     fMEDFile_ch.setFieldNoProfileSBT(field)     # No profile desired on the field, Sort By Type
     fMEDFile_ch.write(ficmed, 0) # 0 to indicate that we *append* (and no overwrite) to the MED file
-  #
+
     break
-  #
+
   return error, ficmed
 
 #========================================================================
+
 #========================================================================
 def homard_exec():
-  """
-Python script for HOMARD
-  """
+  """Python script for HOMARD"""
   error = 0
-#
+
   while not error :
-  #
-  #  HOMARD.UpdateStudy()
-  #
-  # Creation of the hypothese DISTANCE INVERSE
-  # ==========================================
+
+# Creation of the hypothese DISTANCE INVERSE
+# ==========================================
     hyponame = "DISTANCE INVERSE"
     print("-------- Creation of the hypothesis", hyponame)
     hypo_5 = HOMARD.CreateHypothesis(hyponame)
@@ -245,33 +233,32 @@ Python script for HOMARD
     hypo_5.SetUnRefThr(1, 0.015)
     print(hyponame, " : champ utilisé :", hypo_5.GetFieldName())
     print(".. caractéristiques de l'adaptation :", hypo_5.GetField())
-  #
-  # Creation of the cases
-  # =====================
-    # Creation of the case
+
+# Creation of the cases
+# =====================
     print("-------- Creation of the case", TEST_NAME)
     mesh_file = os.path.join(DIRCASE, 'maill.00.med')
     case_test_5 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
     case_test_5.SetDirName(DIRCASE)
     case_test_5.SetConfType(1)
     case_test_5.SetExtType(1)
-  #
-  # Creation of the iterations
-  # ==========================
-  #
+
+# Creation of the iterations
+# ==========================
+
     for niter in range(N_ITER_TEST_FILE) :
-  #
+
       s_niterp1 = "%02d" % (niter + 1)
-    #
+
     # Creation of the indicator
     #
       error, ficmed_indic = field_exec(niter)
       if error :
         error = 10
         break
-    #
+
     # Creation of the iteration
-    #
+
       iter_name = "I_" + TEST_NAME + "_" + s_niterp1
       print("-------- Creation of the iteration", iter_name)
       if ( niter == 0 ) :
@@ -286,15 +273,15 @@ Python script for HOMARD
       if error :
         error = 20
         break
-  #
+
     break
-  #
+
   return error
 
 #========================================================================
-#
+
 # Geometry and Mesh
-#
+
 try :
   ERROR = mesh_exec()
   if ERROR :
@@ -305,23 +292,21 @@ except RuntimeError as eee:
 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 RuntimeError as eee:
   raise Exception('Pb in homard_exec: '+str(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)
-#
+
 if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser()
-  iparameters.getSession().restoreVisualState(1)
-
index 5c12921053e1fff7fde5c133334d2380f3956270..5b81cd8eb2f02d7ab34fa9525dcad8d4e7057ece 100755 (executable)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 # Copyright (C) 2011-2020  CEA/DEN, EDF R&D
 #
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-"""
-Python script for HOMARD
-Test test_6
-"""
-__revision__ = "V1.06"
+"""Python script for HOMARD - Test test_6"""
+__revision__ = "V2.01"
 
-#========================================================================
-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
-#
+import SHAPERSTUDY
+import SMESH
+import HOMARD
+
+from salome.shaper import model
+from salome.smesh import smeshBuilder
+
 # ==================================
 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
 # ==================================
+
+#========================================================================
+TEST_NAME = "test_6"
+DEBUG = False
+VERBOSE = False
+N_ITER_TEST_FILE = 3
+TAILLE = 10.
+LG_ARETE = TAILLE*2.5
 # 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
+
+#========================================================================
+def create_cao_smesh ():
+  """CAO and mesh"""
+
+  structure_sh, xao_file = create_cao ()
+
+  error, mesh_file = create_mesh (structure_sh)
+
+  return error, xao_file, mesh_file
+#========================================================================
+
+#========================================================================
+def create_cao ():
+  """CAO"""
+
+  if VERBOSE :
+    texte = "Géométrie '{}'\n".format(TEST_NAME)
+    texte += "Taille de base ={}".format(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
+
+  model.begin()
+  partset = model.moduleDocument()
+
+  part_1 = model.addPart(partset)
+  part_1_doc = part_1.document()
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc,  0.*TAILLE,  0.*TAILLE, 0.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc,  5.*TAILLE,  2.*TAILLE, 0.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc, 10.*TAILLE,  1.*TAILLE, 0.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc, 16.*TAILLE,  4.*TAILLE, 0.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc, 16.*TAILLE, 10.*TAILLE, 0.*TAILLE)
+
+  ### Create interpolation
+  interpolation_1_objects = [model.selection("VERTEX", "all-in-Point_1"), \
+                            model.selection("VERTEX", "all-in-Point_2"), \
+                            model.selection("VERTEX", "all-in-Point_3"), \
+                            model.selection("VERTEX", "all-in-Point_4"), \
+                            model.selection("VERTEX", "all-in-Point_5")]
+  _ = model.addInterpolation(part_1_doc, interpolation_1_objects, False, False)
+
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc,  0.*TAILLE,  0.*TAILLE, 20.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc,  6.*TAILLE, -5.*TAILLE, 20.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc, 11.*TAILLE, -2.*TAILLE, 20.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc, 12.*TAILLE,  3.*TAILLE, 20.*TAILLE)
+
+  ### Create Point
+  _ = model.addPoint(part_1_doc, 16.*TAILLE, 10.*TAILLE, 20.*TAILLE)
+
+  ### Create interpolation
+  interpolation_2_objects = [model.selection("VERTEX", "all-in-Point_6"), \
+                            model.selection("VERTEX", "all-in-Point_7"), \
+                            model.selection("VERTEX", "all-in-Point_8"), \
+                            model.selection("VERTEX", "all-in-Point_9"), \
+                            model.selection("VERTEX", "all-in-Point_10")]
+  _ = model.addInterpolation(part_1_doc, interpolation_2_objects, False, False)
+
+  ### Create Filling
+  structure_sh = model.addFilling(part_1_doc, [model.selection("EDGE", "Interpolation_1_1"), model.selection("EDGE", "Interpolation_2_1")])
+  structure_sh.setName(TEST_NAME)
+  structure_sh.result().setName(TEST_NAME)
+
+  ### Create Group
+  group_1 = model.addGroup(part_1_doc, "Faces", [model.selection("FACE", TEST_NAME)])
+  group_1.setName("Voile")
+  group_1.result().setName("Voile")
+
+  ### Create Group
+  group_2 = model.addGroup(part_1_doc, "Edges", [model.selection("EDGE", "Interpolation_1_1")])
+  group_2.setName("C_0")
+  group_2.result().setName("C_0")
+
+  ### Create Group
+  group_3 = model.addGroup(part_1_doc, "Edges", [model.selection("EDGE", "Interpolation_2_1")])
+  group_3.setName("C_1")
+  group_3.result().setName("C_1")
+
+  ### Create Group
+  group_4 = model.addGroup(part_1_doc, "Edges", [model.selection("EDGE", TEST_NAME+"/Edge_0_1")])
+  group_4.setName("D_0")
+  group_4.result().setName("D_0")
+
+  ### Create Group
+  group_5 = model.addGroup(part_1_doc, "Edges", [model.selection("EDGE", TEST_NAME+"/Edge_0_3")])
+  group_5.setName("D_1")
+  group_5.result().setName("D_1")
+
+  xao_file = os.path.join(DIRCASE, TEST_NAME+".xao")
+  model.exportToXAO(part_1_doc, xao_file, model.selection("FACE", TEST_NAME), "GN", TEST_NAME)
+
+  model.end()
+
+  return structure_sh, xao_file
+#========================================================================
+
+#========================================================================
+def create_mesh (structure_sh):
+  """Mesh"""
+  error = 0
+  mesh_file = os.path.join(DIRCASE, 'maill.00.med')
+
+  if VERBOSE :
+    texte = "Maillage de '{}'\n".format(TEST_NAME)
+    texte += "lg_arete = {}\n".format(LG_ARETE)
+    print (texte)
+
+  while not error :
+
+# 1. Importation to the study
+# ===========================
+    model.publishToShaperStudy()
+    l_aux = SHAPERSTUDY.shape(model.featureStringId(structure_sh))
+
+# 2. Creation of the mesh
+# =======================
     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)
+    structure_m = smesh.Mesh(l_aux[0])
+
+    MG_CADSurf = structure_m.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.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()
+
+# Les groupes issus de la géométrie
+    for groupe in l_aux[1:]:
+      groupe_nom = groupe.GetName()
+      if ( groupe_nom == "Voile" ):
+        shape = SMESH.FACE
+      else:
+        shape = SMESH.EDGE
+      _ = structure_m.GroupOnGeom(groupe,groupe_nom,shape)
+
+# Computation
+    isDone = structure_m.Compute()
     if not isDone :
-      message += "Probleme dans le maillage de la surface."
-      erreur = 13
+      error = 1
       break
-#
-# 5. Export MED
-#
-    ficmed = os.path.join(rep_mail,'maill.00.med')
-    texte = "Ecriture du fichier '%s'" % ficmed
-    if verbose :
-      print (texte)
+
+# MED exportation
     try:
-      maill_00.ExportMED(ficmed)
+      structure_m.ExportMED(mesh_file)
     except IOError as eee:
       error = 2
       raise Exception('ExportMED() failed. ' + str(eee))
-#
+
     break
-#
-  return erreur, message, ficmed
-#
-#==========================  Fin de la fonction ==================================
-#
+
+  return error, mesh_file
+#========================================================================
+
 #========================= Debut de la fonction ==================================
-#
-def homard_exec(nom, ficmed, xao_file, verbose=False):
-  """
-Python script for HOMARD
-  """
-  erreur = 0
-  message = ""
-#
-  while not erreur :
+
+def homard_exec(xao_file, mesh_file):
+  """Python script for HOMARD"""
+  error = 0
+
+  while not error :
     #
     #HOMARD.UpdateStudy()
     #
     # Frontière
     # =========
-    if verbose :
+    if VERBOSE :
       print(". Frontière")
-    cao_name = "CAO_" + nom
-    la_frontiere = HOMARD.CreateBoundaryCAO(cao_name, xao_file)
+    cao_name = "CAO_" + TEST_NAME
+    _ = HOMARD.CreateBoundaryCAO(cao_name, xao_file)
     #
     # Hypotheses
     # ==========
-    if verbose :
+    if VERBOSE :
       print(". Hypothèses")
-    hyponame = "hypo_" + nom
+    hyponame = "hypo_" + TEST_NAME
     l_hypothese = HOMARD.CreateHypothesis(hyponame)
     l_hypothese.SetUnifRefinUnRef(1)
     #
     # Cas
     # ===
-    if verbose :
+    if VERBOSE :
       print(". Cas")
-    le_cas = HOMARD.CreateCase('case_'+nom, nom, ficmed)
+    le_cas = HOMARD.CreateCase('case_'+TEST_NAME, TEST_NAME, mesh_file)
     le_cas.SetDirName(DIRCASE)
     le_cas.AddBoundary(cao_name)
     #
     # Creation of the iterations
     # ==========================
-    if verbose :
+    if VERBOSE :
       option = 2
     else :
       option = 1
     #
     for niter in range(1, N_ITER_TEST_FILE+1):
-      if verbose :
+      if VERBOSE :
         print(". Itération numéro %d" % niter)
-      iter_name = "I_" + nom + "_%02d" % niter
+      iter_name = "I_" + TEST_NAME + "_%02d" % niter
       if ( niter == 1 ) :
         l_iteration = le_cas.NextIteration(iter_name)
       else :
         l_iteration = l_iteration.NextIteration(iter_name)
-      l_iteration.SetMeshName(nom)
+      l_iteration.SetMeshName(TEST_NAME)
       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
+      error = l_iteration.Compute(1, option)
+      if error :
+        error = niter
         break
     #
     break
-  #
-  if erreur :
-    message += "Erreur au calcul de l'itération %d" % erreur
-  #
-  return erreur, message
+
+  return error
 #
 #==========================  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)
-#
+
+# CAO and Mesh
+
+try :
+  ERROR, XAO_FILE, MESH_FILE = create_cao_smesh()
+  if ERROR :
+    raise Exception('Pb in create_cao_smesh')
+except RuntimeError as eee:
+  raise Exception('Pb in create_cao_smesh: '+str(eee.message))
+
+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(XAO_FILE, MESH_FILE)
+  if ERROR :
+    raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except RuntimeError as eee:
+  raise Exception('Pb in homard_exec: '+str(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)
+
 if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser()
-  iparameters.getSession().restoreVisualState(1)
-
index a5a4e5e0113ed92405edf1fec41c8faf9ce37278..b8434f8f2e0d55eae6900ee7eab42c7ccd177f9a 100644 (file)
@@ -4,7 +4,7 @@ ANALYSE DU MAILLAGE
 ===================
 
      Maillage apres adaptation                         
-     MESH                                                                            
+     test_4                                                                            
      Date de creation : lundi 2 novembre 2015 a 11 h 32 mn 46 s         
      Dimension : 3
      Degre : 1
index 46688a8eb7069c3d19bde9c4e5c545216f5e5885..0a13c56e60550d29541f0998f69944ac95e239c7 100644 (file)
@@ -4,7 +4,7 @@ ANALYSE DU MAILLAGE
 ===================
 
      Maillage apres adaptation                         
-     MESH                                                                            
+     test_4                                                                            
      Date de creation : mardi 12 septembre 2017 a 8 h 47 mn 39 s        
      Dimension : 3
      Degre : 1
index 8c52a5071133866ed911cca92acd3e0be4a763f9..8c2853f17d3fd03f590cd740bf48bc17eeb37fa7 100644 (file)
@@ -14,7 +14,7 @@ ANALYSE DU MAILLAGE
 
          Direction    |       Unite       |  Minimum   |  Maximum
      ---------------------------------------------------------------
-                      |                   |  0.0000    |  169.52    
+                      |                   |  0.0000    |  169.49    
                       |                   | -50.434    |  100.00    
                       |                   |  0.0000    |  200.00