Back to index

salome-med  6.5.0
Functions | Variables
dumpMEDMEM Namespace Reference

Functions

def _showNodalConnectivity
def _showSupport
def ShowFamily
 Dump i-th family of given entity in mesh.
def ShowFamilies
 Dump all families in mesh.
def ShowGroup
 Dump a GROUP.
def ShowGroups
 Dump all GROUP's in mesh.
def ShowMesh
 Dump mesh general information.
def ShowFields
 Dump all FIELD's in MED.
def ReadFields
 Read all fields in MED.
def supprimer
def deleteFile

Variables

dictionary theEntityName
dictionary theTypeName
dictionary medModeSwitch
dictionary med_type_champ
string tab = " "
 debugShowConn = True
int SHOW_ALL = 1

Function Documentation

def dumpMEDMEM._showNodalConnectivity (   mesh,
  entity,
  type,
  elems,
  tablevel,
  showOnly = SHOW_ALL 
) [private]

Definition at line 73 of file dumpMEDMEM.py.

00073 
00074 def _showNodalConnectivity(mesh,entity,type,elems,tablevel,showOnly=SHOW_ALL):
00075     if debugShowConn: print "ELEMENTS:",elems
00076     tab1 = tab*tablevel
00077     tab2 = tab*(tablevel+1)
00078     typeName = theTypeName[type]
00079     nbElem = len( elems )
00080     if showOnly > 0:
00081         elems = elems[:showOnly]
00082     nbShow = len( elems )
00083     connectivity = mesh.getConnectivity(MED_NODAL,entity,MED_ALL_ELEMENTS)
00084     index = mesh.getConnectivityIndex(MED_NODAL,entity)
00085     if debugShowConn: print "CONN:",connectivity,"\nIND:",index
00086     elemShift = 0
00087     types = mesh.getTypes( entity )
00088     for t in types:
00089         if t != type:
00090             elemShift += mesh.getNumberOfElements(entity,t)
00091         else:
00092             break
00093         pass
00094     for i in elems:
00095         elem = i + elemShift
00096         print tab1,typeName,i,":",connectivity[index[elem-1]-1 : index[elem]-1]
00097         pass
00098     nbSkip = nbElem - nbShow
00099     if nbSkip > 0:
00100         print tab1,"...",nbSkip,"elements not shown"
00101         pass
00102     pass
00103 
#private

Here is the caller graph for this function:

def dumpMEDMEM._showSupport (   support,
  tablevel,
  showElems = 0 
) [private]

Definition at line 104 of file dumpMEDMEM.py.

00104 
00105 def _showSupport(support, tablevel,showElems=0):
00106     tab1 = tab*(tablevel+0)
00107     tab2 = tab*(tablevel+1)
00108     tab3 = tab*(tablevel+3)
00109     entity    = support.getEntity()
00110     types     = support.getTypes()
00111     nbOfTypes = support.getNumberOfTypes()
00112     onAll     = support.isOnAllElements()
00113     print tab1,"-Entity:",theEntityName[entity]
00114     print tab1,"-Types :",types
00115     print tab1,"-Elements"
00116     if onAll:
00117         print tab2,"<< Is on all elements >>"
00118     else:
00119         for type in types:
00120             nbOfElmtsOfType = support.getNumberOfElements(type)
00121             number = support.getNumber(type)
00122             number.sort()
00123             print tab2,"* Type:",theTypeName[type]
00124             print     tab3,". Nb elements:",nbOfElmtsOfType
00125             print     tab3,". Numbers:",number[:min(100,nbOfElmtsOfType)],
00126             if nbOfElmtsOfType > 100:
00127                 print "...skip", nbOfElmtsOfType-100
00128             else:
00129                 print
00130                 pass
00131             if entity != MED_NODE and showElems:
00132                 print tab3,". Nodal connectivity"
00133                 _showNodalConnectivity(support.getMesh(),entity,type,number,tablevel+4,showElems)
00134                 pass
00135             pass
00136         pass
00137     print
00138     return

