Back to index

salome-med  6.5.0
FIELDcreate.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 should be executed when the shared library is   #
00026 # generated using SWIG 1.3 (or higher) due to the fact that older    #
00027 # version could not handle the wrapping of several class constructor #
00028 ######################################################################
00029 #
00030 from libMEDMEM_Swig import *
00031 
00032 MedFile = "pointe.med"
00033 meshName = "maa1"
00034 
00035 myMesh = MESH(MED_DRIVER,MedFile,meshName)
00036 
00037 mySupport = myMesh.getSupportOnAll(MED_CELL)
00038 
00039 numberOfComponents = 3
00040 myField = FIELDDOUBLE(mySupport,numberOfComponents)
00041 fieldName = "fieldcelldouble"
00042 myField.setName(fieldName)
00043 
00044 for i in range(numberOfComponents):
00045     if (i == 0):
00046         name = "Vx"
00047         desc = "vitesse selon x"
00048     elif (i == 1):
00049         name = "Vy"
00050         desc = "vitesse selon y"
00051     else:
00052         name = "Vz"
00053         desc = "vitesse selon z"
00054     unit = "m. s-1"
00055     ip1 = i+1
00056     myField.setComponentName(ip1,name)
00057     myField.setComponentDescription(ip1,desc)
00058     myField.setMEDComponentUnit(ip1,unit)
00059 
00060 iterationNumber = 10
00061 myField.setIterationNumber(iterationNumber)
00062 
00063 orderNumber = 1
00064 myField.setOrderNumber(orderNumber)
00065 
00066 time = 3.435678
00067 myField.setTime(time)
00068 
00069 numberOfValue = mySupport.getNumberOfElements(MED_ALL_ELEMENTS)
00070 
00071 for i in range(numberOfValue):
00072     ip1 = i+1
00073     for j in range(numberOfComponents):
00074         jp1 = j+1
00075         value = (ip1+jp1)*0.1
00076         myField.setValueIJ(ip1,jp1,value)
00077 
00078 id = myField.addDriver(MED_DRIVER)