aboutsummaryrefslogtreecommitdiff
path: root/pyfrm2xdmf
diff options
context:
space:
mode:
authorPaul Garlick <pgarlick@tourbillion-technology.com>2016-03-17 20:40:18 +0000
committerPaul Garlick <pgarlick@tourbillion-technology.com>2016-03-17 20:44:19 +0000
commitc98547931d611bc5d5dd754ef29594b863f28eb9 (patch)
treea21f5b9748dd0477dfd25e16a6055cb518f80f0c /pyfrm2xdmf
parent086746ff58a19456111c9999e91e8a63e7e88acb (diff)
downloadpyfrUtils-c98547931d611bc5d5dd754ef29594b863f28eb9.tar.gz
pyfrm2xdmf: add Function DataItem to allow concatenation of 1D-arrays
Diffstat (limited to 'pyfrm2xdmf')
-rwxr-xr-xpyfrm2xdmf42
1 files 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(' <Geometry GeometryType="X_Y">\n') # co-ordinates in separate arrays
else:
xdmfFile.write(' <Geometry GeometryType="X_Y_Z">\n') # co-ordinates in separate arrays
- writeHyperSlab(xdmfFile, nDims, nCells, nVerts, pyfrm, dataset)
+ for coord in range(nDims):
+ xdmfFile.write(' <DataItem ItemType="Function" Dimensions="{}"\n'.format(nVerts*nCells)) # 1D-array
+ xdmfFile.write(' Function="JOIN({})">\n'.format(' ; '.join("$" + str(k) for k in range(nVerts))))
+ writeHyperSlab(xdmfFile, coord, nDims, nCells, nVerts, pyfrm, dataset)
+ xdmfFile.write(' </DataItem>\n')
xdmfFile.write(' </Geometry>\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(' <DataItem ItemType="HyperSlab"\n')
- xdmfFile.write(' Dimensions="{} 1 1"\n'.format(nCells*nVerts))
- xdmfFile.write(' Type="HyperSlab">\n')
- xdmfFile.write(' <DataItem\n') # start, stride and count of hyperslab region
- xdmfFile.write(' Dimensions="3 3"\n')
- xdmfFile.write(' Format="XML">\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(' </DataItem>\n')
- xdmfFile.write(' <DataItem\n')
- xdmfFile.write(' Name="Points" \n')
- xdmfFile.write(' Dimensions="{} {} {}"\n'.format(nVerts, nCells, nDims))
- xdmfFile.write(' Format="HDF">\n')
- xdmfFile.write(' {}:/{}\n'.format(pyfrm, dataset))
+ for vert in range(nVerts):
+ xdmfFile.write(' <DataItem ItemType="HyperSlab"\n')
+ xdmfFile.write(' Dimensions="{} 1 1"\n'.format(nCells))
+ xdmfFile.write(' Type="HyperSlab">\n')
+ xdmfFile.write(' <DataItem\n') # start, stride and count of hyperslab region
+ xdmfFile.write(' Dimensions="3 3"\n')
+ xdmfFile.write(' Format="XML">\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(' </DataItem>\n')
+ xdmfFile.write(' <DataItem\n')
+ xdmfFile.write(' Name="Points" \n')
+ xdmfFile.write(' Dimensions="{} {} {}"\n'.format(nVerts, nCells, nDims))
+ xdmfFile.write(' Format="HDF">\n')
+ xdmfFile.write(' {}:/{}\n'.format(pyfrm, dataset))
+ xdmfFile.write(' </DataItem>\n')
xdmfFile.write(' </DataItem>\n')
- xdmfFile.write(' </DataItem>\n')
return
def writeAttribute(xdmfFile, tag):