[vtkusers] ExodusII Block name and Element type

Eugen Wintersberger eugen.wintersberger at desy.de
Mon Mar 14 06:02:46 EDT 2011


Hi there
  I need to store a VTK MultiBlock dataset to an ExodusII file. This
works so far without problems except for the Block name and the element
type stored in the ExodusII file. 
Although I can set the NAME attribute in a blocks metadata,
vtkExodusIIWriter seems to overwrite this values. 

Ok. Here is basically what I am doing

//create the MultiBlock dataset
mbset = vtk.vtkMultiBlockDataSet()
mbset.SetNumberOfBlocks(number)

//read an unstructured grid from a VTK file - one for each block
//the content of each file is stored in a block of the 
//MultiBlockDataSet
for i in range(0,number):
	
	reader = vtk.vtkUnstructuredGridReader()
	print 'Block ' + str(i) + 'read'

	domainname = 'domain' + str(i)
	dfilename = folder + domainname +'.vtk'

	reader.SetFileName(dfilename)
	reader.SetReadAllScalars(1)
	reader.SetReadAllVectors(1)
	#reader.ReadAllVectorsOn()
	reader.Update()

	mbset.SetBlock(i, reader.GetOutput())
	
	//here I set the name of the block in the VTK 
	//MultiBlockDataSet
	mbset.GetMetaData(i).Set(vtk.vtkCompositeDataSet.NAME(), 
				 domainname)

	//update the DataSet
	mbset.Update()
	mbset.UpdateData()
	mbset.UpdateInformation()


//after finishing the MultiBlockDataSet it should be 
//written to an ExodusII file
writer = vtk.vtkExodusIIWriter()
writer.SetFileName(filename)
writer.SetInput(mbset)

writer.WriteOutBlockIdArrayOn()
writer.WriteOutGlobalElementIdArrayOn()
writer.WriteOutGlobalNodeIdArrayOn()
writer.WriteAllTimeStepsOn()
writer.SetBlockIdArrayName('data')
writer.UpdateWholeExtent()
writer.GetModelMetadata().SetTitle('Ge wire on Si substrate')
writer.UpdateInformation()
writer.Update()

For testing I used two VTK files as input (two datasets of type
vtkUnstructuredGrid). The grids should have the names "domain0" and 
"domain1" in the ExodusII file (see code above). 
However, if I read the data back using the vtkExodusIIReader I get 
the following names for the blocks:

Blocks:
      Element block 10 "Unnamed block ID: 10 Type: TETRA Size: 611" (611)
          ....
          Type: TETRA
          ....
      Element block 78 "Unnamed block ID: 78 Type: TETRA Size: 2997" (2997)
          ....
          Type: TETRA
          ....

Obviously the name of the element blocks is not what I have 
set in the code above. 

How do I set the name of an element block (the element type would be
important too) correctly using the ExodusII writer?
Thanks in advance.

best regards
    Eugen Wintersberger




More information about the vtkusers mailing list