Here is the call graph for this function:

Here is the caller graph for this function:

def dumpMEDMEM.deleteFile (   f)

Definition at line 495 of file dumpMEDMEM.py.

00495 
00496 def deleteFile( f ):
00497     supprimer( f )

Here is the call graph for this function:

def dumpMEDMEM.ReadFields (   med)

Read all fields in MED.

Definition at line 453 of file dumpMEDMEM.py.

00453 
00454 def ReadFields(med):
00455     nbFields = med.getNumberOfFields()
00456     if (nbFields>0):
00457         print 'READ FIELDs ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
00458         med.updateSupport()
00459         for i in range(nbFields):
00460             field_name = med.getFieldName(i)
00461             nbOfIt = med.getFieldNumberOfIteration(field_name)
00462             print '  The field is',field_name,'with',nbOfIt,'iteration(s)'
00463             for j in range(nbOfIt):
00464                 dtitfield = med.getFieldIteration(field_name,j)
00465                 dt = dtitfield.getdt()
00466                 it = dtitfield.getit()
00467                 field = med.getField(field_name,dt,it)
00468                 type = field.getValueType()
00469                 print '     * Iteration:',dt,'Order number:',it,'Type:',type
00470                 mode = field.getInterlacingType()
00471                 if type == MED_INT32:
00472                     if mode == MED_FULL_INTERLACE:
00473                         fieldint = createFieldIntFromField(field)
00474                     else:
00475                         fieldint = createFieldIntNoInterlaceFromField( field )
00476                     print '     Reading',fieldint.getName(),'...'
00477                     fieldint.read()
00478                 elif type == MED_REEL64:
00479                     if mode == MED_FULL_INTERLACE:
00480                         f = createFieldDoubleFromField(field)
00481                     else:
00482                         f = createFieldDoubleNoInterlaceFromField( field )
00483                     print '     Reading',f.getName(),'...'
00484                     f.read()
00485                 else:
00486                     print '  !!!! Bad type of Field !!!!'
00487 
00488 # Remove a file if it exists

def dumpMEDMEM.ShowFamilies (   mesh,
  showElems = 0 
)

Dump all families in mesh.

Optionally dump nodal connectivity of <showElems> first elements of each family. Use showElems=SHOW_ALL to dump connectivity of all elements.

Definition at line 176 of file dumpMEDMEM.py.

00176 
00177 def ShowFamilies(mesh, showElems=0):
00178     line = "families in mesh <" + mesh.getName() + ">"
00179     print "\n",line,"\n","-"*len(line)
00180     for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
00181         nbFam = mesh.getNumberOfFamilies(entity)
00182         for i in range(nbFam):
00183             ShowFamily(mesh,entity,i+1,showElems)
00184         pass
00185     print

Here is the call graph for this function:

def dumpMEDMEM.ShowFamily (   mesh,
  entity,
  i,
  showElems = 0 
)

Dump i-th family of given entity in mesh.

Optionally dump nodal connectivity of <showElems> first elements. Use showElems=SHOW_ALL to dump connectivity of all elements.

Definition at line 143 of file dumpMEDMEM.py.

