Skip to content

Commit c08fe58

Browse files
filippo-biondindem0
authored andcommitted
Added parsing of mesh points in binary format
1 parent 919d943 commit c08fe58

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

smithers/io/openfoam/mesh_parser.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,18 @@ def parse_line(line):
198198
except ValueError:
199199
pass
200200

201-
string_coords = content[start_idx:start_idx+num_points]
201+
if not is_binary:
202+
string_coords = content[start_idx:start_idx+num_points]
202203

203-
data = np.array(list(map(parse_line, string_coords)), dtype=float)
204-
return data
205-
206-
#TODO binary
207-
# if is_binary:
208-
# buf = b''.join(content[n+1:])
209-
# disp = struct.calcsize('c')
210-
# vv = np.array(struct.unpack('{}d'.format(num*3),
211-
# buf[disp:num*3*struct.calcsize('d') + disp]))
212-
# data = vv.reshape((num, 3))
204+
data = np.array(list(map(parse_line, string_coords)), dtype=float)
205+
else:
206+
buf = b''.join(content[start_idx-1:])
207+
disp = struct.calcsize('c')
208+
vv = np.array(struct.unpack('{}d'.format(num_points*3),
209+
buf[disp:num_points*3*struct.calcsize('d') + disp]))
210+
data = vv.reshape((num_points, 3))
213211

212+
return data
214213

215214
@classmethod
216215
def parse_owner_neighbour_content(cls, content, is_binary, skip=10):

0 commit comments

Comments
 (0)