(prefix, prefix_new, nvertex, ncells, nmem, dt, indices, lsData, tohdf5=False, prec=8, append2prefix="_resampled")
| 25 | |
| 26 | |
| 27 | def recreateXdmf(prefix, prefix_new, nvertex, ncells, nmem, dt, indices, lsData, tohdf5=False, prec=8, append2prefix="_resampled"): |
| 28 | full_prefix = prefix |
| 29 | prefix = os.path.basename(prefix) |
| 30 | prefix_new = os.path.basename(prefix_new) |
| 31 | |
| 32 | # fault and surface output have 3 colums in connect |
| 33 | ncolConnect = 4 |
| 34 | scell = "Tetrahedron" |
| 35 | lsplit = prefix.split("-") |
| 36 | if len(lsplit) > 1: |
| 37 | if lsplit[-1] in ["surface", "fault"]: |
| 38 | ncolConnect = 3 |
| 39 | scell = "Triangle" |
| 40 | |
| 41 | if tohdf5: |
| 42 | colonOrNothing = ".h5:" |
| 43 | DataExtension = "" |
| 44 | DataFormat = "HDF" |
| 45 | else: |
| 46 | colonOrNothing = "" |
| 47 | DataExtension = ".bin" |
| 48 | DataFormat = "Binary" |
| 49 | |
| 50 | # create and print the new Xdmf file |
| 51 | header = """<?xml version="1.0" ?> |
| 52 | <!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []> |
| 53 | <Xdmf Version="2.0"> |
| 54 | <Domain> |
| 55 | <Grid Name="TimeSeries" GridType="Collection" CollectionType="Temporal">""" |
| 56 | |
| 57 | score = "" |
| 58 | |
| 59 | for i, ii in enumerate(indices): |
| 60 | score = ( |
| 61 | score |
| 62 | + """ <Grid Name="step_%012d" GridType="Uniform"> |
| 63 | <Topology TopologyType="%s" NumberOfElements="%d"> |
| 64 | <DataItem NumberType="Int" Precision="8" Format="%s" Dimensions="%d %d">%s_cell%s/mesh0/connect%s</DataItem> |
| 65 | </Topology> |
| 66 | <Geometry name="geo" GeometryType="XYZ" NumberOfElements="%d"> |
| 67 | <DataItem NumberType="Float" Precision="8" Format="%s" Dimensions="%d 3">%s_vertex%s/mesh0/geometry%s</DataItem> |
| 68 | </Geometry> |
| 69 | <Time Value="%f"/>\n""" |
| 70 | % ( |
| 71 | ii, |
| 72 | scell, |
| 73 | ncells, |
| 74 | DataFormat, |
| 75 | ncells, |
| 76 | ncolConnect, |
| 77 | prefix_new, |
| 78 | colonOrNothing, |
| 79 | DataExtension, |
| 80 | nvertex, |
| 81 | DataFormat, |
| 82 | nvertex, |
| 83 | prefix_new, |
| 84 | colonOrNothing, |
no test coverage detected