From e6a7149d84a80559ec92bf03b96063ebd0192ba4 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 14 Sep 2018 12:14:51 +0300 Subject: [PATCH] 0023591: [EDF] Add test to check meshing plug-ins to SMESH module --- doc/salome/examples/CMakeLists.txt | 2 +- doc/salome/examples/creating_meshes_ex05.py | 4 +- doc/salome/examples/filters_ex24.py | 2 +- doc/salome/examples/test_smeshplugins.py | 206 ++++++++++++++++++++ doc/salome/examples/tests.set | 1 + 5 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 doc/salome/examples/test_smeshplugins.py diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 01ed3f5ac..7aa40fe8d 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -34,7 +34,7 @@ SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/SMESH) # Application tests SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test) -INSTALL(FILES ${GOOD_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY}) +INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} diff --git a/doc/salome/examples/creating_meshes_ex05.py b/doc/salome/examples/creating_meshes_ex05.py index ae1d073b4..5806d5227 100644 --- a/doc/salome/examples/creating_meshes_ex05.py +++ b/doc/salome/examples/creating_meshes_ex05.py @@ -46,13 +46,13 @@ import MEDLoader, os # exported mesh is in 2D space because it is a planar mesh lying # on XOY plane, and autoDimension=True by default mesh2D.ExportMED( medFile ) -medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0) +medMesh = MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0) print "autoDimension==True, exported mesh is in %sD"%medMesh.getSpaceDimension() # exported mesh is in 3D space, same as in Mesh module, # thanks to autoDimension=False mesh2D.ExportMED( medFile, autoDimension=False ) -medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0) +medMesh = MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0) print "autoDimension==False, exported mesh is in %sD"%medMesh.getSpaceDimension() os.remove( medFile ) diff --git a/doc/salome/examples/filters_ex24.py b/doc/salome/examples/filters_ex24.py index bab47e2a7..8d97a4334 100644 --- a/doc/salome/examples/filters_ex24.py +++ b/doc/salome/examples/filters_ex24.py @@ -5,7 +5,7 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # remove some volumes to have volumes with bare borders -mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] ) +mesh.RemoveElements( mesh.GetElementsByType(SMESH.VOLUME)[0:5] ) # get all volumes with bare borders filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume) ids = mesh.GetIdsFromFilter(filter) diff --git a/doc/salome/examples/test_smeshplugins.py b/doc/salome/examples/test_smeshplugins.py new file mode 100644 index 000000000..d3111e63a --- /dev/null +++ b/doc/salome/examples/test_smeshplugins.py @@ -0,0 +1,206 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Test000 +Checks the availability of the external plugins : + 1 NETGENPLUGIN + 2 GMSHPLUGIN + 3 MG-CADSURF (BLSURFPLUGIN) + 4 MG-TETRA (GHS3DPLUGIN) + 5 MG-HEXA (HEXOTICPLUGIN) + 6 MG-HYBRID (HYBRIDPLUGIN) + 7 MG-TETRA-PARALLELE (GHS3DPRLPLUGIN) +Copyright EDF R&D 2017 +""" +__revision__ = "V1.0" +# +# Computation of the meshes: T/F +ComputeMeshes = True + +import salome + +salome.salome_init() +theStudy = salome.myStudy +# +import iparameters +IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1)) + +# fill list AP_MODULES_LIST +IPAR.append("AP_MODULES_LIST", "Geometry") +IPAR.append("AP_MODULES_LIST", "Mesh") + +ERROR = 0 +MESSAGE = "" +# +while not ERROR : + +### +### A. GEOM component +### + import GEOM + from salome.geom import geomBuilder + geompy = geomBuilder.New(theStudy) + O = geompy.MakeVertex(0, 0, 0, "0") + OX = geompy.MakeVectorDXDYDZ(1, 0, 0, "OX") + OY = geompy.MakeVectorDXDYDZ(0, 1, 0, "OY") + OZ = geompy.MakeVectorDXDYDZ(0, 0, 1, "OZ") + BOX = geompy.MakeBoxDXDYDZ(200, 200, 200, "BOX") + +### +### B. SMESH component +### + + import SMESH + from salome.smesh import smeshBuilder + + smesh = smeshBuilder.New(theStudy) + +# B.1. NETGEN + TEXTE = "NETGEN_1D2D3D" + MESH_1 = smesh.Mesh(BOX) + smesh.SetName(MESH_1.GetMesh(), "M_"+TEXTE) + try : + NETGEN_2D3D = MESH_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 + else : + if ComputeMeshes : + smesh.SetName(NETGEN_2D3D.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_1.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + +# B.2. Gmsh + TEXTE = "Gmsh" + MESH_2 = smesh.Mesh(BOX) + smesh.SetName(MESH_2.GetMesh(), "M_"+TEXTE) + try : + GMSH = MESH_2.Tetrahedron(algo=smeshBuilder.GMSH) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 + else : + if ComputeMeshes : + smesh.SetName(GMSH.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_2.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + +# B.3. MG_CADSurf + TEXTE = "MG_CADSurf" + MESH_3 = smesh.Mesh(BOX) + smesh.SetName(MESH_3.GetMesh(), "M_"+TEXTE) + try : + MG_CADSurf = MESH_3.Triangle(algo=smeshBuilder.MG_CADSurf) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 +# On arrete tout en cas de problème car les suivants en dépendent + break + else : + if ComputeMeshes : + smesh.SetName(MG_CADSurf.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_3.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + +# B.4. MG_Tetra + TEXTE = "MG_Tetra" + MESH_4 = smesh.Mesh(BOX) + smesh.SetName(MESH_4.GetMesh(), "M_"+TEXTE) + MG_CADSurf_Te = MESH_4.Triangle(algo=smeshBuilder.MG_CADSurf) + try : + MG_Tetra = MESH_4.Tetrahedron(algo=smeshBuilder.MG_Tetra) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 + else : + if ComputeMeshes : + smesh.SetName(MG_Tetra.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_4.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + +# B.5. MG_Hexa + TEXTE = "MG_Hexa" + MESH_5 = smesh.Mesh(BOX) + smesh.SetName(MESH_5.GetMesh(), "M_"+TEXTE) + MG_CADSurf_He = MESH_5.Triangle(algo=smeshBuilder.MG_CADSurf) + try : + MG_Hexa = MESH_5.Hexahedron(algo=smeshBuilder.MG_Hexa) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 + else : + if ComputeMeshes : + smesh.SetName(MG_Hexa.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_5.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + +# B.6. MG_Hybrid + TEXTE = "MG_Hybrid" + MESH_6 = smesh.Mesh(BOX) + smesh.SetName(MESH_6.GetMesh(), "M_"+TEXTE) + MG_CADSurf_Hy = MESH_6.Triangle(algo=smeshBuilder.MG_CADSurf) + try : + MG_Hybrid = MESH_6.Tetrahedron(algo=smeshBuilder.HYBRID) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 + else : + if ComputeMeshes : + smesh.SetName(MG_Hybrid.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_6.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + +# B.7. MG_Tetra_Parallel + TEXTE = "MG_Tetra_Parallel" + MESH_7 = smesh.Mesh(BOX) + smesh.SetName(MESH_7.GetMesh(), "M_"+TEXTE) + MG_CADSurf_Tp = MESH_7.Triangle(algo=smeshBuilder.MG_CADSurf) + try : + MG_Tetra_Parallel = MESH_7.Tetrahedron(algo=smeshBuilder.MG_Tetra_Parallel) + except : + MESSAGE += "\nImpossible d'utiliser "+TEXTE + ERROR += 1 + else : + if ComputeMeshes : + smesh.SetName(MG_Tetra_Parallel.GetAlgorithm(), TEXTE) + OK_COMPUTE = MESH_7.Compute() + if not OK_COMPUTE : + MESSAGE += "\nErreur avec "+TEXTE + ERROR += 1 + else : + print TEXTE+": OK" + + break + +### +### C. End +### +if ERROR : + raise Exception("\n\nNombre d'erreurs : %d" % ERROR + MESSAGE + "\n") +else : + print "\nAucun problème\n" + diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index 2cf9698d1..34237bccf 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -42,6 +42,7 @@ SET(BAD_TESTS quality_controls_ex21.py quality_controls_ex22.py viewing_meshes_ex01.py + test_smeshplugins.py ) SET(GOOD_TESTS -- 2.39.2