Back to index

salome-med  6.5.0
med_test_skin.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #% Test function MESH::getSkin() on mesh from file cube_hexa8_quad4.med
00025 #% The med file can be obtained by running create_mesh_c3h8q4 executable
00026 #
00027 from libMEDMEM_Swig import *
00028 import os
00029 #
00030 #befor running this script, please be sure about the path the file fileName
00031 #
00032 filePath=os.environ["MED_ROOT_DIR"]
00033 filePath=os.path.join(filePath, "share", "salome", "resources", "med")
00034 
00035 medFile = os.path.join(filePath, "cube_hexa8_quad4.med")
00036 
00037 print ""
00038 print "Read file", medFile
00039 print ""
00040 
00041 md = MEDFILEBROWSER(medFile)
00042 
00043 mesh_name = md.getMeshName(0)
00044 mesh = MESH(MED_DRIVER,medFile,mesh_name)
00045 
00046 print "Building the support on all (8) Cells of the mesh."
00047 supportCell = mesh.getSupportOnAll(MED_CELL)
00048 
00049 print "Getting skin of an all cell support"
00050 
00051 supportSkin = mesh.getSkin(supportCell)
00052 faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] )
00053 print "--------", faceNumbers
00054 if faceNumbers != [2, 3, 6, 8, 10, 11, 12, 13, 16, 17, 19, 20, 22, 23, 24, 27, 28, 29, 30, 31, 32, 34, 35, 36]:
00055   raise  RuntimeError, "Wrong skin of an all cell support"
00056   
00057 print "Build the support on 1 Cell (#8) of the mesh."
00058 supportCell = SUPPORT( supportCell )
00059 supportCell.setAll( 0 )
00060 nbGeomTypes = 1
00061 nbTotalEntity = 1
00062 GeometricType = mesh.getTypes(MED_CELL)
00063 nbEntityList = [1, 2]
00064 EntityNbs = [8]
00065 supportCell.setpartial("1 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs)
00066 
00067 print "Getting skin of 1 cell support"
00068 supportSkin = mesh.getSkin(supportCell)
00069 faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] )
00070 print "Skin Support FACE numbers:"
00071 print "--------", faceNumbers
00072 if faceNumbers != [18, 26, 33, 34, 35, 36]:
00073   raise  RuntimeError, "Wrong skin of 1 cell support"
00074 
00075 
00076 
00077 print "Building the support on 2 Cells (#1 #2) of the mesh."
00078 nbTotalEntity = 2
00079 nbEntityList = [1, 3]
00080 EntityNbs = [1, 2]
00081 supportCell.setpartial("2 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs)
00082 
00083 print "Getting skin of 2 cell support"
00084 supportSkin = mesh.getSkin(supportCell)
00085 faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] )
00086 print "Skin Support FACE numbers:", faceNumbers
00087 if faceNumbers != [1, 2, 3, 4, 6, 7, 8, 9, 10, 11]:
00088   raise  RuntimeError, "Wrong skin of 2 cells support"