1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 ############################################################################
23 # this Python script is testing the profil functionality using the FIELD
24 # constructor via a MED driver.
25 ############################################################################
27 from libMEDMEM_Swig import *
30 #test 1 --- zzzz121b_without_tr6.med RESUZERODEPL____________________ 1 1
31 #test 2 --- zzzz121b_without_tr6.med RESUZEROERRE_ELGA_NORE__________ 1 1
32 #test 3 --- maill.00.med Indicateur_d_erreur_00 2 2
34 medFile = "zzzz121b_without_tr6.med"
35 #medFile = "maill.00.med"
37 fieldName = "RESUZERODEPL____________________"
38 #fieldName = "RESUZEROERRE_ELGA_NORE__________"
39 #fieldName = "Indicateur_d_erreur_00"
41 # default value, may be changed according to what field is stored in medFile
42 ##iterationNumber = -1
51 #befor running this script, please be sure about the path the file fileName
53 filePath=os.environ["MED_ROOT_DIR"]
54 filePath=os.path.join(filePath, "share", "salome", "resources", "med")
56 medFile = os.path.join(filePath, medFile)
58 def analyseField(field):
59 fieldName = field.getName()
60 fieldType = field.getValueType()
61 fieldDesc = field.getDescription()
62 fieldIterationNumber = field.getIterationNumber()
63 fieldOrderNumber = field.getOrderNumber()
64 fieldTime = field.getTime()
65 fieldNbOfComp = field.getNumberOfComponents()
66 print "The field ",fieldName," with the description ",fieldDesc," typed ",fieldType
67 print "Iteration number ",fieldIterationNumber," OrderNumber ",fieldOrderNumber," Time ",fieldTime
68 print "It has ",fieldNbOfComp,"components"
69 for k in range(fieldNbOfComp):
71 fieldCompName = field.getComponentName(kp1)
72 fieldCompDesc = field.getComponentDescription(kp1)
73 fieldCompUnit = field.getMEDComponentUnit(kp1)
74 print " * Component:",kp1
75 print " Name:",fieldCompName
76 print " Description:",fieldCompDesc
77 print " Unit:",fieldCompUnit
79 fieldSupport = field.getSupport()
80 fieldMeshName = fieldSupport.getMeshName()
81 fieldSupportOnAll = fieldSupport.isOnAllElements()
82 fieldNbEntities = fieldSupport.getNumberOfElements(MED_ALL_ELEMENTS)
83 fieldEntityType = fieldSupport.getEntity()
84 fieldSupportNumber = range(1,fieldNbEntities+1)
85 if (not fieldSupportOnAll):
86 fieldSupportNumber = fieldSupport.getNumber(MED_ALL_ELEMENTS)
88 print " fieldSupportNumber ", fieldSupportNumber
89 fieldInterlacingType = field.getInterlacingType()
90 print "It relies on the mesh named ",fieldMeshName
91 print "its interlacing type ",fieldInterlacingType
92 print "and it is on ",fieldNbEntities," entities of the type ",fieldEntityType
93 if (fieldInterlacingType == MED_FULL_INTERLACE):
94 for i in range(fieldNbEntities):
95 value = field.getRow(fieldSupportNumber[i])
96 print " * ",fieldSupportNumber[i]," --- ",value
99 elif (fieldInterlacingType == MED_FULL_INTERLACE):
100 for i in range(fieldNbOfComp):
101 value = field.getColumn(fieldSupportNumber[i])
102 print " * ",fieldSupportNumber[i]," --- ",value
107 field = FIELDDOUBLE(MED_DRIVER, medFile, fieldName,
108 iterationNumber, orderNumber)
112 print "END of the Pyhton script ..... Ctrl D to exit"