From c98547931d611bc5d5dd754ef29594b863f28eb9 Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Thu, 17 Mar 2016 20:40:18 +0000 Subject: pyfrm2xdmf: add Function DataItem to allow concatenation of 1D-arrays --- pyfrm2xdmf | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/pyfrm2xdmf b/pyfrm2xdmf index b7e1be3..7b88716 100755 --- a/pyfrm2xdmf +++ b/pyfrm2xdmf @@ -37,30 +37,34 @@ def writeGeometry(xdmfFile, nDims, nCells, nVerts, pyfrm, dataset): xdmfFile.write(' \n') # co-ordinates in separate arrays else: xdmfFile.write(' \n') # co-ordinates in separate arrays - writeHyperSlab(xdmfFile, nDims, nCells, nVerts, pyfrm, dataset) + for coord in range(nDims): + xdmfFile.write(' \n'.format(' ; '.join("$" + str(k) for k in range(nVerts)))) + writeHyperSlab(xdmfFile, coord, nDims, nCells, nVerts, pyfrm, dataset) + xdmfFile.write(' \n') xdmfFile.write(' \n') return -def writeHyperSlab(xdmfFile, nDims, nCells, nVerts, pyfrm, dataset): +def writeHyperSlab(xdmfFile, coord, nDims, nCells, nVerts, pyfrm, dataset): "write HyperSlab element" - for coord in range(nDims): - xdmfFile.write(' \n') - xdmfFile.write(' \n') - xdmfFile.write(' 0 0 {}\n'.format(coord)) # select co-ordinate - xdmfFile.write(' 1 1 1\n') # select every vertex in every cell - xdmfFile.write(' {:<3} {} 1\n'.format(nVerts, nCells)) # loop over cells (first) and vertices (second) - xdmfFile.write(' \n') - xdmfFile.write(' \n') - xdmfFile.write(' {}:/{}\n'.format(pyfrm, dataset)) + for vert in range(nVerts): + xdmfFile.write(' \n') + xdmfFile.write(' \n') + xdmfFile.write(' {:<3} 0 {}\n'.format(vert, coord)) # select vertex and co-ordinate (format is vertex, cell, co-ordinate) + xdmfFile.write(' 1 1 1\n') # select every cell, for this vertex and co-ordinate + xdmfFile.write(' 1 {} 1\n'.format(nCells)) # loop over cells + xdmfFile.write(' \n') + xdmfFile.write(' \n') + xdmfFile.write(' {}:/{}\n'.format(pyfrm, dataset)) + xdmfFile.write(' \n') xdmfFile.write(' \n') - xdmfFile.write(' \n') return def writeAttribute(xdmfFile, tag): -- cgit