00143 
00144 def ShowFamily(mesh, entity, i, showElems=0):
00145     family = mesh.getFamily(entity,i)
00146     familyName = family.getName()
00147     familyDescription = family.getDescription()
00148     entity = family.getEntity()
00149     familyBool = family.isOnAllElements()
00150     print "\nFAMILY", i, "on", theEntityName[entity]
00151     print tab*1,"-Name       :",familyName
00152     print tab*1,"-Description:",familyDescription
00153     familyIdentifier = family.getIdentifier()
00154     nbOfAtt = family.getNumberOfAttributes()
00155     print tab*1,"-Identifier :",familyIdentifier
00156     print tab*1,"-Attributes"
00157     attributesids = family.getAttributesIdentifiers()
00158     attributesvals = family.getAttributesValues()
00159     for k in range(nbOfAtt):
00160         print tab*2,"* Id         :",attributesids[k]
00161         print tab*2,"* Value      :",attributesvals[k]
00162         print tab*2,"* Description:",family.getAttributeDescription(k+1)
00163         pass
00164     nbOfGrp = family.getNumberOfGroups()
00165     print tab*1,"-Nb Of Groups:",nbOfGrp
00166     print tab*1,"-Groups:"
00167     for k in range(nbOfGrp):
00168         print tab*2,k+1,":",family.getGroupName(k+1)
00169         pass
00170     _showSupport(family,1,showElems)
00171     return

Here is the call graph for this function:

Here is the caller graph for this function:

def dumpMEDMEM.ShowFields (   fields,
  showValues = 0 
)

Dump all FIELD's in MED.

Optionally dump <showValues> first values. Use showValues=SHOW_ALL to dump all values.

Definition at line 330 of file dumpMEDMEM.py.

00330 
00331 def ShowFields( fields, showValues=0 ):
00332     nbFields = len(fields)
00333     print "---------------------- Fields-------------------------"
00334     print "Nb fields", nbFields
00335     for (iField, f ) in enumerate( fields ):
00336         sup       = f.getSupport()
00337         name      = f.getName()
00338         desc      = f.getDescription()
00339         itnb      = f.getIterationNumber()
00340         time      = f.getTime()
00341         order     = f.getOrderNumber()
00342         ftype     = f.getValueType()
00343         mode      = f.getInterlacingType()
00344         nbcomp    = f.getNumberOfComponents()
00345         nbval     = f.getNumberOfValues()
00346         nbelem    = sup.getNumberOfElements(MED_ALL_ELEMENTS)
00347         nbOfTypes = sup.getNumberOfTypes()
00348         types     = sup.getTypes()
00349         isOnAll   = sup.isOnAllElements()
00350         print '\nFIELD',iField
00351         print tab*1,'-Name             : "%s"' % name
00352         print tab*1,'-Description      : "%s"' % desc
00353         print tab*1,'-IterationNumber  :  %s' % itnb
00354         print tab*1,'-Time             :  %s' % time
00355         print tab*1,'-OrderNumber      :  %s' % order
00356         print tab*1,'-Nb Values        :  %s' % nbval
00357         print tab*1,'-Nb Supp. Elements:  %s' % nbelem
00358         print tab*1,'-Nb Componenets   :  %s' % nbcomp
00359         print tab*1,'-ValueType        :  %s' % med_type_champ[ftype]
00360         print tab*1,'-Interlace        :  %s' % medModeSwitch[mode]
00361         print tab*1,'-Conponents'
00362         for k in range(nbcomp):
00363             kp1 = k+1
00364             compName = f.getComponentName(kp1)
00365             compDesc = f.getComponentDescription(kp1)
00366             compUnit = f.getMEDComponentUnit(kp1)
00367             print     tab*2,kp1,'*Name       : "%s"' % compName
00368             try:
00369                 print tab*2,'  *Description: "%s"' % compDesc
00370             except:
00371                 print 'INVALID'
00372                 pass
00373             try:
00374                 print tab*2,'  *Unit       : "%s"' % compUnit
00375             except:
00376                 print 'INVALID'
00377                 pass
00378             pass
00379         print tab*1,'-MESH             : "%s"' % sup.getMeshName()
00380         print tab*1,'-SUPPORT          : "%s"' % sup.getName()
00381         print tab*1,'-On all elements  :  %s' % bool(isOnAll)
00382         print tab*1,'-Types            :  %s'  % types
00383 
00384         if ftype == MED_REEL64:
00385             if mode == MED_FULL_INTERLACE:
00386                 f = createFieldDoubleFromField(f)
00387             else:
00388                 f = createFieldDoubleNoInterlaceFromField( f )
00389                 pass
00390             pass
00391         elif ftype == MED_INT32:
00392             if mode == MED_FULL_INTERLACE:
00393                 f = createFieldIntFromField(f)
00394             else:
00395                 f = createFieldIntNoInterlaceFromField( f )
00396                 pass
00397             pass
00398         else:
00399             print tab*1,'<< Unknown field type >>:',ftype
00400             continue
00401         nbGauss = 1
00402         hasGauss = False
00403         if nbcomp == 0:
00404             nbGauss = 0
00405         else:
00406             hasGauss = f.getGaussPresence()
00407             pass
00408         if hasGauss:
00409             nbGaussByType = f.getNumberOfGaussPoints()
00410             pass
00411         for k in range(nbOfTypes):
00412             type = types[k]
00413             nbOfElmtsOfType = sup.getNumberOfElements(type)
00414             if hasGauss: nbGauss = nbGaussByType[ k ]
00415             if type == 0: type = MED_POINT1
00416             print tab*2,k+1,theTypeName[type],':',nbOfElmtsOfType, 'elements,',\
00417                   nbGauss,'gauss point(s)'
00418             pass
00419         nbOf = sup.getNumberOfElements(MED_ALL_ELEMENTS)
00420         elements = []
00421         if not isOnAll:
00422             elements = sup.getNumber(MED_ALL_ELEMENTS)
00423             pass
00424         if nbcomp == 0:
00425             nbOf = 0
00426             print tab*1,'-Nb Values        :',nbOf
00427             #value = f.getValue(MED_FULL_INTERLACE)
00428             #print value[0: min( 100, len(value)-1 )]
00429 
00430         toShow = min( nbOf, showValues )
00431         if toShow < 0: toShow = nbOf
00432         for I in range( toShow ):
00433             if elements:
00434                 i = elements[ I ]
00435             else:
00436                 i = I+1
00437             if mode == MED_FULL_INTERLACE:
00438                 valueI = f.getRow(i)
00439             else:
00440                 valueI = []
00441                 for j in range( nbcomp ):
00442                     for k in range( f.getNbGaussI( i ) ):
00443                         valueI.append( f.getValueIJK(i,j+1,k+1) )
00444             print '         ',i,' - ',valueI #[:nbcomp]
00445             pass
00446         if nbOf > toShow:
00447             print '            ...skip',nbOf - toShow,'values'
00448             pass
00449         pass
00450     pass

