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