BACKGROUND:
I am working with large geometries that will be meshed or broken down into smaller parts and then regrouped. So, for instance, if a block was broken into 16 pieces, it might be reorganized into 4 “Patches” with 4 pieces or elements each. After this process, I still need to keep track of the elements. I assigned the patchIndex (I have a list of the number of patches) as the “key” that will give back the all the elements in the patch and their 1) local index (the index of the element within the patch) and their 2) global index (the index of the element within the entire geometry).
PROBLEM:
How on earth can I get this information into an HDF5 file?
MY CODE:
Here is how I am setting up my dictionary if that is helpful to know:
def readAscii(ElementsList,gpmetisfile):
f = open(gpmetisfile, 'r')
indexer={}
i=0
for line in gpmetisfile:
patchIndex = eval(line)
if patchIndex in indexer:
localIndex=indexer[patchIndex]
else:
indexer[patchIndex]=0
test = ElementsList[i].setLocalIndex(patchIndex,localIndex)
if test:
indexer[patchIndex] +=1
EDIT – the gpmetisfile is what I use to break down the geometry into pieces. It comes in the format of the nth line corresponding to the nth element that simply has a single value, the patch it belongs to. ElementsList is a list of the elements in the geometry.
I do not fully understand the details of your problem but the easiest way to work with hdf5 file is using the nice h5py library. Here you can find the documentation.