Skip to content

Commit 4a2cf47

Browse files
committed
Fix for wrong offset
1 parent ccc1019 commit 4a2cf47

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fdsreader/simulation.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,14 @@ def _load_boundary_data(self, smv_file: TextIO, line: str, cell_centered: bool):
624624

625625
with open(file_path, 'rb') as infile:
626626
# Offset of the binary file to the end of the file header.
627-
offset = 3 * fdtype.new((('c', 30),)).itemsize
628-
infile.seek(offset)
627+
initial_offset = 3 * fdtype.new((('c', 30),)).itemsize
628+
infile.seek(initial_offset)
629629

630630
n_patches = fdtype.read(infile, fdtype.INT, 1)[0][0][0]
631631

632632
dtype_patches = fdtype.new((('i', 9),))
633633
patch_infos = fdtype.read(infile, dtype_patches, n_patches)
634-
offset += fdtype.INT.itemsize + dtype_patches.itemsize * n_patches
634+
initial_offset += fdtype.INT.itemsize + dtype_patches.itemsize * n_patches
635635
patch_offset = fdtype.FLOAT.itemsize
636636

637637
# Determine the size of the data block for all patches
@@ -643,9 +643,10 @@ def _load_boundary_data(self, smv_file: TextIO, line: str, cell_centered: bool):
643643

644644
# Time info
645645
time_bytes = fdtype.FLOAT.itemsize
646-
n_t = (os.stat(file_path).st_size - offset) // (time_bytes + patches_data_bytes)
646+
n_t = (os.stat(file_path).st_size - initial_offset) // (time_bytes + patches_data_bytes)
647647

648648
times = list()
649+
offset = initial_offset
649650
for _ in range(n_t):
650651
time = fdtype.read(infile, fdtype.FLOAT, 1)[0][0][0]
651652
times.append(time)
@@ -660,7 +661,7 @@ def _load_boundary_data(self, smv_file: TextIO, line: str, cell_centered: bool):
660661
obst_index = patch_info[7] - 1
661662

662663
p = Patch(file_path, dimension, extent, orientation, cell_centered,
663-
patch_offset, offset, n_t, mesh)
664+
patch_offset, initial_offset, n_t, mesh)
664665

665666
# "Obstacles" with index -1 give the extent of the (whole) mesh faces and refer to
666667
# "closed" mesh faces, therefore that data will be added to the corresponding mesh instead

0 commit comments

Comments
 (0)