Back to index

salome-med  6.5.0
testMedMemGeneral.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 all functionalities of the Med Memory through its
00026 # Python API; for this purpose a battery of med file as well as gibi files are
00027 # scanned using the parser written in the Python script med_test1.py with some
00028 # addings to test other functionality written in othe Python scripts in the bin
00029 # directory of the installation of MED
00030 ###################################################################################
00031 #
00032 from libMEDMEM_Swig import *
00033 from random import *
00034 
00035 import sys,os,string
00036 
00037 filesPath = os.environ["MED_ROOT_DIR"]
00038 filesPath = os.path.join(filesPath, "share", "salome", "resources", "med")
00039 
00040 tmpDir = os.getenv("TEMP")
00041 if tmpDir == None:
00042   tmpDir = "/tmp"
00043 
00044 tmpMask = os.path.join(tmpDir, "*_test.*")
00045 os.system("rm -rf " + tmpMask)
00046 
00047 fileNames = []
00048 meshNames = []
00049 
00050 def print_ord(i):
00051     if i == 0:
00052         return 'first'
00053     elif i == 1:
00054         return 'second'
00055     elif i == 2:
00056         return 'third'
00057     else:
00058         return `i`+'th'
00059 
00060 def add_one(i):
00061     return i+1
00062 
00063 ###################################################################################
00064 #
00065 # Here is the part you should change to add another file to the test files battery
00066 #
00067 ###################################################################################
00068 #
00069 # med file list
00070 #
00071 # from CODE_ASTER
00072 #
00073 
00074 ##fileNames.append("maill.0.med")
00075 ##meshNames.append("MAILTRQU")
00076 
00077 ##fileNames.append("zzzz121b.med")
00078 ##meshNames.append("MUN")
00079 
00080 #
00081 # from the SMESH Salome Module
00082 #
00083 
00084 fileNames.append("mesh.med")
00085 meshNames.append("Mesh 1")
00086 
00087 #
00088 # from other source including LGLS ones
00089 #
00090 
00091 fileNames.append("maillage_UniSegFam.med")
00092 meshNames.append("maillage_CHEMVAL_100elts")
00093 
00094 fileNames.append("carre_en_quad4.med")
00095 meshNames.append("carre_en_quad4")
00096 
00097 fileNames.append("cube_hexa8.med")
00098 meshNames.append("CUBE_EN_HEXA8")
00099 
00100 ##fileNames.append("test19.med")
00101 ##meshNames.append("CartGrid")
00102 
00103 ##fileNames.append("test19.med")
00104 ##meshNames.append("bodyfitted")
00105 
00106 ##fileNames.append("test19.med")
00107 ##meshNames.append("maa1")
00108 
00109 fileNames.append("carre_en_quad4_seg2.med")
00110 meshNames.append("carre_en_quad4_seg2")
00111 
00112 fileNames.append("cube_hexa8_quad4.med")
00113 meshNames.append("CUBE_EN_HEXA8_QUAD4")
00114 
00115 fileNames.append("pointe.med")
00116 meshNames.append("maa1")
00117 
00118 fileNames.append("Mistrat.med")
00119 meshNames.append("Mistrat_Hexa")
00120 
00121 ##fileNames.append("TimeStamps.med")
00122 ##meshNames.append("dom")
00123 
00124 fileNames.append("Darcy3_3D_H_10x10x10_2.med")
00125 meshNames.append("Darcy3_3D_H_10x10x10")
00126 
00127 fileNames.append("elle_3D_HPr_10x10x10_2.med")
00128 meshNames.append("elle_3D_HPr_10x10x10")
00129 
00130 fileNames.append("elle_3D_HPr_2x2x2_2.med")
00131 meshNames.append("elle_3D_HPr_2x2x2")
00132 
00133 fileNames.append("elle_3D_HPr_4x4x4_2.med")
00134 meshNames.append("elle_3D_HPr_4x4x4")
00135 
00136 
00137 
00138 fileNames.append("ChampsDarcy.med")
00139 meshNames.append("2D_I129")
00140 
00141 fileNames.append("darcy_1.1_res.med")
00142 meshNames.append("mail_test1-1-tri")
00143 
00144 fileNames.append("darcy_1.3_resCASTEM.med")
00145 meshNames.append("mail_ktest1-3-tetra")
00146 
00147 fileNames.append("darcy_1.3_resPORFLOW.med")
00148 meshNames.append("mail_ktest1-3-hexa")
00149 
00150 fileNames.append("darcy_1.3_resTRACES.med")
00151 meshNames.append("mail_ktest1-3-tetra")
00152 
00153 fileNames.append("darcy2_Castem_EFMH.med")
00154 meshNames.append("mail_test1-2-tri")
00155 
00156 fileNames.append("darcy2_Castem_qua_EFMH.med")
00157 meshNames.append("mail_test1-2-qua")
00158 
00159 fileNames.append("darcy2_Castem_qua_VF.med")
00160 meshNames.append("mail_test1-2-qua")
00161 
00162 # there is a field with too long name (38 > MED_TAILLE_NOM==32):
00163 # "analytical_field - CONCENTRATION of A1"
00164 # so that invalid writing is sometimes fatal
00165 # fileNames.append("Deff_fdt_5.8_castem_efmh_diff_conc_dom.med")
00166 # meshNames.append("maillage_deffec_fdt")
00167 
00168 # there is a field with too long name (38 > MED_TAILLE_NOM==32):
00169 # "analytical_field - CONCENTRATION of A1"
00170 # so that invalid writing is sometimes fatal
00171 # fileNames.append("Deff_fdt_5.8_castem_vf_diff_conc_dom.med")
00172 # meshNames.append("maillage_deffec_fdt")
00173 
00174 fileNames.append("extendedtransport53_triangles.med")
00175 meshNames.append("TestA3_2094_0.1_rsurf_tri")
00176 
00177 fileNames.append("H_CastCast_EFMH_I129_COUPLEX1.med")
00178 meshNames.append("COUPLEX1")
00179 
00180 fileNames.append("H_CastCast_VF_I129_COUPLEX1.med")
00181 meshNames.append("COUPLEX1")
00182 
00183 fileNames.append("H_CastCast_VF_Se79_COUPLEX1.med")
00184 meshNames.append("COUPLEX1")
00185 
00186 fileNames.append("H_CastPorf_I129_COUPLEX1.med")
00187 meshNames.append("COUPLEX1")
00188 
00189 fileNames.append("H_CastPorf_Se79_COUPLEX1.med")
00190 meshNames.append("COUPLEX1")
00191 
00192 fileNames.append("H_PorfCast_EFMH_I129_COUPLEX1.med")
00193 meshNames.append("COUPLEX1")
00194 
00195 fileNames.append("H_PorfCast_EFMH_Se79_COUPLEX1.med")
00196 meshNames.append("COUPLEX1")
00197 
00198 fileNames.append("H_PorfPorf_I129_COUPLEX1.med")
00199 meshNames.append("COUPLEX1")
00200 
00201 fileNames.append("H_Traces_I129_COUPLEX1.med")
00202 meshNames.append("COUPLEX1")
00203 
00204 fileNames.append("H_Traces_Se79_COUPLEX1.med")
00205 meshNames.append("COUPLEX1")
00206 
00207 fileNames.append("maillage_5_5_5.med")
00208 meshNames.append("maillage_5_5_5")
00209 
00210 fileNames.append("maillage_chemvalIV_cas1_40elts.med")
00211 meshNames.append("maillage_chemvalIV_cas1_40elts")
00212 
00213 
00214 
00215 
00216 #
00217 # Castem or Gibi file list
00218 #
00219 
00220 fileNames.append("Darcy3_3D_H_10x10x10.sauve")
00221 meshNames.append("")
00222 
00223 fileNames.append("dx200_dy1_avec_2couches.sauve")
00224 meshNames.append("")
00225 
00226 fileNames.append("elle_2D_QT_10x10.sauve")
00227 meshNames.append("")
00228 
00229 fileNames.append("elle_2D_QT_2x2.sauve")
00230 meshNames.append("")
00231 
00232 fileNames.append("elle_2D_QT_40x40.sauve")
00233 meshNames.append("")
00234 
00235 fileNames.append("elle_2D_QT_4x4.sauve")
00236 meshNames.append("")
00237 
00238 fileNames.append("elle_3D_HPr_10x10x10.sauve")
00239 meshNames.append("")
00240 
00241 fileNames.append("elle_3D_HPr_2x2x2.sauve")
00242 meshNames.append("")
00243 
00244 fileNames.append("elle_3D_HPr_4x4x4.sauve")
00245 meshNames.append("")
00246 
00247 fileNames.append("inclusion_2d_raf.sauve")
00248 meshNames.append("")
00249 
00250 fileNames.append("inclusion_2d.sauve")
00251 meshNames.append("")
00252 
00253 fileNames.append("mail_ktest1-3-hexa.sauve")
00254 meshNames.append("")
00255 
00256 fileNames.append("mail_ktest1-3-tetra.sauve")
00257 meshNames.append("")
00258 
00259 fileNames.append("mail_ktest3-1.sauve")
00260 meshNames.append("")
00261 
00262 fileNames.append("mail_ktest3-2.sauve")
00263 meshNames.append("")
00264 
00265 fileNames.append("maillage_andra2_100elts.sauve")
00266 meshNames.append("")
00267 
00268 fileNames.append("maillage_cas2_2d.sauve")
00269 meshNames.append("")
00270 
00271 fileNames.append("maillage_cas4_234elts.sauve")
00272 meshNames.append("")
00273 
00274 fileNames.append("maillage_CHEMVAL_100elts.sauve")
00275 meshNames.append("")
00276 
00277 fileNames.append("maillage_CHEMVAL_40elts.sauve")
00278 meshNames.append("")
00279 
00280 fileNames.append("maillage_chemvalIV_cas1_100elts.sauve")
00281 meshNames.append("")
00282 
00283 fileNames.append("maillage_chemvalIV_cas1_40elts.sauve")
00284 meshNames.append("")
00285 
00286 fileNames.append("mail_test1-1-qua.sauve")
00287 meshNames.append("")
00288 
00289 fileNames.append("mail_test1-1-tri.sauve")
00290 meshNames.append("")
00291 
00292 fileNames.append("mail_test1-2-qua.sauve")
00293 meshNames.append("")
00294 
00295 fileNames.append("mail_test1-2-tri.sauve")
00296 meshNames.append("")
00297 
00298 fileNames.append("mail-test1-4-1.sauve")
00299 meshNames.append("")
00300 
00301 fileNames.append("mail-test1-4-2.sauve")
00302 meshNames.append("")
00303 
00304 #
00305 # Porflow file list
00306 #
00307 
00308 fileNames.append("boitenew.inp")
00309 meshNames.append("")
00310 
00311 fileNames.append("Case1.inp")
00312 meshNames.append("")
00313 
00314 fileNames.append("cube.inp")
00315 meshNames.append("")
00316 
00317 fileNames.append("test3.inp")
00318 meshNames.append("")
00319 
00320 fileNames.append("titi.inp")
00321 meshNames.append("")
00322 
00323 ###################################################################################
00324 
00325 nbOfFiles = len(fileNames)
00326 filesFull = []
00327 
00328 for i in range(nbOfFiles):
00329     filesFull.append(os.path.join(filesPath, fileNames[i]))
00330 
00331 ###################################################################################
00332 #
00333 # Loop on all files
00334 #
00335 ###################################################################################
00336 
00337 print " This test is running on ",nbOfFiles," files"
00338 print ""
00339 
00340 for i in range(nbOfFiles):
00341     fileName = fileNames[i]
00342     fileFull = filesFull[i]
00343     decompFile = string.split(fileName,".")
00344     lenDecompFileM1 = len(decompFile)-1
00345 
00346     if (lenDecompFileM1 == 0) :
00347         print "The file ",fileName," should have at least a . in its name "
00348         sys.exit(1)
00349 
00350     extensionFile = decompFile[lenDecompFileM1]
00351 
00352     rootFile = decompFile[0]
00353     for k in range(1,lenDecompFileM1):
00354         rootFile = rootFile + "." + decompFile[k]
00355 
00356     rootFileFull = os.path.join(tmpDir, rootFile)
00357 
00358     medV22FileName = rootFileFull + "V22_test.med"
00359     vtkFileName    = rootFileFull + "_test.vtk"
00360 
00361     try:
00362         mesh = MESH()
00363         if (extensionFile == "med"):
00364             print "The file ",fileName," is a MED file and the name of the mesh is ", meshNames[i]
00365             meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh)
00366             meshDriver.setMeshName(meshNames[i])
00367         elif (extensionFile == "sauve"):
00368             print "The file ",fileName," is a GIBI file"
00369             meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh)
00370         elif (extensionFile == "inp"):
00371             print "The file ",fileName," is a PORFLOW file"
00372             meshDriver = PORFLOW_MESH_RDONLY_DRIVER(fileFull,mesh)
00373         else :
00374             print "the file ",fileName,"has an unknow extension"
00375             sys.exit(1)
00376 
00377         mesh.read(meshDriver)
00378     except:
00379         print "The mesh stored in the file ",fileName," is perhaps a GRID."
00380         try:
00381             print "... of MED_CARTESIAN type ?"
00382             type = MED_CARTESIAN
00383             mesh = GRID()
00384             mesh.setGridType(type)
00385             if (extensionFile == "med"):
00386                 meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh)
00387                 meshDriver.setMeshName(meshNames[i])
00388             elif (extensionFile == "sauve"):
00389                 meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh)
00390             elif (extensionFile == "inp"):
00391                 print "The file ",fileName," is a PORFLOW file"
00392                 meshDriver = PORFLOW_MESH_RDONLY_DRIVER(fileFull,mesh)
00393             else :
00394                 print "the file ",fileName,"has an unknow extension"
00395                 sys.exit(1)
00396 
00397             meshDriver.open()
00398             meshDriver.read()
00399         except:
00400             meshDriver.close()
00401             try:
00402                 print "... of MED_POLAR type ?"
00403                 mesh = GRID()
00404                 type = MED_POLAR
00405                 mesh.setGridType(type)
00406                 if (extensionFile == "med"):
00407                     meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh)
00408                     meshDriver.setMeshName(meshNames[i])
00409                 elif (extensionFile == "sauve"):
00410                     meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh)
00411                 else :
00412                     print "the file ",fileName,"has an unknow extension"
00413                     sys.exit(1)
00414 
00415                 meshDriver.open()
00416                 meshDriver.read()
00417             except:
00418                 meshDriver.close()
00419                 print "... of MED_BODY_FITTED type ?"
00420                 mesh = GRID()
00421                 type = MED_BODY_FITTED
00422                 mesh.setGridType(type)
00423                 if (extensionFile == "med"):
00424                     meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh)
00425                     meshDriver.setMeshName(meshNames[i])
00426                 elif (extensionFile == "sauve"):
00427                     meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh)
00428                 else :
00429                     print "the file ",fileName,"has an unknow extension"
00430                     sys.exit(1)
00431 
00432                 meshDriver.open()
00433                 meshDriver.read()
00434 
00435     meshDriver.close()
00436 
00437     meshName = mesh.getName()
00438     spaceDim = mesh.getSpaceDimension()
00439     meshDim = mesh.getMeshDimension()
00440     print "The mesh ",meshName," is a ",spaceDim,"D mesh on a ",meshDim,"D geometry"
00441 
00442     if (extensionFile == "med"):
00443         print "and is mounted via the MED driver"
00444     elif (extensionFile == "sauve"):
00445         print "and is mounted via the GIBI driver"
00446     elif (extensionFile == "inp"):
00447         print "and is mounted via the PORFLOW driver"
00448 
00449     nbNodes = mesh.getNumberOfNodes()
00450     print "The mesh ",meshName," has",nbNodes,"Nodes"
00451     coordSyst = mesh.getCoordinatesSystem()
00452     print "The coordinates system is",coordSyst
00453     print "The Coordinates :"
00454     coordNames = []
00455     coordUnits = []
00456     for isd in range(spaceDim):
00457         coordNames.append(mesh.getCoordinateName(isd))
00458         coordUnits.append(mesh.getCoordinateUnit(isd))
00459 
00460     print "names:", coordNames
00461     print "units", coordUnits
00462     print "values:"
00463     coordinates = mesh.getCoordinates(MED_FULL_INTERLACE)
00464     for k in range(nbNodes):
00465         kp1 = k+1
00466         coords = []
00467         for isd in range(spaceDim):
00468             isdp1 = isd+1
00469             coords.append(mesh.getCoordinate(kp1,isdp1))
00470 
00471         print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)]
00472 
00473     print ""
00474     print "Show the Cell Nodal Connectivity of the Cells:"
00475     nbTypesCell = mesh.getNumberOfTypes(MED_CELL)
00476     print ""
00477     if (nbTypesCell>0):
00478         print "The Mesh has",nbTypesCell,"Type(s) of Cell"
00479         types = mesh.getTypes(MED_CELL)
00480         for k in range(nbTypesCell):
00481             type = types[k]
00482             nbElemType = mesh.getNumberOfElements(MED_CELL,type)
00483             print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)"
00484             connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,type)
00485             nbNodesPerCell = type%100
00486             for j in range(nbElemType):
00487                 print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell]
00488 
00489     print ""
00490     print "Show the Cell Reverse Nodal Connectivity:"
00491     ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL)
00492     ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL)
00493     print ""
00494     for j in range(nbNodes):
00495         begin = ReverseConnectivityIndex[j]-1
00496         end = ReverseConnectivityIndex[j+1]-1
00497         print "Node",(j+1),"-->",ReverseConnectivity[begin:end]
00498 
00499     print ""
00500     print "Show the Cell Descending Connectivity:"
00501     mesh.calculateConnectivity(MED_DESCENDING,MED_CELL)
00502     nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
00503     Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS)
00504     ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL)
00505     print ""
00506     for j in range(nbElemts):
00507         begin = ConnectivityIndex[j]-1
00508         end = ConnectivityIndex[j+1]-1
00509         print "Element",(j+1),"-->",Connectivity[begin:end]
00510 
00511     print ""
00512 
00513     if (spaceDim == 3):
00514         constituent = MED_FACE
00515     elif (spaceDim == 2):
00516         constituent = MED_EDGE
00517 
00518     print "Show the Face/Edge Nodal Connectivity:"
00519     nbTypesConst = mesh.getNumberOfTypes(constituent)
00520     print ""
00521     if (nbTypesConst>0):
00522         print "The Mesh has",nbTypesConst,"Type(s) of Constituent"
00523         types = mesh.getTypes(constituent)
00524         for k in range(nbTypesConst):
00525             type = types[k]
00526             nbElemType = mesh.getNumberOfElements(constituent,type)
00527             print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)"
00528             connectivity = mesh.getConnectivity(MED_NODAL,constituent,type)
00529             nbNodesPerConst = type%100
00530             for j in range(nbElemType):
00531                 print "Element",(j+1)," ",connectivity[j*nbNodesPerConst:(j+1)*nbNodesPerConst]
00532 
00533     if (meshDim == 3):
00534         print ""
00535         print "Show the Face/Edge Reverse Nodal Connectivity:"
00536         ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL,constituent)
00537         ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL,constituent)
00538         print ""
00539         for j in range(nbNodes):
00540             begin = ReverseConnectivityIndex[j]-1
00541             end = ReverseConnectivityIndex[j+1]-1
00542             print "Node",(j+1),"-->",ReverseConnectivity[begin:end]
00543 
00544         print ""
00545         try:
00546             print "Show the Face/Edge Descending Connectivity:"
00547             mesh.calculateConnectivity(MED_DESCENDING,constituent)
00548             nbElemts = mesh.getNumberOfElements(constituent,MED_ALL_ELEMENTS)
00549             Connectivity = mesh.getConnectivity(MED_DESCENDING,constituent,MED_ALL_ELEMENTS)
00550             ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,constituent)
00551             print ""
00552             for j in range(nbElemts):
00553                 begin = ConnectivityIndex[j]-1
00554                 end = ConnectivityIndex[j+1]-1
00555                 print "Element",(j+1),"-->",Connectivity[begin:end]
00556 
00557             print ""
00558         except :
00559             pass
00560 
00561     for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
00562         nbFam = mesh.getNumberOfFamilies(entity)
00563         nbGrp = mesh.getNumberOfGroups(entity)
00564         if (entity == MED_NODE) :
00565             if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)"
00566             if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)"
00567         elif (entity == MED_CELL) :
00568             if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)"
00569             if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)"
00570         elif (entity == MED_FACE) :
00571             if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)"
00572             if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)"
00573         elif (entity == MED_EDGE) :
00574             if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)"
00575             if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)"
00576 
00577     for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
00578         nbFam = mesh.getNumberOfFamilies(entity)
00579         nbGrp = mesh.getNumberOfGroups(entity)
00580         if nbFam > 0:
00581             for j in range(nbFam):
00582                 print ""
00583                 family = mesh.getFamily(entity,j+1)
00584                 familyName = family.getName()
00585                 familyDescription = family.getDescription()
00586                 familyEntity = family.getEntity()
00587                 familyBool = family.isOnAllElements()
00588                 print "  -Name:",familyName
00589                 print "  -Description:",familyDescription
00590                 print "  -Entity:",familyEntity
00591                 familyIdentifier = family.getIdentifier()
00592                 nbOfAtt = family.getNumberOfAttributes()
00593                 print "  -Identifier:",familyIdentifier
00594                 print "  -Number Of Attributes:",nbOfAtt
00595                 attributesids = family.getAttributesIdentifiers()
00596                 attributesvals = family.getAttributesValues()
00597                 for k in range(nbOfAtt):
00598                     print "    * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1)
00599                 nbOfGrp = family.getNumberOfGroups()
00600                 print "  -Number Of Groups:",nbOfGrp
00601                 for k in range(nbOfGrp):
00602                     print "    * Group:",family.getGroupName(k+1)
00603                 print "  -Entities list:"
00604                 if (familyBool):
00605                     print "  -Is on all entities"
00606                 else:
00607                     nbOfTypes = family.getNumberOfTypes()
00608                     types = family.getTypes()
00609                     print "  -Number Of Types:",nbOfTypes
00610                     for k in range(nbOfTypes):
00611                         type = types[k]
00612                         nbOfElmtsOfType = family.getNumberOfElements(type)
00613                         number = family.getNumber(type)
00614                         print "    * Type",type
00615                         print "    * Number",number[0:nbOfElmtsOfType]
00616                     print ""
00617         print ""
00618 
00619         if nbGrp > 0:
00620             for j in range(nbGrp):
00621                 print ""
00622                 group = mesh.getGroup(entity,j+1)
00623                 groupName = group.getName()
00624                 groupDescription = group.getDescription()
00625                 groupEntity = group.getEntity()
00626                 groupBool = group.isOnAllElements()
00627                 print "  -Name:",groupName
00628                 print "  -Description:",groupDescription
00629                 print "  -Entity:",groupEntity
00630                 nbOfFam = group.getNumberOfFamilies()
00631                 print "  -Number Of Families:",nbOfFam
00632                 for k in range(nbOfFam):
00633                     print "    * Family:",group.getFamily(k+1).getName()
00634                 print "  -Entities list:"
00635                 if (groupBool):
00636                     print "  -Is on all entities"
00637                 else:
00638                     nbOfTypes = group.getNumberOfTypes()
00639                     types = group.getTypes()
00640                     print "  -Number Of Types:",nbOfTypes
00641                     for k in range(nbOfTypes):
00642                         type = types[k]
00643                         nbOfElmtsOfType = group.getNumberOfElements(type)
00644                         number = group.getNumber(type)
00645                         print "    * Type",type
00646                         print "    * Number",number[0:nbOfElmtsOfType]
00647                     print ""
00648             print ""
00649 
00650 
00651     print "Saving in file the mesh under the med and vtk format"
00652     print "Med V22 file = ",medV22FileName
00653     print "vtk file = ",vtkFileName
00654 
00655     idMedV22 = mesh.addDriver(MED_DRIVER,medV22FileName,mesh.getName(),RDWR)
00656     mesh.write(idMedV22)
00657 
00658     idVtk = mesh.addDriver(VTK_DRIVER,vtkFileName,mesh.getName())
00659     mesh.write(idVtk)
00660     print ""
00661 
00662     print "Building of the support on all Cells of the mesh."
00663     supportCell = mesh.getSupportOnAll( MED_CELL )
00664     print ""
00665     barycenter = mesh.getBarycenter(supportCell)
00666     print "Getting barycenter of all Cells of the mesh"
00667     for j in range(nbElemts):
00668         barycenterCell = barycenter.getRow(j+1)
00669         print "    * ",barycenterCell[:spaceDim]
00670     print ""
00671 
00672     print "Saving in file the cell barycenter field under the med and vtk format"
00673     print "Med V22 file = ",medV22FileName
00674     print "vtk file = ",vtkFileName
00675 
00676     idMedV22 = barycenter.addDriver(MED_DRIVER,medV22FileName,barycenter.getName())
00677     barycenter.write(idMedV22)
00678 
00679     idVtk = barycenter.addDriver(VTK_DRIVER,vtkFileName,barycenter.getName())
00680     barycenter.write(idVtk)
00681     print ""
00682 
00683     if (spaceDim == 3) and (meshDim == spaceDim) :
00684         print "Getting volume of all Cells of the mesh:"
00685         volume = mesh.getVolume(supportCell)
00686         voltot = 0.
00687         for j in range(nbElemts):
00688             volumeCell = volume.getValueIJ(j+1,1)
00689             print "    * ",volumeCell
00690             voltot = voltot + volumeCell
00691         print "Volume of the mesh:",voltot
00692         print ""
00693 
00694         print "Saving in file the cell volume field under the med and vtk format"
00695         print "Med V22 file = ",medV22FileName
00696         print "vtk file = ",vtkFileName
00697 
00698         idMedV22 = volume.addDriver(MED_DRIVER,medV22FileName,volume.getName())
00699         volume.write(idMedV22)
00700 
00701         idVtk = volume.addDriver(VTK_DRIVER,vtkFileName,volume.getName())
00702         volume.write(idVtk)
00703         print ""
00704 
00705         print "Building of the support on all Faces of the mesh."
00706         supportFace = mesh.getSupportOnAll(MED_FACE)
00707         nbFace = mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)
00708         print ""
00709         print "Getting normal of each face of this support",nbFace
00710         nbTypeFace = mesh.getNumberOfTypes(MED_FACE)
00711         TypeFace = mesh.getTypes(MED_FACE)
00712         print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace]
00713         normal = mesh.getNormal(supportFace)
00714         area = mesh.getArea(supportFace)
00715         for j in range(nbFace):
00716             normalFace = normal.getRow(j+1)
00717             areaFace = area.getRow(j+1)
00718             value1 = normalFace[0]
00719             value2 = normalFace[1]
00720             value3 = normalFace[2]
00721             norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
00722             print "    * ",normalFace[:spaceDim],"norm:",norm," --> area ",areaFace[0]
00723         print ""
00724 
00725         print "Saving in file the face normal field under the med format"
00726         print "Med V22 file = ",medV22FileName
00727 
00728         idMedV22 = normal.addDriver(MED_DRIVER,medV22FileName,normal.getName())
00729         normal.write(idMedV22)
00730 
00731         print "but not in vtk format because vtk does not offer the possibility to view a field on edges or faces"
00732         print ""
00733 
00734     elif (spaceDim == 2) and (meshDim == spaceDim):
00735         print "Getting area on all Cells of the mesh:"
00736         area = mesh.getArea(supportCell)
00737         areatot = 0.
00738         for j in range(nbElemts):
00739             areaCell = area.getValueIJ(j+1,1)
00740             print "    * ",areaCell
00741             areatot = areatot + areaCell
00742         print "Area of the mesh:",areatot
00743         print ""
00744 
00745         print "Saving in file the cell area field under the med and vtk format"
00746         print "Med V22 file = ",medV22FileName
00747         print "vtk file = ",vtkFileName
00748 
00749 
00750         idMedV22 = area.addDriver(MED_DRIVER,medV22FileName,area.getName())
00751         area.write(idMedV22)
00752 
00753         idVtk = area.addDriver(VTK_DRIVER,vtkFileName,area.getName())
00754         area.write(idVtk)
00755         print ""
00756 
00757         print "Building of the support on all Edges of the mesh."
00758         supportEdge = mesh.getSupportOnAll(MED_EDGE)
00759         nbEdge = mesh.getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)
00760         print ""
00761         print "Getting normal of each edge of this support",nbEdge
00762         nbTypeEdge = mesh.getNumberOfTypes(MED_EDGE)
00763         TypeEdge = mesh.getTypes(MED_EDGE)
00764         print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge]
00765         normal = mesh.getNormal(supportEdge)
00766         length = mesh.getLength(supportEdge)
00767         for j in range(nbEdge):
00768             normalEdge = normal.getRow(j+1)
00769             lengthEdge = length.getRow(j+1)
00770             value1 = normalEdge[0]
00771             value2 = normalEdge[1]
00772             norm = (value1*value1 + value2*value2)**(0.5)
00773             print "    * ",normalEdge[:spaceDim],"norm:",norm," --> length ",lengthEdge[0]
00774         print ""
00775 
00776         print "Saving in file the face normal field under the med format"
00777         print "Med V22 file = ",medV22FileName
00778 
00779         idMedV22 = normal.addDriver(MED_DRIVER,medV22FileName,normal.getName())
00780         normal.write(idMedV22)
00781 
00782         print "but no in vtk format because vtk does not offer the possibility to view a field on edges or faces"
00783 
00784     print ""
00785     print "Building support on Elements of the boundary"
00786     if (spaceDim == 3) and (meshDim == spaceDim) :
00787         suppBound = mesh.getBoundaryElements(MED_FACE)
00788         nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
00789         print "Getting normal field on the boundary",nbElmBound
00790         normalBound = mesh.getNormal(suppBound)
00791         numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS)
00792         for j in range(nbElmBound):
00793             valInd = numberSuppBound[j]
00794             normalBoundJ = normalBound.getRow(valInd)
00795             value1 = normalBoundJ[0]
00796             value2 = normalBoundJ[1]
00797             value3 = normalBoundJ[2]
00798             norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
00799             print "    * ",normalBoundJ[:spaceDim],"norm:",norm
00800     elif (spaceDim == 2) and (meshDim == spaceDim):
00801         suppBound = mesh.getBoundaryElements(MED_EDGE)
00802         nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
00803         print "Getting normal field on the boundary",nbElmBound
00804         normalBound = mesh.getNormal(suppBound)
00805         numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS)
00806         for j in range(nbElmBound):
00807             valInd = numberSuppBound[j]
00808             normalBoundJ = normalBound.getRow(valInd)
00809             value1 = normalBoundJ[0]
00810             value2 = normalBoundJ[1]
00811             norm = (value1*value1 + value2*value2)**(0.5)
00812             print "    * ",normalBoundJ[:spaceDim],"norm:",norm
00813     print ""
00814 
00815     if (extensionFile == "med"):
00816         md = MEDFILEBROWSER(fileFull)
00817 
00818         nbMeshes = md.getNumberOfMeshes()
00819         nbFields = md.getNumberOfFields()
00820 
00821         print "The med file", fileName, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
00822 
00823         if (nbMeshes>0):
00824             print "Mesh(es) Name(s) is(are) "
00825 
00826             for imsh in range(nbMeshes):
00827                 mesh_name = md.getMeshName(imsh)
00828                 print "   - ",mesh_name
00829         print ""
00830         if (nbFields>0):
00831             print "Field(s) Name(s) is(are) "
00832 
00833             for ifld in range(nbFields):
00834                 field_name = md.getFieldName(ifld)
00835                 print "   - ",field_name
00836 
00837         print ""
00838 
00839 #        mesh_name = md.getMeshName(0)
00840         mesh_name = meshNames[i]
00841         if md.isStructuredMesh( mesh_name ):
00842             mesh = GRID(MED_DRIVER,md.getFileName(),mesh_name)
00843         else:
00844             mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name)
00845         spaceDim = mesh.getSpaceDimension()
00846         meshDim = mesh.getMeshDimension()
00847         nbNodes = mesh.getNumberOfNodes()
00848         print "The first mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes"
00849 
00850         if (nbFields>0):
00851             print "Field(s) Analysis "
00852             for ifld in range(nbFields):
00853                 field_name = md.getFieldName(ifld)
00854                 dtits = md.getFieldIteration(field_name)
00855                 print "The",print_ord(ifld),"field is",field_name,"with",len(dtits),"iteration(s)"
00856                 for dtitfield in dtits:
00857                     dt = dtitfield.getdt()
00858                     it = dtitfield.getit()
00859                     type = md.getFieldType(field_name)
00860                     print "     * Iteration:",dt,"Order number:",it,"Type:",type
00861                     if type == MED_INT32:
00862                         fieldint = FIELDINT(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh)
00863                         name = fieldint.getName()
00864                         desc = fieldint.getDescription()
00865                         nbOfComp = fieldint.getNumberOfComponents()
00866                         print "     Field",name," : ",desc
00867                         print "     Number Of Components:",nbOfComp
00868                         iterationNb = fieldint.getIterationNumber()
00869                         orderNb = fieldint.getOrderNumber()
00870                         time = fieldint.getTime()
00871                         print "     Iteration Number",iterationNb
00872                         print "     Order Number",orderNb
00873                         print "     Time",time
00874                         print "     Norme  2  : ", fieldint.norm2()
00875                         print "     Norme Max : ", fieldint.normMax()
00876 
00877                         if fieldint.getSupport().getEntity()!=MED_NODE:
00878                             fieldint_vol=fieldint.getSupport().getMesh().getVolume(fieldint.getSupport())
00879                             print "     Norme L1  : ", fieldint.normL1()
00880                             print "     Norme L2  : ", fieldint.normL2()
00881                             print "     Norme L2(vol) : ", fieldint.normL2(fieldint_vol)
00882 
00883                         for k in range(nbOfComp):
00884                             kp1 = k+1
00885                             compName = fieldint.getComponentName(kp1)
00886                             compDesc = fieldint.getComponentDescription(kp1)
00887                             compUnit = fieldint.getMEDComponentUnit(kp1)
00888                             print "      * Component:",kp1
00889                             print "          Name:",compName
00890                             print "          Description:",compDesc
00891                             print "          Unit:",compUnit
00892                             if fieldint.getSupport().getEntity()!=MED_NODE:
00893                                 print "          Norme L1  : ", fieldint.normL1(kp1)
00894                                 print "          Norme L2  : ", fieldint.normL2(kp1)
00895                                 print "          Norme L2(vol) : ", fieldint.normL2(kp1,fieldint_vol)
00896 
00897                         support = fieldint.getSupport()
00898                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
00899                         print "     Values:",nbOf
00900                         for k in range(nbOf):
00901                             valueI = fieldint.getRow(k+1)
00902                             print "     *",valueI[:nbOfComp]
00903                         fieldint2 = FIELDINT(fieldint)
00904                         print ""
00905                         fieldintadd = fieldint + fieldint2
00906                         print "Test of the addition of two integer fields with creation a new one"
00907                         print ""
00908                         name = fieldintadd.getName()
00909                         desc = fieldintadd.getDescription()
00910                         nbOfComp = fieldintadd.getNumberOfComponents()
00911                         print "     Field",name," : ",desc
00912                         print "     Number Of Components:",nbOfComp
00913                         iterationNb = fieldintadd.getIterationNumber()
00914                         orderNb = fieldintadd.getOrderNumber()
00915                         time = fieldintadd.getTime()
00916                         print "     Iteration Number",iterationNb
00917                         print "     Order Number",orderNb
00918                         print "     Time",time
00919                         for k in range(nbOfComp):
00920                             kp1 = k+1
00921                             compName = fieldintadd.getComponentName(kp1)
00922                             compDesc = fieldintadd.getComponentDescription(kp1)
00923                             compUnit = fieldintadd.getMEDComponentUnit(kp1)
00924                             print "      * Component:",kp1
00925                             print "          Name:",compName
00926                             print "          Description:",compDesc
00927                             print "          Unit:",compUnit
00928 
00929                         support = fieldintadd.getSupport()
00930                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
00931                         print "     Values:",nbOf
00932                         for k in range(nbOf):
00933                             valueI = fieldintadd.getRow(k+1)
00934                             print "     *",valueI[:nbOfComp]
00935                         print ""
00936                         fieldintsub = fieldint - fieldint2
00937                         print "Test of the substraction of two integer fields with creation a new one"
00938                         print ""
00939                         name = fieldintsub.getName()
00940                         desc = fieldintsub.getDescription()
00941                         nbOfComp = fieldintsub.getNumberOfComponents()
00942                         print "     Field",name," : ",desc
00943                         print "     Number Of Components:",nbOfComp
00944                         iterationNb = fieldintsub.getIterationNumber()
00945                         orderNb = fieldintsub.getOrderNumber()
00946                         time = fieldintsub.getTime()
00947                         print "     Iteration Number",iterationNb
00948                         print "     Order Number",orderNb
00949                         print "     Time",time
00950                         for k in range(nbOfComp):
00951                             kp1 = k+1
00952                             compName = fieldintsub.getComponentName(kp1)
00953                             compDesc = fieldintsub.getComponentDescription(kp1)
00954                             compUnit = fieldintsub.getMEDComponentUnit(kp1)
00955                             print "      * Component:",kp1
00956                             print "          Name:",compName
00957                             print "          Description:",compDesc
00958                             print "          Unit:",compUnit
00959 
00960                         support = fieldintsub.getSupport()
00961                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
00962                         print "     Values:",nbOf
00963                         for k in range(nbOf):
00964                             valueI = fieldintsub.getRow(k+1)
00965                             print "     *",valueI[:nbOfComp]
00966                         print ""
00967                         fieldintmul = fieldint * fieldint2
00968                         print "Test of the multiplication of two integer fields with creation a new one"
00969                         print ""
00970                         name = fieldintmul.getName()
00971                         desc = fieldintmul.getDescription()
00972                         nbOfComp = fieldintmul.getNumberOfComponents()
00973                         print "     Field",name," : ",desc
00974                         print "     Number Of Components:",nbOfComp
00975                         iterationNb = fieldintmul.getIterationNumber()
00976                         orderNb = fieldintmul.getOrderNumber()
00977                         time = fieldintmul.getTime()
00978                         print "     Iteration Number",iterationNb
00979                         print "     Order Number",orderNb
00980                         print "     Time",time
00981                         for k in range(nbOfComp):
00982                             kp1 = k+1
00983                             compName = fieldintmul.getComponentName(kp1)
00984                             compDesc = fieldintmul.getComponentDescription(kp1)
00985                             compUnit = fieldintmul.getMEDComponentUnit(kp1)
00986                             print "      * Component:",kp1
00987                             print "          Name:",compName
00988                             print "          Description:",compDesc
00989                             print "          Unit:",compUnit
00990 
00991                         support = fieldintmul.getSupport()
00992                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
00993                         print "     Values:",nbOf
00994                         for k in range(nbOf):
00995                             valueI = fieldintmul.getRow(k+1)
00996                             print "     *",valueI[:nbOfComp]
00997                         print ""
00998                         try:
00999                             fieldintdiv = fieldint / fieldint2
01000                             print "Test of the division of two integer fields with creation a new one"
01001                             print ""
01002                             name = fieldintdiv.getName()
01003                             desc = fieldintdiv.getDescription()
01004                             nbOfComp = fieldintdiv.getNumberOfComponents()
01005                             print "     Field",name," : ",desc
01006                             print "     Number Of Components:",nbOfComp
01007                             iterationNb = fieldintdiv.getIterationNumber()
01008                             orderNb = fieldintdiv.getOrderNumber()
01009                             time = fieldintdiv.getTime()
01010                             print "     Iteration Number",iterationNb
01011                             print "     Order Number",orderNb
01012                             print "     Time",time
01013                             for k in range(nbOfComp):
01014                                 kp1 = k+1
01015                                 compName = fieldintdiv.getComponentName(kp1)
01016                                 compDesc = fieldintdiv.getComponentDescription(kp1)
01017                                 compUnit = fieldintdiv.getMEDComponentUnit(kp1)
01018                                 print "      * Component:",kp1
01019                                 print "          Name:",compName
01020                                 print "          Description:",compDesc
01021                                 print "          Unit:",compUnit
01022 
01023                             support = fieldintdiv.getSupport()
01024                             nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
01025                             print "     Values:",nbOf
01026                             for k in range(nbOf):
01027                                 valueI = fieldintdiv.getRow(k+1)
01028                                 print "     *",valueI[:nbOfComp]
01029                             print ""
01030                             print "TESTS OPERATIONS SUR FIELDINT : "
01031                         except:
01032                             print "testMedMemGeneral  fieldintdiv = fieldint / fieldint2 catch/except error"
01033                         fieldintadd = fieldint+fieldint2
01034                         fieldintsub = fieldint-fieldint2
01035                         fieldintmul = fieldint*fieldint2
01036                         try:
01037                             fieldintdiv = fieldint/fieldint2
01038                         except:
01039                             fieldintdiv = None
01040                             print "testMedMemGeneral  fieldintdiv = fieldint/fieldint2 catch/except error"
01041                         fieldintasso = fieldint+fieldint*fieldint
01042                         fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2)
01043 
01044                         print " f1     : ",fieldint.getValue()
01045                         print " f2     : ",fieldint2.getValue()
01046                         print "--------------------------------------------------------------------------------------------------------------"
01047                         print "  +     : ",fieldintadd.getValue()
01048                         print "  -     : ",fieldintsub.getValue()
01049                         print "  *     : ",fieldintmul.getValue()
01050                         if fieldintdiv == None :
01051                             print "testMedMemGeneral   /     : None"
01052                         else:
01053                             print "  /     : ",fieldintdiv.getValue()
01054                         fieldint+=fieldint2;
01055                         print "  +=    : ",fieldint.getValue()
01056                         fieldint-=fieldint2;
01057                         print "  -=    : ",fieldint.getValue()
01058                         fieldint*=fieldint2;
01059                         print "  *=    : ",fieldint.getValue()
01060                         try:
01061                             fieldint/=fieldint2;
01062                             print "  /=    : ",fieldint.getValue()
01063                         except :
01064                             fieldint = None
01065                             print "  /=    : Catch/Except : None"
01066                         print "f1+f2*f2: ",fieldintasso.getValue()
01067                         if fieldint != None :
01068                             fieldint.applyLin(4,1);
01069                             print " 4f1+1  : ",fieldint.getValue()
01070                         print " f1.f2  : ",fieldintSP.getValue()
01071                         fieldint2.applyPyFunc(add_one)
01072                         print " CB:f2+1: ",fieldint2.getValue()
01073                     elif type == MED_REEL64:
01074                         fielddouble = FIELDDOUBLE(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh)
01075                         name = fielddouble.getName()
01076                         desc = fielddouble.getDescription()
01077                         nbOfComp = fielddouble.getNumberOfComponents()
01078                         print "     Field",name," : ",desc
01079                         print "     Number Of Components:",nbOfComp
01080                         iterationNb = fielddouble.getIterationNumber()
01081                         orderNb = fielddouble.getOrderNumber()
01082                         time = fielddouble.getTime()
01083                         print "     Iteration Number",iterationNb
01084                         print "     Order Number",orderNb
01085                         print "     Time",time
01086                         print "     Norme  2  : ", fielddouble.norm2()
01087                         print "     Norme Max : ", fielddouble.normMax()
01088                         fielddouble.getSupport().update()
01089                         fieldEntity = fielddouble.getSupport().getEntity()
01090                         print "try sobolev",fieldEntity
01091                         if fieldEntity !=MED_NODE:
01092                             if (fieldEntity == MED_CELL):
01093                                 if (spaceDim == 3):
01094                                     fielddouble_vol=fielddouble.getSupport().getMesh().getVolume(fielddouble.getSupport())
01095                                 elif (spaceDim == 2):
01096                                     fielddouble_vol=fielddouble.getSupport().getMesh().getArea(fielddouble.getSupport())
01097                             elif (fieldEntity == MED_FACE):
01098                                 fielddouble_vol=fielddouble.getSupport().getMesh().getArea(fielddouble.getSupport())
01099                             elif (fieldEntity == MED_EDGE):
01100                                 fielddouble_vol=fielddouble.getSupport().getMesh().getLength(fielddouble.getSupport())
01101                             print "Norme L1  : ", fielddouble.normL1()
01102                             print "Norme L2  : ", fielddouble.normL2()
01103                             print "Norme L2(vol) : ", fielddouble.normL2(fielddouble_vol)
01104 
01105                         for k in range(nbOfComp):
01106                             kp1 = k+1
01107                             compName = fielddouble.getComponentName(kp1)
01108                             compDesc = fielddouble.getComponentDescription(kp1)
01109                             compUnit = fielddouble.getMEDComponentUnit(kp1)
01110                             print "      * Component:",kp1
01111                             print "          Name:",compName
01112                             print "          Description:",compDesc
01113                             print "          Unit:",compUnit
01114                             if fielddouble.getSupport().getEntity()!=MED_NODE:
01115                                 print "          Norme L1  : ", fielddouble.normL1(kp1)
01116                                 print "          Norme L2  : ", fielddouble.normL2(kp1)
01117                                 print "          Norme L2(vol) : ", fielddouble.normL2(kp1, fielddouble_vol)
01118 
01119                         support = fielddouble.getSupport()
01120                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
01121                         print "     Values:",nbOf
01122                         for k in range(nbOf):
01123                             valueI = fielddouble.getRow(k+1)
01124                             print "     *",valueI[:nbOfComp]
01125                         fielddouble2 = FIELDDOUBLE(fielddouble)
01126                         print ""
01127                         fielddoubleadd = fielddouble + fielddouble2
01128                         print "Test of the addition of two double fields with creation a new one"
01129                         print ""
01130                         name = fielddoubleadd.getName()
01131                         desc = fielddoubleadd.getDescription()
01132                         nbOfComp = fielddoubleadd.getNumberOfComponents()
01133                         print "     Field",name," : ",desc
01134                         print "     Number Of Components:",nbOfComp
01135                         iterationNb = fielddoubleadd.getIterationNumber()
01136                         orderNb = fielddoubleadd.getOrderNumber()
01137                         time = fielddoubleadd.getTime()
01138                         print "     Iteration Number",iterationNb
01139                         print "     Order Number",orderNb
01140                         print "     Time",time
01141                         for k in range(nbOfComp):
01142                             kp1 = k+1
01143                             compName = fielddoubleadd.getComponentName(kp1)
01144                             compDesc = fielddoubleadd.getComponentDescription(kp1)
01145                             compUnit = fielddoubleadd.getMEDComponentUnit(kp1)
01146                             print "      * Component:",kp1
01147                             print "          Name:",compName
01148                             print "          Description:",compDesc
01149                             print "          Unit:",compUnit
01150 
01151                         support = fielddoubleadd.getSupport()
01152                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
01153                         print "     Values:",nbOf
01154                         for k in range(nbOf):
01155                             valueI = fielddoubleadd.getRow(k+1)
01156                             print "     *",valueI[:nbOfComp]
01157                         print ""
01158                         fielddoublesub = fielddouble - fielddouble2
01159                         print "Test of the substraction of two double fields with creation a new one"
01160                         print ""
01161                         name = fielddoublesub.getName()
01162                         desc = fielddoublesub.getDescription()
01163                         nbOfComp = fielddoublesub.getNumberOfComponents()
01164                         print "     Field",name," : ",desc
01165                         print "     Number Of Components:",nbOfComp
01166                         iterationNb = fielddoublesub.getIterationNumber()
01167                         orderNb = fielddoublesub.getOrderNumber()
01168                         time = fielddoublesub.getTime()
01169                         print "     Iteration Number",iterationNb
01170                         print "     Order Number",orderNb
01171                         print "     Time",time
01172                         for k in range(nbOfComp):
01173                             kp1 = k+1
01174                             compName = fielddoublesub.getComponentName(kp1)
01175                             compDesc = fielddoublesub.getComponentDescription(kp1)
01176                             compUnit = fielddoublesub.getMEDComponentUnit(kp1)
01177                             print "      * Component:",kp1
01178                             print "          Name:",compName
01179                             print "          Description:",compDesc
01180                             print "          Unit:",compUnit
01181 
01182                         support = fielddoublesub.getSupport()
01183                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
01184                         print "     Values:",nbOf
01185                         for k in range(nbOf):
01186                             valueI = fielddoublesub.getRow(k+1)
01187                             print "     *",valueI[:nbOfComp]
01188                         print ""
01189                         fielddoublemul = fielddouble * fielddouble2
01190                         print "Test of the multiplication of two double fields with creation a new one"
01191                         print ""
01192                         name = fielddoublemul.getName()
01193                         desc = fielddoublemul.getDescription()
01194                         nbOfComp = fielddoublemul.getNumberOfComponents()
01195                         print "     Field",name," : ",desc
01196                         print "     Number Of Components:",nbOfComp
01197                         iterationNb = fielddoublemul.getIterationNumber()
01198                         orderNb = fielddoublemul.getOrderNumber()
01199                         time = fielddoublemul.getTime()
01200                         print "     Iteration Number",iterationNb
01201                         print "     Order Number",orderNb
01202                         print "     Time",time
01203                         for k in range(nbOfComp):
01204                             kp1 = k+1
01205                             compName = fielddoublemul.getComponentName(kp1)
01206                             compDesc = fielddoublemul.getComponentDescription(kp1)
01207                             compUnit = fielddoublemul.getMEDComponentUnit(kp1)
01208                             print "      * Component:",kp1
01209                             print "          Name:",compName
01210                             print "          Description:",compDesc
01211                             print "          Unit:",compUnit
01212 
01213                         support = fielddoublemul.getSupport()
01214                         nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
01215                         print "     Values:",nbOf
01216                         for k in range(nbOf):
01217                             valueI = fielddoublemul.getRow(k+1)
01218                             print "     *",valueI[:nbOfComp]
01219                         print ""
01220                         try:
01221                             fielddoublediv = fielddouble / fielddouble2
01222                             print "Test of the division of two double fields with creation a new one"
01223                             print ""
01224                             name = fielddoublediv.getName()
01225                             desc = fielddoublediv.getDescription()
01226                             nbOfComp = fielddoublediv.getNumberOfComponents()
01227                             print "     Field",name," : ",desc
01228                             print "     Number Of Components:",nbOfComp
01229                             iterationNb = fielddoublediv.getIterationNumber()
01230                             orderNb = fielddoublediv.getOrderNumber()
01231                             time = fielddoublediv.getTime()
01232                             print "     Iteration Number",iterationNb
01233                             print "     Order Number",orderNb
01234                             print "     Time",time
01235                             for k in range(nbOfComp):
01236                                 kp1 = k+1
01237                                 compName = fielddoublediv.getComponentName(kp1)
01238                                 compDesc = fielddoublediv.getComponentDescription(kp1)
01239                                 compUnit = fielddoublediv.getMEDComponentUnit(kp1)
01240                                 print "      * Component:",kp1
01241                                 print "          Name:",compName
01242                                 print "          Description:",compDesc
01243                                 print "          Unit:",compUnit
01244 
01245                             support = fielddoublediv.getSupport()
01246                             nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
01247                             print "     Values:",nbOf
01248                             for k in range(nbOf):
01249                                 valueI = fielddoublediv.getRow(k+1)
01250                                 print "     *",valueI[:nbOfComp]
01251                         except:
01252                             print "testMedMemGeneral  fielddoublediv = fielddouble / fielddouble2 catch/except error"
01253 
01254                         print ""
01255                         print "TESTS OPERATIONS SUR FIELDDOUBLE : "
01256                         fielddoublesub = fielddouble-fielddouble2
01257                         fielddoublemul = fielddouble*fielddouble2
01258                         try:
01259                             fielddoublediv = fielddouble/fielddouble2
01260                         except:
01261                             print "testMedMemGeneral    /=    : catch/except error"
01262                             fielddoublediv = None
01263                         fielddoubleasso = fielddouble+fielddouble2*fielddouble2
01264                         fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2)
01265                         print " f1     : ",fielddouble.getValue()
01266                         print " f2     : ",fielddouble2.getValue()
01267                         print "--------------------------------------------------------------------------------------------------------------"
01268                         print "  +     : ",fielddoubleadd.getValue()
01269                         print "  -     : ",fielddoublesub.getValue()
01270                         print "  *     : ",fielddoublemul.getValue()
01271                         if fielddoublediv != None:
01272                             print "  /     : ",fielddoublediv.getValue()
01273                             pass
01274                         fielddouble+=fielddouble2;
01275                         print "  +=    : ",fielddouble.getValue()
01276                         fielddouble-=fielddouble2;
01277                         print "  -=    : ",fielddouble.getValue()
01278                         fielddouble*=fielddouble2;
01279                         print "  *=    : ",fielddouble.getValue()
01280                         try:
01281                             fielddouble/=fielddouble2;
01282                             print "  /=    : ",fielddouble.getValue()
01283                         except:
01284                             print "testMedMemGeneral   /=    : "
01285                         print "f1+f2*f2: ",fielddoubleasso.getValue()
01286                         fielddouble.applyLin(4,1);
01287                         print " 4f1+1  : ",fielddouble.getValue()
01288                         print " f1.f2  : ",fielddoubleSP.getValue()
01289                         fielddouble2.applyPyFunc(add_one)
01290                         print " CB:f2+1: ",fielddouble2.getValue()
01291                     else:
01292                         print "  !!!! Bad type of Field !!!!"
01293 
01294 print "END of the Pyhton script ..... Ctrl D to exit"