def dumpMEDMEM.ShowGroup (   group,
  showElems 
)

Dump a GROUP.

Optionally dump nodal connectivity of <showElems> first elements of the group. Use showElems=SHOW_ALL to dump connectivity of all elements.

Definition at line 190 of file dumpMEDMEM.py.

00190 
00191 def ShowGroup(group, showElems):
00192     groupName = group.getName()
00193     groupDescription = group.getDescription()
00194     nbOfFam = group.getNumberOfFamilies()
00195     print "\nGROUP on",theEntityName[group.getEntity()]
00196     print tab*1,"-Name          :",groupName
00197     print tab*1,"-Description   :",groupDescription
00198     print tab*1,"-Nb Of Families:",nbOfFam
00199     print tab*1,"-Families"
00200     for k in range(nbOfFam):
00201         print tab*2,k+1,":",group.getFamily(k+1).getName()
00202         pass
00203     _showSupport(group,1,showElems)
00204     return

Here is the call graph for this function:

Here is the caller graph for this function:

def dumpMEDMEM.ShowGroups (   mesh,
  showElems = 0 
)

Dump all GROUP's in mesh.

Optionally dump nodal connectivity of <showElems> first elements of each group. Use showElems=SHOW_ALL to dump connectivity of all elements.

Definition at line 209 of file dumpMEDMEM.py.

