Back to index

salome-med  6.5.0
test_profil_MedFieldDriver.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 ############################################################################
00025 # this Python script is testing the profil functionality using the FIELD
00026 # constructor via a MED driver.
00027 ############################################################################
00028 #
00029 from libMEDMEM_Swig import *
00030 
00031 # users inputs
00032 #test 1 --- zzzz121b_without_tr6.med RESUZERODEPL____________________ 1 1
00033 #test 2 --- zzzz121b_without_tr6.med RESUZEROERRE_ELGA_NORE__________ 1 1
00034 #test 3 --- maill.00.med Indicateur_d_erreur_00 2 2
00035 
00036 medFile = "zzzz121b_without_tr6.med"
00037 #medFile = "maill.00.med"
00038 
00039 fieldName = "RESUZERODEPL____________________"
00040 #fieldName = "RESUZEROERRE_ELGA_NORE__________"
00041 #fieldName = "Indicateur_d_erreur_00"
00042 
00043 # default  value, may be changed according to what field is stored in medFile
00044 ##iterationNumber = -1
00045 ##orderNumber = -1
00046 iterationNumber = 1
00047 orderNumber = 1
00048 #iterationNumber = 2
00049 #orderNumber = 2
00050 
00051 import os
00052 #
00053 #befor running this script, please be sure about the path the file fileName
00054 #
00055 filePath=os.environ["MED_ROOT_DIR"]
00056 filePath=os.path.join(filePath, "share", "salome", "resources", "med")
00057 
00058 medFile = os.path.join(filePath, medFile)
00059 
00060 def analyseField(field):
00061     fieldName = field.getName()
00062     fieldType = field.getValueType()
00063     fieldDesc = field.getDescription()
00064     fieldIterationNumber = field.getIterationNumber()
00065     fieldOrderNumber = field.getOrderNumber()
00066     fieldTime = field.getTime()
00067     fieldNbOfComp = field.getNumberOfComponents()
00068     print "The field ",fieldName," with the description ",fieldDesc," typed ",fieldType
00069     print "Iteration number ",fieldIterationNumber," OrderNumber ",fieldOrderNumber," Time ",fieldTime
00070     print "It has ",fieldNbOfComp,"components"
00071     for k in range(fieldNbOfComp):
00072         kp1 = k+1
00073         fieldCompName = field.getComponentName(kp1)
00074         fieldCompDesc = field.getComponentDescription(kp1)
00075         fieldCompUnit = field.getMEDComponentUnit(kp1)
00076         print "      * Component:",kp1
00077         print "          Name:",fieldCompName
00078         print "          Description:",fieldCompDesc
00079         print "          Unit:",fieldCompUnit
00080         pass
00081     fieldSupport = field.getSupport()
00082     fieldMeshName = fieldSupport.getMeshName()
00083     fieldSupportOnAll = fieldSupport.isOnAllElements()
00084     fieldNbEntities = fieldSupport.getNumberOfElements(MED_ALL_ELEMENTS)
00085     fieldEntityType = fieldSupport.getEntity()
00086     fieldSupportNumber = range(1,fieldNbEntities+1)
00087     if (not fieldSupportOnAll):
00088         fieldSupportNumber = fieldSupport.getNumber(MED_ALL_ELEMENTS)
00089         pass
00090     print " fieldSupportNumber ", fieldSupportNumber
00091     fieldInterlacingType = field.getInterlacingType()
00092     print "It relies on the mesh named ",fieldMeshName
00093     print "its interlacing type ",fieldInterlacingType
00094     print "and it is on ",fieldNbEntities," entities of the type ",fieldEntityType
00095     if (fieldInterlacingType == MED_FULL_INTERLACE):
00096         for i in range(fieldNbEntities):
00097             value = field.getRow(fieldSupportNumber[i])
00098             print " * ",fieldSupportNumber[i]," --- ",value
00099             pass
00100         pass
00101     elif (fieldInterlacingType == MED_FULL_INTERLACE):
00102         for i in range(fieldNbOfComp):
00103             value = field.getColumn(fieldSupportNumber[i])
00104             print " * ",fieldSupportNumber[i]," --- ",value
00105             pass
00106         pass
00107     pass
00108 
00109 field = FIELDDOUBLE(MED_DRIVER, medFile, fieldName,
00110                     iterationNumber, orderNumber)
00111 
00112 analyseField(field)
00113 
00114 print "END of the Pyhton script ..... Ctrl D to exit"