00209 
00210 def ShowGroups(mesh, showElems=0):
00211     line = "groups in mesh <" + mesh.getName() + ">"
00212     print "\n",line,"\n","-"*len(line)
00213     for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
00214         nbGrp = mesh.getNumberOfGroups(entity)
00215         if nbGrp > 0:
00216             for j in range(nbGrp):
00217                 group = mesh.getGroup(entity,j+1)
00218                 ShowGroup(group,showElems)
00219             pass
00220         pass
00221     pass

Here is the call graph for this function:

def dumpMEDMEM.ShowMesh (   mesh,
  nodes2Show = 0,
  entity2Show = [0 
)

Dump mesh general information.

Optionally dump node coordinates of first <nodes2Show> nodes. <entity2Show> gives number of elements to dump nodal connectivity by entities: [<nb cells="" to="" show>="">, <nb faces>="">, <nb edges>=""> ]. Use SHOW_ALL to dump all elements or node coordinates.

Definition at line 228 of file dumpMEDMEM.py.

00228 
00229 def ShowMesh(mesh, nodes2Show=0, entity2Show=[0,0,0]):
00230     print "---------------------- MESH -------------------------"
00231     meshName   = mesh.getName()
00232     spaceDim   = mesh.getSpaceDimension()
00233     meshDim    = mesh.getMeshDimension()
00234     print "The mesh <%s> is a %dD mesh on a %dD geometry" % (meshName,meshDim,spaceDim)
00235     nbNodes    = mesh.getNumberOfNodes()
00236     print "There are",nbNodes,"MED_NODE's"
00237     coordSyst  = mesh.getCoordinatesSystem()
00238     print "The Coordinates :"
00239     coordNames = []
00240     coordUnits = []
00241     for isd in range(spaceDim):
00242         coordNames.append(mesh.getCoordinateName(isd))
00243         coordUnits.append(mesh.getCoordinateUnit(isd))
00244         pass
00245     print tab,"system:",coordSyst
00246     print tab,"names:", coordNames
00247     print tab,"units:", coordUnits
00248     ## coordinates
00249     if nodes2Show:
00250         print tab,"values:"
00251         coordinates = mesh.getCoordinates(MED_FULL_INTERLACE)
00252         nbCoord = nodes2Show
00253         maxNbCoord = len( coordinates ) / spaceDim
00254         if nbCoord < 0: nbCoord = maxNbCoord
00255         else:           nbCoord = min( nbCoord, maxNbCoord )
00256         for k in range( nbCoord ):
00257             n = k*spaceDim
00258             print tab*2,k+1,coordinates[n:n+spaceDim]
00259             pass
00260         if nbCoord < maxNbCoord: print tab*2,"... %d nodes skipped" % (maxNbCoord-nbCoord)
00261         pass
00262     # elem types
00263     print "The Elements :"
00264     i = -1
00265     for entity in [MED_CELL,MED_FACE,MED_EDGE]:
00266         i += 1
00267         entityName = theEntityName[ entity ]
00268         if mesh.getNumberOfElements(entity,MED_ALL_ELEMENTS) < 1: continue
00269         nbTypes = mesh.getNumberOfTypes( entity )
00270         try:
00271             types = mesh.getTypes( entity )
00272         except:
00273             continue
00274         print tab,"%s types:" % entityName
00275         for type in types:
00276             nbElemType = mesh.getNumberOfElements(entity,type)
00277             print tab*2,"%s: \t %d elements" % ( theTypeName[ type ], nbElemType )
00278             pass
00279         # nodal connectivity
00280         if i >= len( entity2Show ): break
00281         if not entity2Show[ i ]: continue
00282         print tab,"%s nodal connectivity:" % entityName
00283         for type in types:
00284             typeName = theTypeName[ type ]
00285             nbElemType = mesh.getNumberOfElements(entity,type)
00286             if nbElemType == 0:
00287                 continue
00288             d = 1
00289             number = range (d, nbElemType+d)
00290             _showNodalConnectivity(mesh,entity,type,number,2,entity2Show[ i ])
00291             pass
00292         pass
00293 
00294     print "----------------------Groups, Families-------------------------"
00295     nbF = 0
00296     nbG = 0
00297     for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
00298         nbFam = mesh.getNumberOfFamilies(entity)
00299         nbGrp = mesh.getNumberOfGroups(entity)
00300         nbElem= mesh.getNumberOfElements(entity, MED_ALL_ELEMENTS);
00301         nbF += nbFam
00302         nbG += nbGrp
00303         if (entity == MED_NODE) :
00304             if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)"
00305             if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)"
00306             if (nbElem> 0) : print "This mesh has",nbElem,"Node Element(s)"
00307             pass
00308         elif (entity == MED_CELL) :
00309             if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)"
00310             if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)"
00311             if (nbElem> 0) : print "This mesh has",nbElem,"Cell Element(s)"
00312             pass
00313         elif (entity == MED_FACE) :
00314             if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)"
00315             if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)"
00316             if (nbElem> 0) : print "This mesh has",nbElem,"Face Element(s)"
00317             pass
00318         elif (entity == MED_EDGE) :
00319             if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)"
00320             if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)"
00321             if (nbElem> 0) : print "This mesh has",nbElem,"Edge Element(s)"
00322             pass
00323         pass
00324     print "Total nbF", nbF,"nbG",nbG
00325     return

Here is the call graph for this function:

def dumpMEDMEM.supprimer (   f)

Definition at line 489 of file dumpMEDMEM.py.

00489 
00490 def supprimer(f):
00491     if os.access(f, os.F_OK):
00492         os.remove(f)
00493 
00494 # Remove a file if it exists

Here is the caller graph for this function:


Variable Documentation

Definition at line 67 of file dumpMEDMEM.py.

Initial value:
00001 { 6 : "REEL64",
00002                    24: "INT32",
00003                    26: "INT64",
00004                    0 : "UNDEFINED_TYPE" }

Definition at line 60 of file dumpMEDMEM.py.

Initial value:
00001 { 0:"FULL_INTERLACE",
00002                   1:"NO_INTERLACE",
00003                   3:"UNDEFINED_INTERLACE" }

Definition at line 56 of file dumpMEDMEM.py.

Definition at line 70 of file dumpMEDMEM.py.

string dumpMEDMEM.tab = " "

Definition at line 65 of file dumpMEDMEM.py.

Initial value:
00001 { MED_CELL        :"CELL",
00002                   MED_FACE        :"FACE",
00003                   MED_EDGE        :"EDGE",
00004                   MED_NODE        :"NODE",
00005                   MED_ALL_ENTITIES:"ALL_ENTITIES" }

Definition at line 30 of file dumpMEDMEM.py.

Initial value:
00001 {MED_NONE        :"NONE",
00002                MED_POINT1      :"POINT1",
00003                MED_SEG2        :"SEG2",
00004                MED_SEG3        :"SEG3",
00005                MED_TRIA3       :"TRIA3",
00006                MED_QUAD4       :"QUAD4",
00007                MED_TRIA6       :"TRIA6",
00008                MED_QUAD8       :"QUAD8",
00009                MED_TETRA4      :"TETRA4",
00010                MED_PYRA5       :"PYRA5",
00011                MED_PENTA6      :"PENTA6",
00012                MED_HEXA8       :"HEXA8",
00013                MED_TETRA10     :"TETRA10",
00014                MED_PYRA13      :"PYRA13",
00015                MED_PENTA15     :"PENTA15",
00016                MED_HEXA20      :"HEXA20",
00017                MED_POLYGON     :"POLYGON",
00018                MED_POLYHEDRA   :"POLYHEDRA",
00019                MED_ALL_ELEMENTS:"ALL_ELEMENTS"}

Definition at line 36 of file dumpMEDMEM.py.